If you're sure the User will only ever have one role, then a roleID column
in the User table is fine. However, in practice I would be very leery of
such a decision, particularly with something like a Role where a User can
almost certainly have more than one Role. In that case, a link table that
relates userID to roleID is almost certainly the better way to go.

I would have the User compose a Role (or an array of Roles).

I'm not sure what you mean about "where the composition should be taking
place" though. The only place it should matter is in the User itself. The
Service layer doesn't represent individual users (that's what the User
object is for) so there's really no way for the User to Role relationship to
have an impact on the Service, unless I'm not understanding what you're
asking.

Regards,

Brian


On Mon, Aug 4, 2008 at 4:43 PM, Dean Lawrence <[EMAIL PROTECTED]> wrote:

> I've moved to using OOP about 8 months ago after 10 years of working with
> CF in a procedural manner. I have a pretty good understanding of how it
> works, but I always seem to struggle with composition and where in my model
> should the objects be created and stored. Hopefully someone can shed some
> light for me.
>
> I have a simple User object that can have a single role. So I have one of
> the Object attributes as being of type Role. The Role object is simply a
> roleid, name, and permission level. The question I have is this, should I
> store this single relation within a relationship table in my DB or should
> the User table contain a roleID field? I know it is 6 of one, half dozen of
> another, but I wanted to see what other people are doing.
>
> Along those same lines, if I store the roleID in the user table, should my
> User object have both a Role and a roleID attribute (one being the object,
> the other being just the user field value)? Also, I am using a
> Service/Gateway/DAO/Bean model, should the composition be taking place in
> the Service layer or the Bean layer. I've been doing in the Service layer,
> but I am not sure if this is correct.
>
> My environment is Model-Glue/Coldspring if that helps.
>
> Thanks and sorry for the long-winded question.
>
> Dean
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310173
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to