ilovetolearn
ilovetolearn

Reputation: 2060

Coupling & Cohesion Design

This is a common situation I always faced during development work. For each modules, I will have to retrieve a list of users belonging to the respective department. ie. Human Resource / Finance / Purchasing

Should the retrieval of user logic be centralized at com.company.user module or I should have each respective module to retrieve the required users. ie. each module talks to the USER_TABLE ?

Based on my understanding of cohesion / coupling and DRY principle. I think the right way should of implementing this all the logic of retrieval of user by role should be centralized in the user package.

Am I correct to implement as such?

Package Level

com.company.financial
com.company.humanresource
com.company.purchasing
com.company.user

Upvotes: 1

Views: 280

Answers (2)

Wajdy Essam
Wajdy Essam

Reputation: 4340

Yes, you right. Packaging by feature is more modular than packaging by layer,

so the package:

com.company.user

can holds the following classes:

UserGUI.java // gui class for adding users
User.java    // user model
UserDAO.java // user data access object
UserAction.java // controllers

Useful article: Package by feature, not layer

Upvotes: 0

ControlAltDel
ControlAltDel

Reputation: 35096

Yes I think you are right. Retrieval of user logic should be in the user package

Upvotes: 3

Related Questions