Grouping functions as component

12 views
Skip to first unread message

manaus

unread,
May 23, 2013, 5:22:48 AM5/23/13
to ra...@googlegroups.com
Hello, 
I read someone sometimes uses to group functions semantically in a component.
You instantiate it and use its functions. But well looks to me that it is not the proper use of a component.
You should instantiate it passing a value, so the new value inherits all the functions of the component.
Am I right?
I now have a component with 20 query functions, and is starting to make me feel dizzy.
Thanks!

James Kilford

unread,
May 24, 2013, 5:53:53 AM5/24/13
to ra...@googlegroups.com
Hi Max, 

The idea of components with similar functions makes sense -- you can make libraries of functions that are often used together, for example maths functions, or database operations, etc.  It seems like a perfectly good way to use components.

I didn't understand this bit: "You should instantiate it passing a value"... Can you give an example? 

James



--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
 
 
If you don't have time, add a request to the Railo Server wiki to-do page at https://github.com/getrailo/railo/wiki/Todo
---
You received this message because you are subscribed to the Google Groups "Railo" group.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

manaus

unread,
May 24, 2013, 10:24:24 AM5/24/13
to ra...@googlegroups.com
Thanks James,
well what I mean is that, for instance

m = new cfc.EmailClass("myad...@domain.etc");
m.sendHello();
m.deleteFromDb();

And so on
In my case I'm having a component such as

d = new cfc.Queries();
d.findAllLivingInChina();
d.findCityId("Berlin");

d, in this case, has no value. So why using it? :)
Sorry sounds like pre-primer questions :)

James Kilford

unread,
May 24, 2013, 10:43:36 AM5/24/13
to ra...@googlegroups.com
Ah, I see what you mean.  Yes, you're quite right.  It does seem like a waste, but CFML doesn't support static classes.  In other languages you can do exactly what you are saying... but in CF you have to instantiate the class. 

James
Reply all
Reply to author
Forward
0 new messages