• 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: Best Way® to test for existence of a relationsh ip
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best Way® to test for existence of a relationsh ip


  • Subject: Re: Best Way® to test for existence of a relationsh ip
  • From: Bob Stuart <email@hidden>
  • Date: Mon, 7 Apr 2008 09:34:59 -0400

Try catch seems expensive to me. Why not just check with
if  (aPart instanceof ManufacturedPart){
	do something with aPart.billsOfMaterial()
}

At 9:12 AM -0400 4/7/08, David Avendasora wrote:
Hi all,

This is more of a Java question than a WO-specific one

I have an Inheritance structure in my app:

Part (abstract Superclass)
RawMaterial (subclass of Part)
ManufacturedPart (subclass of Part)

I have an NSArray of Parts that could be, RawMaterial instances, ManufacturedPart instances, or most likely, a mixture of the two.

I want to iterate through the Array and get the contents of the Part.billsOfMaterial() (toMany) relationship. The problem is that while ManufacturedParts have this relationship, RawMaterials do not.

Right now, I'm using a try-catch block that catches the exception on RawMaterial.billsOfMaterial() and just ignores it.

I could also add a billsOfMaterial() method to the RawMaterial class that simply returns NSArray.emptyArray.

Is one way better than the other for any reason?

Thanks,

Dave
_______________________________________________
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


--
Bob Stuart
_______________________________________________
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


  • Follow-Ups:
    • Re: Best Way® to test for existence of a relationsh ip
      • From: Chuck Hill <email@hidden>
References: 
 >Best Way® to test for existence of a relationship (From: David Avendasora <email@hidden>)

  • Prev by Date: Best Way® to test for existence of a relationship
  • Next by Date: Re: Swapping a session on a direct action
  • Previous by thread: Best Way® to test for existence of a relationship
  • Next by thread: Re: Best Way® to test for existence of a relationsh ip
  • Index(es):
    • Date
    • Thread