OOP Design: Should groups create lists of users? or...
Posted: Wed Jun 30, 2010 5:01 am
Hi all
I'm currently building a system using DAOs (accessing a relationship database) to generate domain objects.
The intention to to try and ensure as little dependency between the domain objects and DAOs, so that I could in the future replace the DAOs without having to rebuild the domain layer.
I'm currently confused about the best way to approach one concept.
I need to create a list of users within a group
EITHER I ask the Group DAO to create a list of user objects
-the Group DAO would get a list of user keys, and for each one ask the User DAO to create a new User Object which will all be added into a User List Object which I can then iterate through
OR I ask the User DAO to create a list of User Objects for a given group
- the User DAO would be fed a group key, and then create a new User Object for every case which would be added to the User List Object.
For me the first case makes more sense, but it means that the Group Dao now understands how Users are assigned to it, increasing the coupling within my system.
Any thoughts?
To extend this thought I'm thinking through the following options
Either I can ask the Group -> getUserList(self)
or I can ask the User -> getSelfList(group)
this then poses the question if I want to know which group(s) a user belongs to should I do....
Group->getSelfBy(user)
User->getGroupBy(self)
Thanks
Alec
I'm currently building a system using DAOs (accessing a relationship database) to generate domain objects.
The intention to to try and ensure as little dependency between the domain objects and DAOs, so that I could in the future replace the DAOs without having to rebuild the domain layer.
I'm currently confused about the best way to approach one concept.
I need to create a list of users within a group
EITHER I ask the Group DAO to create a list of user objects
-the Group DAO would get a list of user keys, and for each one ask the User DAO to create a new User Object which will all be added into a User List Object which I can then iterate through
OR I ask the User DAO to create a list of User Objects for a given group
- the User DAO would be fed a group key, and then create a new User Object for every case which would be added to the User List Object.
For me the first case makes more sense, but it means that the Group Dao now understands how Users are assigned to it, increasing the coupling within my system.
Any thoughts?
To extend this thought I'm thinking through the following options
Either I can ask the Group -> getUserList(self)
or I can ask the User -> getSelfList(group)
this then poses the question if I want to know which group(s) a user belongs to should I do....
Group->getSelfBy(user)
User->getGroupBy(self)
Thanks
Alec