| Author |
Encapsulating collection membership
|
Malcolm Storey
Ranch Hand
Joined: Nov 09, 2008
Posts: 31
|
|
In my multi-windows app, am going to need various collections of my own objects. Am wondering whether it is better to: A. encapsulate membership in member object creation (via factory method - don't want premature exposure!) B. let the creator handle membership Encapsulation makes managing membership over new/dispose cycles much less error prone and also facilitates a Dispose() method to unhook the object from all Collections of which it is a member. (This would be through my own Collectable interface.) This naturally leads to a hierarchy of collections (app<-windows<-page-<my_primitives) which would be recursively iterated on Dispose(). [Yes, this is over-kill - some of those collections would also be being Disposed, but it would make life easier for GC and not worth trying to programmatically avoid. Dispose() will do other things too.] Is this good design or am I getting carried away by the fun of it all? [ November 18, 2008: Message edited by: Malcolm Storey ]
|
Malcolm
I wouldn't join any Collection with an add() method that would accept me as a parameter
|
 |
 |
|
|
subject: Encapsulating collection membership
|
|
|