Single Responsibility Principle can be Taken Too Far
In the .net framework, every single class you ever write will violate Single Responsibility Principle (SRP).
Why?
Every object in .net has a method called GetHashCode. And... horrors of horrors, every object has a method called ToString. You can, and often, need to override one or both of them. They provide certain functionality to everything, up to, and including, drumroll.... allowing objects to generate hash codes and allowing them to be converted to strings.
I guess it is time to quit coding in .net and simply adopt Ruby. Oh, wpps, the object class in Ruby has methods too. In fact, it would not surprise me that you could override them in a consumer class that, say, inherits from object (evil grin...) My bad. Next idea?
The question, I suppose, is this - how much do we want to allow our primitive objects to do? From time to time, I hear people state that CSLA and TDD are not compatible - and one big reason is that CSLA allegedly breaks SRP, because neither are all it super class methods public, and you have a lot of things you get with CSLA that don't relate purely to what the object is supposed to do in it's 'pure' state.
I have even heard arguments that inheritance is broken, and should never be used. Every is-a is a has-a just waiting to grow up. Every set of private methods is a new class waiting to be discovered. And so on and so forth.
Hmm... seems like we are going a little far there. Lets go back to why encapsulation is a good thing. You see, the fewer external points of input something has, the less we have to test. Opening up everything simply adds to the test load. I suppose if you are full on test-driven, that might be ok. But doesn't that beg the question... why are we orienting our entire design around whether a unit test can be written for it? I mean, unit testing is important, but isn't this a little far?
The fact is - if you are using .net, you do not have 100% test coverage. The .net framework has a method on string called Split. I use it a great deal when parsing. I am pretty sure nobody, except perhaps, somebody at Microsoft, maybe, has ever written a unit test for it. Did you write a test for it? No? Then technically, you don't have 100% test coverage. You took it as a leap of faith that someone at Microsoft tested that. Unless your tool that reports test coverage includes framework bits in it's coverage calculation... which probably none of them do (I haven't checked... do I need to?).
In other words, you take it on faith that the 'evil empire' has tested the .net framework... and therefore, you don't.
Now, lets say you use CSLA - a framework used by 100s of companies on several continents. Maybe I am going out on a limb here, but if you use CSLA, doesn't BusinessBase, with all it's inherent functionality, replace what object would be of you were doing straight POCOs? My open question for the commenters is this (a call for papers, if you like) - where is the border drawn between code we have to test, and code we take on faith that works? Clearly, testing 'object' is too far, since most test programs don't consider it in coverage calculations. Clearly, testing your own class you just wrote is not too far, since it is, well, untested. There is a middle-ground in-between those two extremes. I want to know where people think the line of demarcation is...