|
Re: Overriding methods: msg#00096lang.smalltalk.squeak.beginners
On Sun, 20 Jan 2008 07:54:47 -0800, Ron Teitelbaum <Ron@xxxxxxxxxxxx> wrote: Hi Blake, Sure, for singletons. Good example. Sometimes calling #new on class is a bad idea, either this class shouldn't have instances, or there are other instance creation methods that should be called instead. (We usually don't override new because of other instance Right. And while that's not necessarily ideal, I think it can be construed as part of the price of knowing how to use an object. (Though I like "contract-less" programming, do the degree it's possible.) FishTank class>>newForGallons: numberOfGallons Well, no, this is precisely the sort of situation I run into all the time. "Gee, mister, I'd love to create an instance for ya, but I need to know what kind of instance you want." Ok so in most cases you can set your object up in #initalize This also doens't solve your number of gallons issue. Which puts you in the position of changing that number of gallons after the instance is created. You could also extend your class hierarchy to support different tanks. Yes. This something that I'm getting used to. Thanks, Ron.
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Squeak for robot imaging and scientific applications, Ken G. Brown |
|---|---|
| Next by Date: | Loading windows bitmap?, Blake |
| Previous by Thread: | RE: Overriding methods, Ron Teitelbaum |
| Next by Thread: | Re: Overriding methods, Zulq Alam |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |