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. 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);

Aloha,
Art

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to