MadushM
MadushM

Reputation: 397

Better managing Coldfusion Component (CFC) functions

I heavily rely on CFC. Sometimes within an application, I would have multiple CFC containing dozens of functions per CFC. So over time, it's easy to forget or miss out on already created functions.

So my question is how do you guys manage all these functions? Do you keep a separate document listing all the functions and indexing them that way? Is there an automated feature built in that we can use?

What I've been doing is naming functions more meaningfully but it's very tedious. There has to be a better way to do this. Just looking for your thoughts.

Thank you in advance.

Upvotes: 3

Views: 151

Answers (2)

Arun Pati
Arun Pati

Reputation: 125

-You should follow the proper naming conventions for each and every cfcs.

-Each cfcs should be meant for a particular purpose. i.e. login cfcs should should only contain the login related functions.

-All common functions should be kept together in a cfc and that can be extended by the other cfcs.

-You can use a generic cfc for random functions.

Now, if you want to add a new function for any functionality then you can scan only 3 cfcs i.e. dedicated to that functionality, common and random. And you add the new as per the best fit.

Upvotes: 1

Mark A Kruger
Mark A Kruger

Reputation: 7193

I don't think there's a magic bullet here. Programmers with a bit more OCD than I will likely respond and give you an iron clad solution. For me (or my team) I keep a library of common components in a folder that I reuse for various sites and applications. Then I add them as a /util or /lib folder for a given project and use them (or extend them) as needed. Good planning - good documentation (a Wiki is a great choice for a team) is a must.

Planning carefully whether to extend a CFC is especially important. Otherwise you have to chase down nested function that are part of some super class way down in the weeds (as in, this works, but I really have no idea why it works).

This is where frameworks can provide much needed structure. For common functions and events they generally provide a location and a convention for creating such things. That makes them easy to decipher (as long as you've been indoctrinated into the framework). They have some downsides but they make life a lot easier :)

Upvotes: 7

Related Questions