What you could also do is define your own collection type - an
ArrayOfComments.cfc that only allows instances of Comment.cfc. Then you
return that from BlogPost.getComments(), and implement your various
addComment(), removeComment() functions there.

/t

>-----Original Message-----
>From: [EMAIL PROTECTED] 
>[mailto:[EMAIL PROTECTED] On Behalf Of Mark Mandel
>Sent: Wednesday, September 21, 2005 3:49 AM
>To: [email protected]
>Subject: [CFCDev] Best way to expose a Array of Objects inside a BO
>
>Hey all, 
>
>I'm just looking at composite BOs, which contain an array of other BOs
>inside them, and looking at some ways to expose the array of objects
>inside it.
>
>If we were talking about Comments on a BlogPost some things I was
>looking at where:
>
>BlogPost.getComment() where it returns the array by reference.  
>I'm not so keen on this one because it allows full access to the
>underlying array, and doesn't stop anyone from adding the wrong sort
>of object to the array
>
>BlogPost.getComment() where it returns a new array in which the
>Comment BO's are copied into it.
>I think this is slightly better than the above, as the array from
>within the BlogPost is still encapsulated, and you can write your
>BlogPost.addComment(...), BlogPost.removeComment(...) etc methods from
>here.
>
>Having functions along the lines of:
>BlogPost.addComment(...) : void
>BlogPost.removeComment(...) : void
>BlogPost.clearComments() : void 
>BlogPost.containsComment(...) : boolean
>BlogPost.getCommentIterator() : java.util.Iterator - which is used to
>give the ability to loop through the items in a Array.
>
>I prefer this approach, as you can finely decide which of these
>methods are appropriate for use on a BO, but obviously uses the
>underlying Vector of a CFArray to create the Iterator.
>
>I'm just wondering your thoughts on your preferred approach (I hate to
>say 'best'), and if you can see any issues with any of the above
>methods, particularly exposing an Iterator.
>
>Cheers,
>
>Mark
>-- 
>E: [EMAIL PROTECTED]
>W: www.compoundtheory.com
>ICQ: 3094740
>
>
>----------------------------------------------------------
>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