A Henry P. Erich III Blog

A Geek In and Around Orlando

<December 2008>
SuMoTuWeThFrSa
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910


Navigation

Links

Subscriptions



Friday, April 02, 2004 - Posts

Enforcing Relational Business Rules Between Parent And Child Objects

Say we have two objects: User and Group.

Each of these objects each have their Add, Edit, and Delete methods.

Each of these objects each have a Search method created as Static so it can be called without 'creating an object' and returns a Strongly Typed Collection.   For example to search for users with a list name 'Erich' we could d

UserCollection UserSearchResults = User.Search(params);

Now here comes where I have a question.   Users belong to Groups so I could have User.AddToGroup(Group) because im adding a user to a group.   Or I could have Group.AddUser(User) with basically the same logic, just reverse.

I was thinking about real world situation, where a person would want to become a member of a group, the person would request the group to allow them to become a member and the group would reply.   So I was thinking it would be neat to have some sort of separation of rules between the User and Group objects before allowing adding a relationship between the two.   But both would have to be done.  

Sort of like a User object contains its requirements for being in a Group and a Group has its requirements about what Users can be members.

Also this can be called from either ‘direction’ such as:

User.AddToGroup(Group) which somehow also calls the Group.AddUser(User)

Or I could have called:

Group.AddUser(User) which somehow also calls the User.AddToGroup(Group)

And the logic in User.AddToGroup() method would only care about the Users point of view whereas the logic in the Group.AddUser() method would only care about the Groups point of view.

Im not going to edit this before posting to preserve the flow of thought. Sorry.

posted Friday, April 02, 2004 8:31 AM by he3 with 0 Comments




Powered by Dot Net Junkies, by Telligent Systems