What's the standard way to organize the contents of Java packages -- specifically the location of in

Posted by RenderIn on Stack Overflow See other posts from Stack Overflow or by RenderIn
Published on 2010-06-11T16:43:58Z Indexed on 2010/06/11 16:52 UTC
Read the original article Hit count: 298

I suppose this could go for many OO languages. I'm building my domain objects and am not sure where the best place is for the interfaces & abstract classes.

If I have a pets package with various implementations of the APet abstract class: should it live side-by-side with them or in the parent package?

How about interfaces? It seems like they almost have to live above the implementations in the parent package, since there could potentially be other subpackages which implement it, while there seems to be a stronger correlation between one abstract class and a subpackage.

e.g.

com.foo
com.foo.IConsumer (interface)
com.foo.APet (abstract)
com.foo.pets.Dog extends APet implements IConsumer

OR

com.foo
com.foo.IConsumer (interface)
com.foo.pets.APet (abstract)
com.foo.pets.Dog extends APet implements IConsumer

or something else?

© Stack Overflow or respective owner

Related posts about java

Related posts about object-oriented-design