Re: OO style - dynamic set & get methods

2007-06-14 Thread Andrew Scott
Coldspring only searches to see if the setters exist, not create them.

That's how DI works on any programming language.


On 6/15/07, Jonathon Stierman <[EMAIL PROTECTED]> wrote:
>
> Why code by hand when computers can do it for you? :)
>
> http://rooibos.maestropublishing.com/
>
> It seems to be standard to be using the full method sets.  I believe
> ColdSpring searches your CFCs for getters and setters. So if you wanted to
> use ColdSpring (and probably some other frameworks), you should either
> have
> those getters/setters or have the attributes able to be passed in the
> constructor.
>
> Jonathon
>
>
> -Original Message-
> From: Rob O'Brien [mailto:[EMAIL PROTECTED]
> Sent: Thursday, June 14, 2007 1:51 PM
> To: CF-Talk
> Subject: OO style - dynamic set & get methods
>
> So, I'm just starting to go into OO-style CF development and I have a
> quick
> theory question... Mind you, this is brand new to me, so be gentle.
>
> When setting up my Location Bean, I started to go through each of the
> individual variables and created a get() and set() method for each of
> them.
> I got about halfway through and decided that I was tired of creating
> repetitive functions. I thought to myself, why can't I just create simple,
> dynamic get() and set() functions to handle all of these variables
> dynamically?
>
> Rather than setName(value), why not setVar("Name",value)?
>
> Since these methods are inherently dumb (nothing but a cfset and a
> cfreturn
> as I've seen implemented), why does it matter that I have an individual
> method for each? Validation would come in an additional business layer
> anyway.
>
> I guess I'm looking for pros/cons. This seems like a more dynamic, elegant
> way to set/get, but I'd like to know where the pitfalls are.
>
> Thanks!
> Rob
>
>
>
>
> 

~|
Upgrade to Adobe ColdFusion MX7
The most significant release in over 10 years. Upgrade & see new features.
http://www.adobe.com/products/coldfusion?sdid=RVJR

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:281203
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: OO style - dynamic set & get methods

2007-06-14 Thread Dinner
On 6/14/07, Nathan Strutz wrote:

> Of course there arguments the other way. For instance a config object with
> an unknown or ever-changing number of params it reads from a database or xml
> file would not be as helpful to you if you had to constantly add and remove
> getters and setters every time you needed to add and remove parameters from
> your evolving application. For this case alone I think I would use the
> universal set()/get() methods, or maybe just a plain old struct ;)

"An unknown or ever-changing number of params" Sounds like development. =]

It's all a mix anyways.  Be clear and use patterns and whatnot, and what
difference does it really make?  Drop down a level, pop up a level... consistent
doesn't mean everything is the same--  Well, sorta it does, but I like the def
that means "coherent" (ironic, neh? ;).

It's all "processed" anyways, I don't see what one process offers that you
couldn't implement in another process.  Want to validate the input?  You
have to do that if you use setValue(someThing,else) or setSomeThing(else),
either way.

At least the case maches with setValue(someThing, else), neh?

Yeah, FWIW, I'm liking the setValue() a whole lot more than setName(), etc..

But I do use both.  Bad myself, bad!  Eh.
That's life, especially when you don't Control Everything (or in my
case, just cuz).

I know, this is one of those religious types arguments, been 'round, be 'round,
etc..  Please take these comments in that context.  I'm spiritual, not
religious. ;)

Guess I could be coding for someone who can't read source, right?  Yeah...
but how far do you go?  I've gone far enough, here.

(Opinions Subject to change, of course & BTW =])

~|
ColdFusion MX7 and Flex 2 
Build sales & marketing dashboard RIA’s for your business. Upgrade now
http://www.adobe.com/products/coldfusion/flex2?sdid=RVJT

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:281198
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: OO style - dynamic set & get methods

2007-06-14 Thread Dinner
On 6/14/07, Jonathon Stierman wrote:
> Why code by hand when computers can do it for you? :)

Indeed!  I know /my/ fingers get pretty tired...

all those ones and zeros...

~|
ColdFusion MX7 and Flex 2 
Build sales & marketing dashboard RIA’s for your business. Upgrade now
http://www.adobe.com/products/coldfusion/flex2?sdid=RVJT

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:281196
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: OO style - dynamic set & get methods

2007-06-14 Thread Nathan Strutz
Rob,

This is a great question, and one to ponder for a while, no doubt.

