Archive for the ‘General’ Category

Installing Flex Builder on Ubuntu 9.04

Saturday, April 11th, 2009

For my work I’ve been working with Adobe Flex. If you’re doing Flex development you (probably) work with Flex Builder. It has features a development tool should provide; code completion, design view, good integrated building/running of projects, debugging etc.

At work I’m tied to my Windows XP laptop, at home I work with Ubuntu Linux. Whenever I do Flex development in private time, I always use the Windows machine… but what if you’d like to develop Flex on Linux?

Google quickly pointed to Flex Builder Linux. ‘Yey! A Linux Flex builder!’ The release notes shows some (minor) inconveniences:

Unsupported Flex Builder Features

  • Design view
  • States view
  • Refactoring
  • Data Wizards
  • Cold Fusion – Data Services Wizard
  • Web Services introspection
  • Profiler

And some known issues:

  • Organize Imports removes necessary imports
  • The default version of Java installed in Ubuntu systems is GCJ. This is not supported by the Flex Builder Linux installer and the installation may fail on Ubuntu Systems. Please ensure you have an installed Sun JRE before installing Flex Builder Linux.
  • Getting a transparent window for AIR App depends on your Linux distro capabilities. You may need to turn-on some settings (ex: Desktop effects on Ubuntu 7.10) or install some special packages (example: compiz-fusion, beryl for installing compositing manager) to get this working (if its not working by default)

I left out anything not related to Ubuntu or Flex Builder in general. Besides the ‘design view’ most issues are minor issues. Usually the ‘design view’ is used for some initial drag and drop interface building or for containers with and ‘absolute’ layout  (i.e. Canvas). The ‘design view’ then limits the build/run/change cycles.

Installing Flex Builder on Ubuntu 9.04

The prerequisites mentioned by Adobe are

  • Eclipse 3.3.x (32-bit)
  • Sun JRE 1.5.x or newer (32-bit)
  • Firefox 1.0, 1.5, or 2.0 (32-bit)

At the moment of writing, the version of Eclipse provided with Ubuntu is 3.2.x. So you’ll have to get a newer Eclipse version from Eclipse.org. I tried the latest version available, which is 3.4.2 (which later turned out to be a bad idea, use a 3.3.x version). Installation of Eclipse is as easy as unpacking to the desired location, so I’m not describing that any further. Make sure you have the Sun JRE 1.5.x or newer installed. I installed ’sun-java6-jdk’ via the package manager, the JDK includes the JRE. Configure Eclipse to use that.

JRE settings Eclipse

JRE settings Eclipse

Download the Flex Builder Plugin for Linux.

Installing Flex Builder Linux

To install Flex Builder Linux:

  1. Prior to installing, remove any previous versions of Flex Builder Linux. Refer to the section ‘Uninstalling Flex Builder Linux’ below for instructions.
  2. Run the installer either marking it as executable (chmod +x) or by using a shell to execute it (sh FlexBuilder_Linux_Plugin.bin).
  3. Accept the license agreement and follow the prompts.
  4. When prompted, specify whether to install Flash Player 9 (note that this is an updated version of Flash Player 9 and that Flex Builder Linux will work with earlier versions of Flash Player 9 for Linux). This is the debug version of Flash Player 9, which is required for debugging support and exception display.
  5. Follow the prompts to complete the installation.
  6. Start Eclipse.
    Note: You must create a new workspace before beginning. Select File > Switch Workspace from the menu bar and enter a new folder name. If the folder doesn’t exist, Eclipse creates it.

Install Folder

Install Folder

When choosing the ‘install folder’ you can leave that to default, the Eclipse folder will be defined in the next window.

Eclipse Folder

Eclipse Folder

As described select the Eclipse folder, it must contain a subfolder named ‘configuration’. Continue the installation untill the installer displays that you’re done.

Start Eclipse and open the Flex perspective. If you get the following error while opening a MXML file:

Could not open the editor: Assertion failed:  org.eclipse.jface.util.Assert$AssertionFailedException: Assertion failed

Make sure you have the correct Eclipse version, I used 3.3.2 on Ubuntu 9.04.

Flex Builder Linux

Flex Builder in Linux with code completion

It seems Flex Builder accepts Flex 3 license keys, which is then ignored as it still displays “Flex Builder Linux will expire in xxx days.” If you use charting you can enter your license to remove the trial message.

