Category Archives: Software Development

Eclipse Keyboard Shortcuts

I hate my mouse, I love ALT-TAB in Windows, Homesite gives you CTRL-TAB to effectively switch between open files but I couldn’t figure out a way to the do the same thing in Eclipse. Turns out Eclipse functions more like IE in that each file you view becomes part of your viewing ‘history’. To switch between files, you can use ALT-LEFT ARROW or ALT-RIGHT ARROW just like you can in Internet Explorer to go BACK and FORWARD. Nifty.

Eclipse Local History

Say you just modified a file in Eclipse and you want to roll back to the version you had about 5 minutes ago. With a normal IDE, if you’ve had the file checked out from SourceSafe or CVS without checking it back in you won’t be able to see your changes. Eclipse however, maintains it’s own little history of your changes, which you can see in the screenshot to the left (click it to see the large version). To get this ‘local history’, right click on the file in question, choose “Compare With” and choose “Local History”. Very very cool.

You can read more about Local History here if you’re so inclined.

Test versus Type

Oliver Steele, who is the Chief Software Architect at Laszlo Systems, wrote a short essay about the cost and time difference between “Explicity-Typed Languages” and “Implicitly-Typed Languages”.

A couple people pointed out in the comments that you gain back some of the time lost by developing types & tests in an Explicitly Typed Language when refactoring because your IDE can help you where it can’t in an Implicitly Typed Language. In my humble opinion, this (refactoring) is an example of one of the reasons why J2EE developers don’t look very long at ColdFusion. Moving to ColdFusion requires them to think procedurally rather than in objects (although CFC’s now provide pseudo OO behavior). Testing becomes stickier (although DRK 3 includes the CFunit component framework for testing ColdFusion components). Of course, Oliver’s article is also a great reason TO use a tool like ColdFusion. Instead of spending time writing recursively types,tests, & code, you can code/test/code/test.

re: CFMX Java-jock jihad

Geoff makes a couple blanket statements in his post about how the Java world doesn’t understand CFMX. I don’t agree with a couple of them:

· ColdFusion remains the only answer to making Java accessible to a mass of non comp-sci web developers — I don’t have a computer science degree, neither do 3 of the other 4 developers at Mindseye (all of whom have written Java applications and all of who have spoken at DevCon) and I’ve created a couple sites using Java & JSP technology so to say that non comp-sci web developers can’t understand Java is patently incorrect. I think it also bears mentioning that Java is considered by some to be a language for the masses:

The advantages of Java is that it easily serves as a lingua franca – everyone can read a Java program and understand what is going on…“,

· …most Java developers fail to see where CFMX fits into their world of programming… — Why should they care? There are a number of other scripting languages that work with Java, PHP being one of them. Java developers have enough to worry about… they’re too busy choosing between web frameworks (struts, tapestry, webwork2), persistence models (obj, castor, jdo..) and templating mechanisms (velocity, cocoon..). It’s commonly mentioned/demonstrated that ColdFusion is easy by showing how few lines it takes to query a database, but has anyone ever asked an enterprise Java developer how many queries they put into a JSP? .

With that said, I think that Geoff has the right attitude, starting a “.. post-positive campaign highlighting CFMX/Java symbiosis” is a great starting point. Go one step further though. Build a J2EE application, learn Struts, use OJB. Geoff claims that J2EE people don’t understand CFMX. How well do CFMX people understand J2EE?

Jakarta Latka

I have a peculiar interest in testing tools… I’ve mentioned JMeter (which is more of a stress testing tool) a couple times before, I just found a new one on the Jakarta site call Latka, which “… is a functional (end-to-end) testing tool. It is implemented in Java, and uses an XML syntax to define a series of HTTP (or HTTPS) requests and a set of validations used to verify that the request was processed correctly.

The cool thing about Latka is the non Java part… anyone that understands a little XML can create and/or edit an xml document that defines an ‘test’ and then run it using the Latka engine. So for instance, here at Mindseye our QA team is composed of invididuals with a small amount of programming experience. They could easily create a Lakta test using the xml syntax and then automate the testing of various applications using Latka. Still not convinced, here’s a sample test:

<?xml version=”1.0″ standalone=”no”?>
<!DOCTYPE suite PUBLIC “-//Apache Software Foundation/DTD Latka Test Suite 1.0/EN”
   “http://jakarta.apache.org/commons/latka/dtds/1.0/suite.dtd”>
<suite defaultHost=”http://www.mindseye.com” label=”mindseye”>
   <request path=”/whymindseye/default.cfm” label=”why you should choose mindseye” method=”get” secure=”false” followRedirects=”true”>
      <validate>
      <statusCode code=”200″ />
      <regexp pattern=”What drives landmark companies” />
      </validate>
   </request>
</suite>

Save this to a file and then type:

latka file:PATH_TO_FILE

from the command line. It should check that the page http://www.mindseye.com/whymindseye/default.cfm returns an HTTP status code 200 and that it contains the phrase “What drives landmark companies”.

Unfortunately, Latka doesn’t appear that anyone is working on it (at least since last July).

On a related note, I also found this Slashdot discussion on “Testing Products for Web Applications?“.

Calling Java Constructors with ColdFusion

I mentioned yesterday that Sam posted some great code that lets you upload files to ColdFusion without using CFFILE. His code can be shortened considerably with the use of the init() method:

<cfscript>
fileAsString = “”;
fileReader = createObject(“java”, “java.io.FileReader”);
fileReader.init(form.upFile);
bufferedReader = createObject(“java”, “java.io.BufferedReader”);
bufferedReader.init(fileReader);
try {
   do {
      fileAsString = bufferedReader.readLine();
      processLine(fileAsString);
   } while (true);
} catch (coldfusion.runtime.UndefinedVariableException e) {
// this indicates end of file, ok to ignore error
}
</cfscript>

Basically, you use the CreateObject() function to get a Java object. At that point, you can call static methods on the object or you can use the init() method to call the constructor of the Java object, which I’ve done above, ie:

// get a FileReader object
fileReader = createObject(“java”, “java.io.FileReader”);
// call the FileReader object constructor
fileReader.init(form.upFile);

If you’re curious about this kind of stuff, you should check out the article on Java, ColdFusion MX and Lucene integration I wrote for the July issue of ColdFusion Developer’s Journal, due to hit the stands anytime now.