Programmatically, there's nothing wrong with this approach. It works just
how you want it to.

Now let's think about what that's doing. Your CFC is just acting like a
collection in this case. This is basically how a map object works, a basic
collection in Java. put(), get(), size(), etc. If you're going to do that,
why not just use a collection object. There's a great one you can leech from
Model-Glue's CFCs, or you can literally use a java collection object (they
have a wide selection). However, think a little deeper - this is just a
coldfusion Struct. struct.key = value, #struct.key#, structCount(), etc. Why
don't you just have a public struct on your CFC? Well because that breaks
encapsulation.

Aha, encapsulation. If your CFC has a get() and set() function, and you
, you (or another developer, and hopefully
not the end user), can put any kind of odd value in your CFC's local
storage. Even if you limit it to strings only, you can still be surprised by
an odd string (abc123xyz=nathan, who knows?). Explicit getters and setters
keep the peace here.

The only other thing I can think of is keeping with your convention. If you
have some objects with, say, exactly 3 fields always, or objects that do
something when you get or set a value, you'll want to use a getter/setter
like getName() or something. If your application is 50% getters & setters
and 50% get(key), set(key,value), you've lost your standard convention, and
you have to introspect (or view the source on) every CFC to make sure you're
doing it right.

Of course there arguments the other way. For instance a config object with
an unknown or ever-changing number of params it reads from a database or xml
file would not be as helpful to you if you had to constantly add and remove
getters and setters every time you needed to add and remove parameters from
your evolving application. For this case alone I think I would use the
universal set()/get() methods, or maybe just a plain old struct ;)


-- 
nathan strutz
http://www.dopefly.com/


On 6/14/07, Rob O'Brien <[EMAIL PROTECTED]> wrote:
>
> So, I'm just starting to go into OO-style CF development and I have a
> quick
> theory question... Mind you, this is brand new to me, so be gentle.
>
> When setting up my Location Bean, I started to go through each of the
> individual variables and created a get() and set() method for each of
> them.
> I got about halfway through and decided that I was tired of creating
> repetitive functions. I thought to myself, why can't I just create simple,
> dynamic get() and set() functions to handle all of these variables
> dynamically?
>
> Rather than setName(value), why not setVar("Name",value)?
>
> Since these methods are inherently dumb (nothing but a cfset and a
> cfreturn
> as I've seen implemented), why does it matter that I have an individual
> method for each? Validation would come in an additional business layer
> anyway.
>
> I guess I'm looking for pros/cons. This seems like a more dynamic, elegant
> way to set/get, but I'd like to know where the pitfalls are.
>
> Thanks!
> Rob
>
>
> 

~|
Create Web Applications With ColdFusion MX7 & Flex 2. 
Build powerful, scalable RIAs. Free Trial
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJS 

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:281181
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


RE: OO style - dynamic set & get methods

2007-06-14 Thread Jonathon Stierman
Why code by hand when computers can do it for you? :)

http://rooibos.maestropublishing.com/

It seems to be standard to be using the full method sets.  I believe
ColdSpring searches your CFCs for getters and setters. So if you wanted to
use ColdSpring (and probably some other frameworks), you should either have
those getters/setters or have the attributes able to be passed in the
constructor.

Jonathon


-Original Message-
From: Rob O'Brien [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 14, 2007 1:51 PM
To: CF-Talk
Subject: OO style - dynamic set & get methods

So, I'm just starting to go into OO-style CF development and I have a quick
theory question... Mind you, this is brand new to me, so be gentle.

When setting up my Location Bean, I started to go through each of the
individual variables and created a get() and set() method for each of them.
I got about halfway through and decided that I was tired of creating
repetitive functions. I thought to myself, why can't I just create simple,
dynamic get() and set() functions to handle all of these variables
dynamically?

Rather than setName(value), why not setVar("Name",value)?

Since these methods are inherently dumb (nothing but a cfset and a cfreturn
as I've seen implemented), why does it matter that I have an individual
method for each? Validation would come in an additional business layer
anyway. 

I guess I'm looking for pros/cons. This seems like a more dynamic, elegant
way to set/get, but I'd like to know where the pitfalls are.

Thanks! 
Rob




~|
Upgrade to Adobe ColdFusion MX7
The most significant release in over 10 years. Upgrade & see new features.
http://www.adobe.com/products/coldfusion?sdid=RVJR

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:281180
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4