Opinions on static create…() methods for EOs
Opinions on static create…() methods for EOs
- Subject: Opinions on static create…() methods for EOs
- From: Paul Hoadley <email@hidden>
- Date: Thu, 20 Feb 2014 15:06:01 +1030
Hello,
Say I have an entity Foo. Often I will override the static createFoo() method declared in _Foo.java, perhaps several times with different signatures for different uses. Say Foo has a to-one relationship to Bar, and I supply bar as an argument. I'm a bit inconsistent as to whether I call:
setBarRelationship(bar);
or:
setBarRelationship(bar.localInstanceIn(ec));
in the body of the method, where ec is obviously the EOEditingContext supplied as an argument. I would have thought that doing the latter was more convenient, because then the caller never has to worry about whether or not she needs to or remembers to localInstance the related object herself. But I note that the built-in templates _don't_ do this, so that _Foo.createFoo() would just call setBarRelationship(bar) if bar was an argument.
Are there any gotchas here? Is it safe to always call localInstanceIn() in these static create methods, or should it be left up to the caller?
--
Paul Hoadley
http://logicsquad.net/
_______________________________________________
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