I've been playing with Eclipse a lot lately to help me learn more about Java. Using Eclipse to write Java code is just a joy, and I wanted to point this out in the hope that maybe CFEclipse can eventually get us to this point with our CFML coding. It might not even be possible (or just extremely difficult) to do this in a language like CFML that is not compiled until runtime, but hey, a guy can dream.

I'm a big fan of a development approach called "Coding by Intention". The basic idea is that when you start coding something like a CFC, you should write the "high-level" methods first, but each line of the high-level method is actually a call to a lower-level method that hasn't even been created yet. So you might do something like:

<cffunction name="processForm" access="public" returntype="void" output="false" hint="I validate the form and insert the data into the database.">
   <cfargument name="data" type="struct" required="true" hint="The raw form data." />
   <cfset var validData = "" />
   <cfset validData = validateData( arguments.data ) />
   <cfset getDAO().save( validData ) />
</cffunction>

Where validateData() and getDAO() aren't even created yet. They'll be private methods. The idea is to write the "sergeant" method and pretend that whatever you need is already there. Once you know what you need it's fairly easy to go back and create each of the individual "private" methods.

My real point here isn't to harp on "Code by Intention" but to exalt how easy Eclipse makes this when writing Java. Imagine you're coding in Java and you write the line:

Person p = new Person("Brian");

You can then put the cursor over "new Person" and press Control-1, and a little pop up offers you the choice to "Create Class Person?". How nice, you think, and click it. Bam, a skeleton Person class is generated. Again hover over "new Person" and hit Control-1, and now it asks "Create Constructor Person(String)?" You click that and a constructor skeleton is created that matches the arguments that you declared.

You can do this for any "Code by Intention" methods you create and it will spit out the private methods with matching method signatures. Further, you can go to the Refactor menu and do all sorts of crazy things like automatically create factory methods and make the constructor private, generate getters and setters, move common methods up the inheritance tree, etc. And whenever you do these things, the IDE automatically updates all references in your project to reflect the change.

Can you imagine doing things like this to write CFML? To me this would be a Coding Holy Grail. Now I know that some (all?) of this would be extremely difficult in a typeless, runtime language like CFML. My hope is that bringing these features up to folks who might not be aware of them will generate interest in trying to do these things in CFEclipse. To be honest I never knew IDE's could do things like this. So, would features like this be useful to other CFers or am I just wigging out because I hadn't seen things like this before? Are things like this even possible goals for CFEclipse?

Comments Comments (3) | del.ico.us del.icio.us | Digg It! Digg It! | Linking Blogs Linking Blogs | 5017 Views

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)

  • # Posted By Patrick McElhaney | 11/15/05 6:07 AM

    Have you played with Eclipse's refactoring? Instead of writing out the methods and then filling in the details, I tend to go backwards. I fill the "seargent" method with lots of code. Then I break up the individual steps. Select a line or two of code that you want to be pulled into a private method, right click, and select Refactor > Extract Method. Eclipse will create the private method for you.

  • # Posted By Ryan Guill | 11/15/05 6:44 AM

    Great thoughts. I think this is a great idea, along with other intellisense things. That is one area that ide's like visual studio in other languages have really excelled. At the same time though, those ide's take forever to start up and are horribly slow IMO. So it will probably be a trade off, speed and light weight ide's for powerful, but slower ide's.

    Sean Corfield has been asking for input on feature enhancements for cfeclipse on his blog, you might shoot him a line there.

  • # Posted By Sean Corfield | 11/16/05 4:50 PM

    As Ryan says, I have been asking for feedback on what people want from CFEclipse and we should be publishing a roadmap shortly. We are planning to tackle this whole "intellisense" thing but, as Brian surmises, it's a difficult task. We are definitely taking our cue from what Eclipse can do for Java tho'. Keep an eye on cfeclipse.org (and my blog) for more details.