Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4019466
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:06:29+00:00 2026-05-20T10:06:29+00:00

As projects that I’m working on grow larger and larger, I’m starting to be

  • 0

As projects that I’m working on grow larger and larger, I’m starting to be pretty unsure about dividing classes into packages. Suppose the project has a lot of layers and in these layers are interfaces and implementation and even more sublayers (components). I always end up with a lot of packages which starts to be little confusing.

So I want to know other people’s approaches to working with packages. Do you prefer to have a lot of packages with few classes or few packages with a lot of classes? Do you prefer to separate implementations from interfaces? And so on… In general your daily habits of using packages and pros/cons of your approach.

Thank you for your posts.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:06:29+00:00Added an answer on May 20, 2026 at 10:06 am

    Packages are meant to help you find things.

    If they make it more confusing than it is, you’re not doing something quite right. If the package structure isn’t intuitive, it can actually be harder to find classes than in a flat structure.

    There are two basic schools of organising classes into packages as far as I know:

    1. Organising by module first. Here your higher level packages are different modules of the system and you might split it further by function.
    2. Organising by function. Here you organise by function first (e.g. all controller classes in one package, all your data containers in another and so on) and optionally subdivide it by module.

    There are pros and cons for both systems, I find them roughlty equal, although I prefer the module approach slightly.

    The really important thing is though to follow one system and don’t mix it with the other. Don’t shoehorn classes into packages they don’t belong to and don’t be afraid to create a new package if your new class doesn’t seem to belong to any of your existing ones.

    If a package seems to have grown too large, you might want to split it. But the decision of whether a package should be split or not should be made on whether there is a clear conceptual divide between classes therein and not on numbers. A package with a single class is just as good as a package with thirty classes if it’s obvious why they’re there.

    As for separating interfaces and implementations, first off, I’d probably question the need for them. Ever so often I come across interfaces with only one reasonable implementation, which makes me question their reason to exist. (Sometimes there is a good reason, but often there isn’t.)

    But if you have multiple implementations for a given interface, then yes, I’d separate them. The interface would be com.foo.Bar and the implementations would be something like com.foo.bars.CrowBar, com.foo.bars.TaskBar for example. Obviously, if your implementations belong to different modules, then you would change it to com.foo.moduleX.bars.CrowBar or com.foo.bars.moduleX.CrowBar, depending on which system you’re following.

    Re-reading all this, it does sound kind of complicated, but probably the first sentence is the most important: don’t follow packaging principles blindly, packages should help you find classes, not hinder you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have projects that multiple developers are working on. We all work off the
I'm working on a small fun projects that builds a robot. We as the
I have a couple of projects that I'm working on in Eclipse (or any
I am working in projects that need to fetch all information of single person
In the projects that my team is currently working on, we have tens of
Sometimes when working on projects that people have posted online, I have to frantically
I had many Android projects that were working fine in my old pc. now,
I have multiple projects that shares child apps with other projects . When working
We have (currently) working projects that use Javascript API to get the Facebook session
I have an application with many projects that reference several NServiceBus NuGet packages. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.