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 8992601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:59:37+00:00 2026-06-15T22:59:37+00:00

I know the title probably isn’t too clear because I probably don’t have the

  • 0

I know the title probably isn’t too clear because I probably don’t have the right terminology, but an example should make it clear. Suppose I have an app with posts and comments, what would be the best practice as far as grouping those into namespaces/packages of the various ways. If there’s no better way, what are the advantages and disadvantages of both. Here are a couple different ways I envisioned, note this is in no way exhaustive, it’s just to get the point across:

1)

MyAp
|--Entities
|  |--AbstractEntity.class
|  |--Comment.class
|  |--Post.class
|--DataMappers
|  |--AbstractDataMapper.class
|  |--CommentDataMapper.class
|  |--PostDataMapper.class
|--DataMappers
|  |--AbstractService.class
|  |--CommentService.class
|  |--PostService.class

2)

MyAp
|--Abstract
|  |--AbstractDataMapper.class
|  |--AbstractEntity.class
|  |--AbstractService.class
|--Impl
|  |--Comment
|  |  |--Comment.class
|  |  |--CommentDataMapper.class
|  |  |--CommentService.class
|  |--Post
|  |  |--Post.class
|  |  |--PostDataMapper.class
|  |  |--PostService.class

With a big project, you could break either one of the methods above into broader groups. For example, for #1 you could have Db, Util, System, etc. beneath your Entities, DataMappers, and Services namespaces and would place class implementations in there while keep the AbstractEntity class under the Entities namespace. For #2, you could do the same putting those additional namespaces under Abstract and Impl.

I’m leaning towards #1 being better, seems like I would have to add additional Db, Util, System, etc. namespaces to 2 different places. But #2 has the appeal of keeping all classes related to one model class together. Can’t make up my mind!

  • 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-06-15T22:59:38+00:00Added an answer on June 15, 2026 at 10:59 pm

    I’d say there’s something wrong in both approaches.

    Most of developers tend to break classes by their main specialization. Mapper should go to mappers, model should go to models, helpers should go to helpers, interfaces to interfaces, we think first. That can be easy decision an the beginning of the project, but it causes some pain as time passes. It looks rather stupid some times. Especially when you need to extract a certain functionality into a separate component.

    From my experience I can say that you should group classes by their high-level function, or ‘sub-system’, or, as now DDD specifies ‘bounded context’. In the same time there shouldn’t be very may grouping levels.

    So – I can see all of your entities belong to Posting context. It can look strange enough, but I’d suggest that you put all of your classes to Posting fodler and do not create extra subfolders unless you have a very specific functionality area within the context.

    MyAp
    |--Core
       |--AbstractEntity.class 
       |--AbstractDataMapper.class
       |--AbstractService.class
    |--Posting
       |--Comment.class
       |--Post.class
       |--CommentDataMapper.class
       |--PostDataMapper.class
       |--CommentService.class
       |--PostService.class
    

    In general your second approach looks similar. In that case you can easy add more and more context-specific folders. Something like – ‘Voting’, ‘Notifications’, ‘Authentication’, etc. Also I’d suggest to choose the simplest way, and wait until you have some ‘critical mass’ of classes so you’d have enough information about how to group classes correctly.

    With the first approach you domain’s contexts would be spread over all folders.

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

Sidebar

Related Questions

The title might be worded strange, but it's probably because I don't even know
Probably have wrong title,but I don't know how to describe it. int x=0x4a; h=!(0x80000000000&(0x39+(~x+1)));
I don't know which title I should use for this question. I have a
I know the title makes this sound very easy, but I have a For
I know the title isn't very clear. I'm new to PHP, so there might
I know, great title right ;-) Anyway, lets say I have the following code
Alright, probably not the best title, but meh. I have the following code inside
I don't know if the title is clear enough, anyway what I need to
Sorry, that title probably doesn't make much sense, but what I want to know
That title probably doesn't sound right, but forgive me, I'm learning Rails for the

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.