• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Of Inheritance and AwakeFromInsertion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Of Inheritance and AwakeFromInsertion


  • Subject: Re: Of Inheritance and AwakeFromInsertion
  • From: David LeBer <email@hidden>
  • Date: Wed, 19 Mar 2008 09:13:50 -0400


On 19-Mar-08, at 8:41 AM, David Avendasora wrote:


On Mar 19, 2008, at 8:33 AM, David LeBer wrote:

On 19-Mar-08, at 8:21 AM, David Avendasora wrote:

Hi all,

I've run into something that _seems_ to work, but just seems "wrong" and I don't see how to do it "right".

I have the following inheritance structure in my model:

LotCode (NOT abstract)
ManufacturedBatch extends LotCode.

When I call awakeFromInsertion on the superclass I do it as follows :

public void awakeFromInsertion(EOEditingContext ec) {
	super.awakeFromInsertion(ec);
	if (lotCodeType() == null) {
		setLotCodeType(1);
	}
}

But when I call awakeFromInsertion on the subclass I have to do this:

public void awakeFromInsertion(EOEditingContext ec) {
	super.awakeFromInsertion(ec);
	if (lotCodeType() == null || lotCodeType.equals(1)) {
		setLotCodeType(1);
	}
}

I've never used a concrete superclass but how about:

Superclass:

public void awakeFromInsertion(EOEditingContext ec) {
	super.awakeFromInsertion(ec);
	if (lotCodeType() == null) setLotCodeType(1);
}

Subclass:

public void awakeFromInsertion(EOEditingContext ec) {
	if (lotCodeType() == null) setLotCodeType(2);
	super.awakeFromInsertion(ec);
}

I thought about this, but since it is also an "EO-No-No" to do _anything_ before calling awakeFromInsertion I didn't want to do anything before inserting the super.

Hmm, you are right. How about this:

Superclass:

public void awakeFromInsertion(EOEditingContext ec) {
	awakeWithCodeType(ec, 1);
}

public void awakeWithCodeType(EOEditingContext ec, int codeType) {
	super.awakeFromInsertion(ec);
	setLotCodeType(codeType);
}

Subclass:

public void awakeFromInsertion(EOEditingContext ec) {
	awakeWithCodeType(ec, 2);
}


;david

--
David LeBer
Codeferous Software
'co-def-er-ous' adj. Literally 'code-bearing'
site:   http://codeferous.com
blog: http://davidleber.net
profile: http://www.linkedin.com/in/davidleber
--
Toronto Area Cocoa / WebObjects developers group:
http://tacow.org


_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Of Inheritance and AwakeFromInsertion (From: David Avendasora <email@hidden>)
 >Re: Of Inheritance and AwakeFromInsertion (From: David LeBer <email@hidden>)
 >Re: Of Inheritance and AwakeFromInsertion (From: David Avendasora <email@hidden>)

  • Prev by Date: Re: Of Inheritance and AwakeFromInsertion
  • Next by Date: Re: Of Inheritance and AwakeFromInsertion
  • Previous by thread: Re: Of Inheritance and AwakeFromInsertion
  • Next by thread: Re: Of Inheritance and AwakeFromInsertion
  • Index(es):
    • Date
    • Thread