cerebis wrote:
I do not see why this destroys the separation of concerns. Yes the classes share the same location, but they are still handling their various responsibilities in exactly the same manner. I will concede that imports are now less specific: the dao is exposed to the client class when importing the pojo, but its not quite wide open. If anything, you could just nest the dao/impl alone and avoid this side effect. However, wildcard imports achieving the same result and I do run across them.
Separation of concerns is more than just allocating responsibility to classes - it's also about allocating responsibility to different architectural layers, and making sure that the code is running in the right layer.
You don't necessarily _need_ a completely layered architecture in all cases, but as I was saying, in those cases, nesting inners doesn't buy you a whole lot.
Now, I'm a big fan of inner classes, but that's more in cases where I can make use of the inner having visibility to the outer classes members and final local variables. I look at these cases as the outer and all of his inners as collaborators in the same concern, though. Kind of a multi-headed beast.
Quote:
There is also nothing to stop you having multiple implementations, though some might argue that this would lead quickly to overly large files.
Well file size (in my book) is the lesser consideration. If you have all the implementations in one place you're giving yourself a pretty diluted version of the plugability and clarity of separation between contract and implementation. You're liable to wind up with a tighter coupling than you really had in mind as the software evolves over time. Again, if you don't mind tight coupling, why introduce the interface at all?
Quote:
I must admit I come from the land of C/C++, where good or bad the per file convention is not enforced by the language. Maybe I have terrible habits, but I like to think that I am fairly introspective and rational about things. This thread is to gather opinion. Perhaps I am over compensating for what I consider a tendency for rather anemic pojos. Take away get/set from some projects I've seen, and the classes are simply C structs.
The only difference between C++ struct and class is the default visibility of members. In Java, there are cases where I make data members public and javadoc the class as a 'struct.' These are always small classes, usually private to a subsystem, though. As far as real entities go, I've had too many occassions (back to my C++ days) where something got hosed because of a lack of control over what got put into a data member, or fields that were simple data become calculated or need a check ...