You already choose to use the trail period and didn’t enter your license key? Open ‘license.properties’ in  ‘home/username/.adobe/Flex’. And add:

flexbuilder3=yourlicensekey

Or change:

flexbuilder3.displayedFirstLaunchMessage=true

to:

flexbuilder3.displayedFirstLaunchMessage=false

Restart Flex Builder and enter your license key in the launch message.

Applying Game Mechanics to Functional Software

Monday, March 16th, 2009

Just finished watching a Google Tech Talk by Amy Jo Kim of Shuffle Brain, regarding game mechanics in functional software (video embedded below). She has worked as a social architect on for example Rockband, and applying game mechanics on the eBay infrastructure. She has great ideas and examples of game mechanics applied to software (almost) everyone is using; YouTube, Twitter, eBay etc.

How can we apply these ideas to ‘boring’ business applications?

Fast debugging statements

Monday, August 25th, 2008

While reading Code Complete 2nd Edition I ran into a chapter which covers defensive programming. Defensive programming includes debugging, but not to any price of course. We don’t want performance of the application to suffer from debugging statements, at least not in production fase. Debugging is mainly used during development.

Implementation (Java)

So how do we implement debugging so that it minimally affects performance? According to the log4j website :

Actual logging is also quite fast, ranging from 21 microseconds using the SimpleLayout, 37 microseconds using the TTCCLayout. The performance of the PatternLayout is almost as good as the dedicated layouts, except that it is much more flexible.

Pretty fast huh?

logger.debug("Number of products: " + order.getNumberOfProducts());

Now we move to our production environment, we’ve changed the logging level to ‘error’ (thus not displaying the debug level).

The log will not show the debug message, but we don’t want the debug statement to be executed even! It’s creating a string instance, adding a integer value to it… we just don’t want that. We change it to:

if(logger.isDebugEnabled()){
	logger.debug("Number of products: " + order.getNumberOfProducts());
}

According to the log4j website:

It costs about 5 nanoseconds to determine if a logging statement should be logged or not.

Just to put things into context, 20 microseconds is 20000 nanoseconds. The only drawback of this implementation is that the check performed in ‘isDebugEnabled’ is also performed in ‘debug’. But who cares? If you’re debugging, you’re obviously not interested in 5 nanoseconds performance win (at that moment).

If you don’t mind recompiling your code for different environments you can make it even faster…

class Debug {
	public static final boolean DEBUG = false;
}

//somewhere in a method
if(Debug.DEBUG){
	logger.debug("Number of products: " + order.getNumberOfProducts());
}

How this is faster? The Java compiler sees the code within the if-statement is unreachable and the code will be left out, and that’s of course even faster than 5 nanoseconds. If someone decides to decompile your code, the debug statements will be gone.

Implementation (C/C++)

The last solution is comparable to something called ‘precompilation’ in the C-language (C and C++). There it looks like this:

#define DEBUG

#ifdef DEBUG
print("Debugging in C++");
#endif

If DEBUG is not defined, the code within ‘ifdef’ will not pass the preprocessor, and therefore will not make it into the compiled code.

No more comments in your code

Friday, July 25th, 2008

Comments, the more the better… right? Well I thought so too, in fact this is some of my code of a few days ago:

// handle the initialization of jobs
if (request.getParameter("initiateJobs") != null && request.getParameter("initiateJobs").equalsIgnoreCase("true")) {
	initializeJobs();
}

// get the trigger info, which will be displayed on the jsp page
List triggerInfo = getTriggerInfo();
request.setAttribute("triggerInfo", triggerInfo);

But what does it really add? Besides two lines of text. The code in the ‘if’ statement should be clear enough for a web programmer, and the method ‘initializeJobs’ tells as much as the comment. Same goes for the two lines of code below that. What would my intention be by putting ‘triggerInfo’ on the request scope? Point made.

Maybe you say ‘it’s faster to read’. Well… I don’t think it is.

if (request.getParameter("initiateJobs") != null && request.getParameter("initiateJobs").equalsIgnoreCase("true")) {
	initializeJobs();
}

List triggerInfo = getTriggerInfo();
request.setAttribute("triggerInfo", triggerInfo);

Looking at one of my last lines of code I realized Sammy Larbi and Jeff Atwood have a point.