Marc
> David, I'd like to ask a few questions about your statement. When I took
> Programming WebObjects II, it was recommended to *always* use custom EOs
> which makes sense to me once I realized the power of EOF. I'm surprised to
> hear you say that you use EOGenericRecords. Are you saying that if you don't
> have any custom code, that you just use generic records? I guess I can
I'm saying that not every entity in your Model will have custom behavior
beyond the rules in your model. if you don't need to add code for
derived attributes, boolean rules, validation methods, new object
defaults, or state change methods... then just use EOGenericRecords. It
will be easier to maintain (and a bit faster) and you don't worry about
having to deal with null values mapped to things like ints. Having a
custom class that doesn't actually DO anything doesn't add much value.
HOWEVER, for people starting with EOF I would push them to use custom
classes whenever possible because it gets people thinking about true
Business Logic the EOF way... the rules that the CEO cares about
factored out from everything else. Even experienced developers that have
heard 'business logic' a million times and think they know what it is
don't. It's hard to explain it until you think about your business. It's
also hard for people to get in the habit of just 'letting the object
figure it out'. If new folks have these classes lying around they will
be more encouraged to use them.
> understand not having accessor methods. As you say, you just use
> valueForKey().
>
> I'm not completely clear what is meant by "business logic." Do you mean
> custom methods such as adding a method like totalCost that takes two fields
> and returns a total? Do you include the relationship methods as well or is
> that also part of business logic?
Methods like this on a hypotheical Employee class:
fullName() // dervied attribute for convenience, no real rules
isEligible() // dervied attribute based on state and rules
canShow(User) // security rule based on state AND argument
canEdit(User) // ditto
age() // computation based on state AND implicit argument (todays date)
isCovered() // derived attribute based on state and rules
enrollInPlan() // state change method requiring special rules
hasUnderAgeDependents() // complex dervied attribute based on
// state AND related state (contents of a to-many array)
validateCompany() // validation rule
awakeFromInsertion() // default values for a new object
validateForSave() // validation on combination of all state
s