A few thoughts on Hal's question....

hasSpouse is much more descriptive semantically -- makes for more readable code.

hasSpouse is simpler to document (especially given CFC auto-documentation) than isNull, where I have to then go about documenting various properties.

isNull seems a step closer to requiring the developer to know more about the implementation of your component rather than just the interface. hasSpouse is a single "layer" to learn for the developer, whereas isNull requires learning both that method and the possible attributes that are appropriate to ask for. This both risks breaking clean encapsulation [and makes implementation harder to change] and requires a higher learning curve for developers.

isNull("spuse") [notice the misspelling] is going to either not throw a useful error or will take more work to have it throw a useful error. Whereas hasSpuse() [same spelling error] will throw a meaningful error without needing to do any extra work. This makes debugging much easier for the end-developer who has to use the component.



Hal Helms wrote:
Why not just have an isNull(propertyName) method rather than litter classes
with hasSpouse, hasX, has Y?
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of David Ross
Sent: Tuesday, October 25, 2005 11:36 AM
To: [email protected]
Subject: RE: [CFCDev] CFC return types

the cool thing is that by having a hasSpouse() and a getSpouse() that throws
NotMarried, you leave the choice up the client (thus it's a good practice to
put "Throws: NotMarriedException when there is no spouse"
into the getSpouse()'s hint).

-Dave


[EMAIL PROTECTED] 10/25/2005 9:56:13 AM >>>

I think that's Barney's point. If you're going to call getSpouse(),

you
should already know that the person has a spouse. You shouldn't call
getSpouse() and then check the result to see if a the person had a spouse.
Nor should you call getSpouse() and look for an exception to let you know
that person didn't have a spouse.

Patrick's was one of the best explanations I have seen so far.

M!ke


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]


-----------------------------------------
CONFIDENTIALITY NOTICE: This email and any attachments may contain
confidential information that is protected by law and is for the sole use of
the individuals or entities to which it is addressed. If you are not the
intended recipient, please notify the sender by replying to this email and
destroying all copies of the communication and attachments. Further use,
disclosure, copying, distribution of, or reliance upon the contents of this
email and attachments is strictly prohibited. To contact Albany Medical
Center, or for a copy of our privacy practices, please visit us on the
Internet at www.amc.edu.



----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm

An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]





----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to 
[email protected] with the words 'unsubscribe cfcdev' as the subject of the 
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]






----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to 
[email protected] with the words 'unsubscribe cfcdev' as the subject of the 
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]


Reply via email to