|
Re: Design best practice : put state-independent methods on class side?: msg#00161lang.smalltalk.squeak.beginners
I'm guessing you like that the class methods can be invoked easily from the class name. What you want is a well known object. I try to do all my work on the instance side. That's where most of the objects are. I wouldn't use a class object just to create a well known object. I'd probably start with a Singleton and work from there. You can see drawbacks and alternatives to Singleton at c2.com: http://c2.com/cgi/wiki?SingletonPattern On Tue, Mar 25, 2008 at 12:41 PM, itsme213 <itsme213@xxxxxxxxxxx> wrote: > I have some methods that currently refer to iVars, called from other methods > of the same class. I need similar functionality in other classes, not > related by inheritance, and want to keep it DRY. > > If I move the iVar references into explicit method args they can be easily > re-located and shared. > > Is it then good or bad practice to take a such collection of related > state-independent methods (they don't depend on any iVar) and put them on > the class-side of some suitable class? > > My options and concerns: > - I could move them up the hierarchy on the instance side but sometimes hit > single inheritance limits > - I could use traits for these but am unclear about the future of traits in > Squeak > - I can put on the class side and call easily from instance-side methods, > but is this OK practice? > > Thanks, > > Sophie > > > > _______________________________________________ > Beginners mailing list > Beginners@xxxxxxxxxxxxxxxxxxxxxxxxxx > http://lists.squeakfoundation.org/mailman/listinfo/beginners >
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Design best practice : put state-independent methods onclass side?, itsme213 |
|---|---|
| Next by Date: | RE: Design best practice : put state-independent methods onclass side?, Ramon Leon |
| Previous by Thread: | Re: Design best practice : put state-independent methods onclass side?, itsme213 |
| Next by Thread: | RE: Design best practice : put state-independent methods onclass side?, Ramon Leon |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |