[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: CreateBegin with no createEnd in swarm examples
From: |
Alex Lancaster |
Subject: |
Re: CreateBegin with no createEnd in swarm examples |
Date: |
03 Aug 1999 16:46:35 -0600 |
User-agent: |
Gnus/5.070095 (Pterodactyl Gnus v0.95) Emacs/20.4 |
>>>>> "PJ" == Paul Johnson <address@hidden> writes:
[...]
PJ> Hey, this reminded me. In all swarmapps, there is createBegin
PJ> without a create end for the obj. Look in Heatbugs, for example.
PJ> Its createBegin has this statement:
PJ> obj = [super createBegin: aZone];
PJ> but there is never obj = [obj createEnd];
PJ> What's up with that? Is obj getting its createEnd indirectly
PJ> through the modelSwarm's createEnd?
PJ> This has been a curiosity to me for a long time and I'm eager to
PJ> know the answer.
If you had an an MyObject class, something like:
+ createBegin: aZone
{
SomeObject *obj = [super createBegin: aZone];
obj->someVal = 1;
[...]
return [obj createEnd];
}
- setSomething: something
{
[...]
}
- createEnd
{
[super createEnd];
return self;
}
And when you created the object, you did the following:
anObject = [MyObject createBegin: [self getZone]];
[anObject setSomething: something];
anObject = [anObject createEnd];
then `createEnd' would get called *twice*, once internally in the
factory method, and the second time by the -createEnd method.
However, if you have a *convenience* method, method (where createBegin
and createEnd are called in the same factory method), then it's
appropriate to have the +createBegin: and -createEnd in the same
method i.e.:
+ create: aZone setSomething: something
{
SomeObject *obj = [super createBegin: aZone];
[obj setSomething: something];
return ([obj createEnd]);
}
--- Alex
--
Alex Lancaster | e-mail: address@hidden
Swarm Program | web: http://www.santafe.edu/~alex
Santa Fe Institute | tel: +1-(505) 984-8800 (ext 242)
-------------------------------------------------------------------
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.