iddqd
iddqd

Reputation: 1305

Is it considered bad practice in java for a package to contain both classes and sub-packages?

Is it considered a bad practice in java to have a structure where some package/s contain both classes and sub packages? i.e :

com/
  domain/
     SomeClass.java
     AnotherClass.java
     model/
       Model1.java
       Model2.java
     somePackage/
        SomePackageClass.java

The other option being SomeClass.java and AnotherClass.java contained in third package

Upvotes: 0

Views: 301

Answers (1)

Veselin Davidov
Veselin Davidov

Reputation: 7071

No it's normal structure and not a bad practice. You have different levels in the tree structure. If the class logically is best suited in the parent package then leave it there. If these two classes share a common role that differs them from the others then you can move them to a separate package.

Upvotes: 4

Related Questions