There's no difference in Java that I know of, nor CFCs. I do it for two reasons: 1) to make my memento machinery easier. No sense in putting the validation errors information in the memento (since it can be computed from the other info), and it's quite possible that a different subclass will generate different errors from the same instance data. By separating them, my memento is the same as my variables.my struct, because all the non-memento stuff is just in the variables scope.
2) The instance data is important to subclasses, but the computed data probably isn't (since it's implementation-specific). In other words, variables.my is like Java's protected scope, while variables is like Java's private scope. There is no enforecement of that fact, but it's a useful crutch for double-checking encapsulation. If you ever reference a variable in the parent's variable scope, you need to think about what you're doing. Not that it's wrong, just that you need to make sure. Personal preference to be sure, but thus far it's served me well. Cheers, barneyb > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Brian Kotek > Sent: Tuesday, March 16, 2004 11:01 AM > To: [EMAIL PROTECTED] > Subject: RE: [CFCDev] RFC, CFC Best Practices > > I posted this to the Mach-II list but there seems to be a bit more > activity here so I'm cross-posting it: > > In Java or other OO languages, is there a difference like this between > "instance" data and "computed" data that is local to the object? I > don't think there is but I could be wrong and wanted to ask. But if > there is no difference, is there a compelling reason to > introduce such a > difference in CFCs? > > > -----Original Message----- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On Behalf Of Barney Boisvert > > Sent: Tuesday, March 16, 2004 12:31 PM > > To: [EMAIL PROTECTED] > > Subject: RE: [CFCDev] RFC, CFC Best Practices > > > > > > I've found that using a struct in the variables scope for > > instance data (I use 'my') is helpful to separate actual > > instance data from computed data. Take a User business object > > for example. It'll have instance data such as 'name', > > 'username', 'password'. But it'll also very likely have a > > validate() method which will check the values of those > > fields, and store error flags somewhere for later recall by > > getValidationErrors() or the like. > > > > Thus I'll have these fields: > > > > Variables.my.name > > Variables.my.username > > Variables.my.password > > Variables.validationErrors > > > > Making the distinction allows to memento machinery to work > > better, and also > > allows generic get/set methods to be "safe". > > > > > -----Original Message----- > > > From: [EMAIL PROTECTED] > > > [mailto:[EMAIL PROTECTED] On Behalf Of Nathan Dintenfass > > > Sent: Monday, March 15, 2004 8:38 PM > > > To: [EMAIL PROTECTED] > > > Subject: [CFCDev] RFC, CFC Best Practices > > > > > > I've noticed that many of the best practices talked about on > > > this list are > > > not as widely known as I would have thought. What's worse, > > > most of the > > > basic best practices related to CFCs are not well > documented or are > > > documented in disparate places. > > > > > > I'm trying to capture a concise list of CFC best practices > > > that everyone > > > coding CFCs should be aware of (if not follow). > > > > > > Perhaps some of y'all have comments/additions/criticisms, > > > which I'd welcome: > > > > > > http://www.dintenfass.com/cfcbestpractices/ > > > > > > ---------------------------------------------------------- > > > You are subscribed to cfcdev. To unsubscribe, send an email to > > > [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the > > > message of the email. > > > > > > CFCDev is run by CFCZone (www.cfczone.org) and supported > > > by Mindtool, Corporation (www.mindtool.com). > > > > > > 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' > > in the message of the email. > > > > CFCDev is run by CFCZone (www.cfczone.org) and supported > > by Mindtool, Corporation (www.mindtool.com). > > > > 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' > in the message of the email. > > CFCDev is run by CFCZone (www.cfczone.org) and supported > by Mindtool, Corporation (www.mindtool.com). > > 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' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
