Click here to Skip to main content
15,902,939 members
Home / Discussions / C#
   

C#

 
GeneralRe: collections or methods? Pin
Judah Gabriel Himango15-Apr-04 10:22
sponsorJudah Gabriel Himango15-Apr-04 10:22 
GeneralRe: collections or methods? Pin
Heath Stewart15-Apr-04 10:51
protectorHeath Stewart15-Apr-04 10:51 
GeneralRe: collections or methods? Pin
Judah Gabriel Himango15-Apr-04 11:23
sponsorJudah Gabriel Himango15-Apr-04 11:23 
GeneralRe: collections or methods? Pin
Steven Campbell15-Apr-04 11:17
Steven Campbell15-Apr-04 11:17 
GeneralRe: collections or methods? Pin
Judah Gabriel Himango15-Apr-04 16:41
sponsorJudah Gabriel Himango15-Apr-04 16:41 
AnswerRe: collections or methods? Pin
scadaguy15-Apr-04 11:42
scadaguy15-Apr-04 11:42 
GeneralRe: collections or methods? Pin
Judah Gabriel Himango15-Apr-04 16:53
sponsorJudah Gabriel Himango15-Apr-04 16:53 
AnswerRe: collections or methods? Pin
bjoernen24-Apr-04 23:06
bjoernen24-Apr-04 23:06 
I prefer your solution (#1).

I don't buy the argument that external objects could break the inner workings of Foo children. Foo is a class that happens to have property named Children. It's up that object (Children) to maintain it's own integrity, just as any other property of Foo. Foo's responsibility is to make sure all it's property values make sense as a whole, not that they make sense within themselves. If the Foo class is interested in knowing about special events in the Children object, it can listen to them using an eventhandler, just as you have done in your design.

I would say #2 is a bad design, because Foo must know too much about the Children object type (class). That's the FooCollection's responsibilities, and can be easily done with indexers, properties and events. If your friend has a problem with your solution not being OO enough, I would say his solution is less OO.

Is there a special circumstance in that the Children object is of type FooCollection, making this a tree structure? Really not. I think the same design patterns should apply.

A sligthly better solution would be that FooCollection contains objects that implement the IFoo interface. Possibly overkill, but could be useful.

Regards,
/Björn Morén

GeneralHotkeys Pin
rickrf15-Apr-04 7:43
rickrf15-Apr-04 7:43 
GeneralRe: Hotkeys Pin
Tom Clement15-Apr-04 7:51
professionalTom Clement15-Apr-04 7:51 
GeneralRe: Hotkeys Pin
Heath Stewart15-Apr-04 8:41
protectorHeath Stewart15-Apr-04 8:41 
GeneralRe: Hotkeys Pin
Mazdak15-Apr-04 9:24
Mazdak15-Apr-04 9:24 
GeneralRe: Hotkeys Pin
Heath Stewart15-Apr-04 9:25
protectorHeath Stewart15-Apr-04 9:25 
GeneralRe: Hotkeys Pin
rickrf16-Apr-04 4:36
rickrf16-Apr-04 4:36 
GeneralRe: Hotkeys Pin
rickrf16-Apr-04 5:16
rickrf16-Apr-04 5:16 
GeneralRe: Hotkeys Pin
Bee Master16-Apr-04 17:46
Bee Master16-Apr-04 17:46 
QuestionWinForms bug? Pin
Tom Clement15-Apr-04 7:02
professionalTom Clement15-Apr-04 7:02 
GeneralC#: Question referring Generics Pin
SJ_Phoenix15-Apr-04 6:46
SJ_Phoenix15-Apr-04 6:46 
GeneralRe: C#: Question referring Generics Pin
Heath Stewart15-Apr-04 6:55
protectorHeath Stewart15-Apr-04 6:55 
GeneralRe: C#: Question referring Generics Pin
Heath Stewart15-Apr-04 7:02
protectorHeath Stewart15-Apr-04 7:02 
GeneralRe: C#: Question referring Generics Pin
SJ_Phoenix15-Apr-04 7:29
SJ_Phoenix15-Apr-04 7:29 
GeneralRe: C#: Question referring Generics Pin
Heath Stewart15-Apr-04 8:35
protectorHeath Stewart15-Apr-04 8:35 
GeneralRe: C#: Question referring Generics Pin
SJ_Phoenix15-Apr-04 9:52
SJ_Phoenix15-Apr-04 9:52 
Generalloading 3d models in opengl Pin
shedid15-Apr-04 6:28
shedid15-Apr-04 6:28 
GeneralRe: loading 3d models in opengl Pin
Judah Gabriel Himango15-Apr-04 7:52
sponsorJudah Gabriel Himango15-Apr-04 7:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.