• 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: Nested Editing Contexts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Nested Editing Contexts


  • Subject: Re: Nested Editing Contexts
  • From: Steven Mark McCraw <email@hidden>
  • Date: Wed, 30 May 2007 18:40:58 -0400

Cough.  Cough.


http://developer.apple.com/documentation/WebObjects/ Enterprise_Objects/EnterpriseObjects/chapter_3_section_13.html#// apple_ref/doc/uid/TP30001011-DontLinkChapterID_8-TPXREF146


And I quote, "Note that immediately after the enterprise object is created, it is inserted into an editing context. As a cardinal rule, all enterprise objects reside in an editing context. This is necessary in order for enterprise objects to send and receive the notifications necessary for change tracking and other mechanisms within Enterprise Objects. So, for every enterprise object you create, you must immediately insert it into an editing context."


http://developer.apple.com/documentation/WebObjects/ Enterprise_Objects/BusinessLogic/chapter_4_section_3.html#// apple_ref/doc/uid/TP30001011-DontLinkChapterID_3-TPXREF140


"You may wonder why it’s not recommended to initialize an enterprise object’s values in an object’s constructor. An enterprise object’s constructor represents the earliest state in the life of a particular object. The state of an enterprise object at the point of construction is not complete; the object is not fully initialized. It may not yet have been inserted into an editing context and it might not even have been assigned a global ID. You don’t ever want to manipulate an enterprise object that isn’t in an editing context or that doesn’t have a global ID."

I've seen that document as well, but I noticed the date on it was the latter half of 2005. I read all of the documentation Apple had regarding WebObjects back in 2000, and I even managed to get my hands on the training manuals for the courses they used to offer on WebObjects, and I don't ever recall seeing anything like that in any of the material. Of course, that is not to say it wasn't there. I wasn't specifically looking for it, so it's easy for me to imagine myself zipping over those short paragraphs without them making a big enough impression for me to remember. It is entirely possible that something like this was available from Apple very early on and I missed it.


Even so, the language in even the recent document is pretty weak: "it's not recommended to initialize an enterprise object's values in an object's constructor" implies some violation of best practices or perhaps style, but certainly not "if you do this your application will at some point break in frustrating ways that you cannot even imagine". But now I'm truly nitpicking about language, and I'm supposed to be a programmer, not an attorney. I'll quit publicly bitching at Apple on the list now. It's totally pointless anyway (except for that warm, happy feeling it gives me) ;)

I have often wondered that. Now you have gone and provoked me. I will file a bug report. You _can_ do this yourself by adding this to your base EO class:

public void willRead() {
if (editingContext() == null) {
throw new IllegalStateException("Access of instance of " + entityName() + " that has not been inserted into an EOEditingContext or whose EOEditingContext has been disposed");
}
super.willRead();
}

That's good thinking. Also, I'll be interested to see what they say about it when you file that report.




I think either one of those things would have saved lots of grief over the years for developers. I know it would have for me. At any rate, it's just my opinion, and it's so irrelevant anyway that I almost deleted this email without sending it to the list, but my fragile ego prevailed. I promise this will be the last one :)

Not if you reply to this one! Grin.

Ugh. You win this time ;)

_______________________________________________
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: Nested Editing Contexts
      • From: Mike Schrag <email@hidden>
References: 
 >Nested Editing Contexts (From: "Ted Archibald" <email@hidden>)
 >Re: Nested Editing Contexts (From: Steven Mark McCraw <email@hidden>)
 >Re: Nested Editing Contexts (From: Mike Schrag <email@hidden>)
 >Re: Nested Editing Contexts (From: Steven Mark McCraw <email@hidden>)
 >Re: Nested Editing Contexts (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: Nested Editing Contexts
  • Next by Date: Re: Nested Editing Contexts
  • Previous by thread: Re: Nested Editing Contexts
  • Next by thread: Re: Nested Editing Contexts
  • Index(es):
    • Date
    • Thread