| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| (I posted this earlier, but it not shown up after almost an hour. Please ignore this if I've double-posted) Hi, Suppose I have a control panel web site which allows me to manage multiple web sites. Each site can have multiple groups, and each group can have multiple members. I have the following objects and methods: Site +--getId() +--getName() Group +--getId() +--getName() Member +--getId() +--getName() Would adding the method getGroups() (returning an array of Group objects) to Site and the method getMembers() (returning an array of Member objects) to Group be bad design? |
|
#2
| |||
| |||
| On Oct 28, 1:09*pm, skeftomai <chad.d.john...@gmail.com> wrote: > (I posted this earlier, but it not shown up after almost an hour. > Please ignore this if I've double-posted) > > Hi, > > Suppose I have a control panel web site which allows me to manage > multiple web sites. Each site can have multiple groups, and each group > can have multiple members. I have the following objects and methods: > > Site > +--getId() > +--getName() > > Group > +--getId() > +--getName() > > Member > +--getId() > +--getName() > > Would adding the method getGroups() (returning an array of Group > objects) to Site and the method getMembers() (returning an array of > Member objects) to Group be bad design? err...my message did not post "momentarily" after submission...I don't understand--I don't see that there is a moderator for this group. Ignore this dupe. |
|
#3
| |||
| |||
| On 28 Oct, 20:09, skeftomai <chad.d.john...@gmail.com> wrote: > (I posted this earlier, but it not shown up after almost an hour. > Please ignore this if I've double-posted) google has been misbehaving for the last couple of days > Suppose I have a control panel web site which allows me to manage > multiple web sites. Each site can have multiple groups, and each group > can have multiple members. I have the following objects and methods: > > Site > +--getId() > +--getName() > > Group > +--getId() > +--getName() > > Member > +--getId() > +--getName() > > Would adding the method getGroups() (returning an array of Group > objects) to Site and the method getMembers() (returning an array of > Member objects) to Group be bad design? I'm no expert on this stuff but I thought I'd post my thoughts in the hope of being told why I'm wrong. I suppose it depends what you intend to do with the array (a collection might be better). Does the array contain values or references? Either way looks problematic. Could your function return an iterator instead? If you return values I start to worry about who owns the objects. Can you modify the objects in the array? What happens to the originals? -- Nick Keighley |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.