No worries.  Here's another attempt at explaining.  I did some teaching in
my college years, and it's always the best way to get really familiar with a
concept, because what might seem obvious to you when explained one way,
might be completely muddy to someone else, so you have to figure out a
different way to say the same thing, and that takes a good understanding.
Makes you think, and I like to think.

The init method gets an actual Address object, which it sets to it's
'address' instance variable (via the setAddress method).  The setMemento
gets a memento, which has a field containing the memento of the address
object (take a look at getMemento), which it passes to the setMemento method
of the address instance variable, which resets that instance to whatever
state was provided in the memento.  Here's what the methods are doing, in
English (the code is below them):

Init creates an Address object

getMemento makes a struct that has a field named 'address', which contains
the address object's memento (accessed using
variables.instance.address.getMemento()).  That field does NOT contain an
Address object, just a mememnto

setMemento accepts a struct named 'm' that has a field named 'address',
which contains an address objects' memento (see how getMemento works,
above).  That memento is passed to the address object's setMemento method
(variables.instance.address.setMemento(m.address))

Code:
Void init(Address address) {
  variables.instance.address = address;  // Address object
  // this is the ONLY Address object ever used by whatever
  // object this method is in.  The state of the Address
  // object will be swapped out as necessary (via memento)
  // but it will always be the same object.
}

Struct getMemento() {
  result = structNew();
  // this field is an address memento
  result.address = variables.instance.address.getMemento();
  return result;
}

Void setMemento(struct m) {
  // m.address is an address memento (see getMemento),
  // while variables.instance.address is an Address object
  // which was created in the init() method.
  variables.instance.address.setMemento(m.address);
}

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Justin Balog
> Sent: Wednesday, December 10, 2003 3:52 PM
> To: '[EMAIL PROTECTED]'
> Subject: RE: [CFCDev] memento and composition
> 
> Sorry Barney, for being completely thick skulled, but 'a' in 
> the init() is
> passed in.  When I am going to call the setInstanceMemento() 
> of the person,
> I won't be passing in an 'a' to the init() so there won't be an 'a'
> available to whose setInstanceMemento(m.address) I can call. 
> I think I am
> missing something here.  Thanks again.
> 
> Justin

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to