Re: OT : Coding Standards (was New WebObjects 15 Minute Tutorial in Quicktime)
Re: OT : Coding Standards (was New WebObjects 15 Minute Tutorial in Quicktime)
- Subject: Re: OT : Coding Standards (was New WebObjects 15 Minute Tutorial in Quicktime)
- From: "Jonathan 'Wolf' Rentzsch" <email@hidden>
- Date: Sun, 28 Mar 2004 22:50:59 -0600
Greetings Owen,
>> Owen McKerrow, email@hidden, wrote:
>>> I just watched the Jonathan's 15 min Intro to WebObjects ( Great work
>>> John, keep it up ). However I did notice that he does things a little
>>> differently to how I've seen WO taught before. These being :
>>> 1) He didn't make a java class of his Entity, he just imported the
>>> EOModel
>>
>> Yes, generating Java code is wonderfully optional in WebObjects/EOF. In
>> my experience, Java code generation buys you two things:
>>
>> 1. A place to put your EO's logic.
>>
>> If all you're doing in your logic is populating default values in your
>> EO's attributes, there are alternative places you can extend
>> D2W+WOF+EOF
>> to make this non-entity-specific. I find most of my custom EO "logic"
>> is
>> setting these default values, so replacing a bunch of entity-specific
>> Java code with a framework extension can often completely mitigate the
>> need for code generation altogether
>
>Unless Im miss-understanding you, I normally do that sort of thing in
>awakeFromInsertion() inside the Java class for the Entity. But its all
>pretty class specific, How do you get a generic framework to do it ?
Either in the EOF layer (probably via a delegate, I think Wonder has
something which does this) or if you're targeting DirectToWeb, by
subclassing D2W. Here's some slightly outdated code,
DefaultPropertyValueD2W, which populates new EOs based on the app's rules:
<http://www.omnigroup.com/mailman/archive/webobjects-dev/2002-April/022720.
html>
The EOF implementation is more generally applicable, but you'd have to
violate framework layering if you want to populate values from say, your
WOSession, which is a common desire. My DefaultPropertyValueD2W solves
that, but requires D2W. There's probably a happy middle at the WOF layer
that I haven't looked for yet.
>Arturo also mention Gap generation. What is it ?
<http://www.research.ibm.com/designpatterns/pubs/gg.html>
Wow, that's long-winded. It boils down to that fact of instead of
generating one source file that both you and EOGenerator fight over
(EOGenerator always wanting to make the .java reflect the eomodel, while
you're stuffing custom logic in there), there's two files. "_MyEO.java",
which EOGenerator is free to overwrite at any time (and does!), and
"MyEO.java", which subclasses _MyEO, which is forever untouched by
EOGenerator.
| Jonathan 'Wolf' Rentzsch http://rentzsch.com
| Red Shed Software http://redshed.net
| "better" necessarily means "different"
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.