• 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: deprecated API
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: deprecated API


  • Subject: Re: deprecated API
  • From: Chuck Hill <email@hidden>
  • Date: Thu, 9 Feb 2006 14:54:58 -0800


On Feb 9, 2006, at 2:39 PM, Art Isbell wrote:

On Feb 9, 2006, at 12:22 PM, Chuck Hill wrote:

On Feb 9, 2006, at 2:16 PM, Art Isbell wrote:

If this is good:

MyNewPage nextPage = (MyNewPage)pageWithName (MyNewPage.class.getName());

then why not this?

MyEO eo = (MyEO) EOUtilities.createAndInsertInstance(ec, MyEO.class.getName());

Good question, and one that I should add to the best practice. The second parameter is the entity name from the model, not the class name.

Correct! However, eliminating string literals from code reduces errors from some typos that won't be caught until run-time.

Sniff. That smells like another best practice. :-)


So using eogenerator to define the class constant (i.e., public static final String) ENTITY_NAME in each EO class would minimize such errors with some typos being caught at compile time:

MyEO eo = (MyEO) EOUtilities.createAndInsertInstance(ec, MyEO.ENTITY_NAME);

	But some typos would still sneak through until run-time:

MyEO eo = (MyEO) EOUtilities.createAndInsertInstance(ec, YourEO.ENTITY_NAME);


Quite true. I omitted this as it does not work in the (admittedly rare) case where one class implements multiple entities. EOGenerator assumes one entity == one class (IIRC). So, MyEO.ENTITY_NAME will return the name of the last entity to get generated. With that one exception, I would prefer to use static string constants for the reasons you give.


Chuck

--
Coming in 2006 - an introduction to web applications using WebObjects and Xcode http://www.global-village.net/wointro


Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems. http://www.global-village.net/products/practical_webobjects




_______________________________________________ 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: 
 >deprecated API (From: zac <email@hidden>)
 >Re: deprecated API (From: Chuck Hill <email@hidden>)
 >Re: deprecated API (From: zac <email@hidden>)
 >Re: deprecated API (From: Chuck Hill <email@hidden>)
 >Re: deprecated API (From: Mike Schrag <email@hidden>)
 >Re: deprecated API (From: Chuck Hill <email@hidden>)
 >Re: deprecated API (From: Arturo Perez <email@hidden>)
 >Re: deprecated API (From: Chuck Hill <email@hidden>)
 >Re: deprecated API (From: Art Isbell <email@hidden>)
 >Re: deprecated API (From: Chuck Hill <email@hidden>)
 >Re: deprecated API (From: Art Isbell <email@hidden>)

  • Prev by Date: Re: Filemaker und WebObjects?
  • Next by Date: Some help with Optimization
  • Previous by thread: Re: deprecated API
  • Next by thread: Re: deprecated API
  • Index(es):
    • Date
    • Thread