Re: Newbie Key Value-coding and Subclasses Question
Re: Newbie Key Value-coding and Subclasses Question
- Subject: Re: Newbie Key Value-coding and Subclasses Question
- From: Chuck Hill <email@hidden>
- Date: Thu, 9 Feb 2006 10:34:29 -0800
Hi,
On Feb 9, 2006, at 9:59 AM, Arturo Perez wrote:
David Avendasora wrote:
I have a reputation as being a bit ummm *strict* in my
interpretation of what the proper O-O way is of doing things. It
has served me well with code and less so with ppl :-)
LOL
On question 1, I am currently testing for what type of Class it is
by reading my PartType field using:
if (((String) valueForKeyPath("part.partType.partTypeName")).equals
("Finished Part")) {...}
and this works just fine, but my understanding was that instanceof
is a better OO way of doing things - especially since the string
partTypeName is a value from a DB field which could potentially
change.
The problem isn't so much with doing the above or using
instanceof. The problem is that once your code becomes aware of
object-types then you're on a slow sure path to perdition. You
might want to take a look at the book HeadsFirst Design Patterns
(the typical GoF reference is too heavyweight for most developers)
for reasons to avoid instanceof et al.
Just another voice from the wilderness here echoing that you want to
think long and hard before using instanceof or anything similar. It
does creep into my code from time to time, but only (well, usually)
as an expedient hack around a prior design flaw.
Chuck
--
Coming in 2006 - an introduction to web applications using WebObjects
and Xcode http://www.global-village.net/wointro
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems. http://www.global-village.net/products/practical_webobjects
_______________________________________________
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