Wednesday, July 1, 2009

IntelliJ 8.1 buuild 9732 hangs with Apple Java for OS X 10.5 - Update 4

If you are a Mac user and you applied Apple's Java for OSX 10.5 Update 4 you might be experiencing crashes with IntelliJ 8.1.x. It appears that the software was not tested well enough against the developer preview before the update went GA. You can read more about this here:

http://lists.apple.com/archives/java-dev/2009/Jun/msg00142.html

While you cannot rollback the Java update on the Mac there is a workaround for this issue as described here:

http://www.jetbrains.net/devnet/message/5240216

Here are the steps I used to correct this on my Mac:

Rename this file:

/Applications/IntelliJ IDEA 8.1.3.app/Contents/MacOS/idea

Replace the idea file with the Java system file like this:

cp /System/Library/Frameworks/JavaVM.framework/Resources/MacOS/JavaApplicationStub 64 to /Applications/IntelliJ IDEA 8.1.3.app/Contents/MacOS/

This did correct the issue for me and the software has been stable. IntelliJ was not the only software affected by this update. I also had to get a new version of DbVisualizer (6.5.7) to correct issues with that software as well because of this issue.

Tuesday, June 2, 2009

RSpec and AutoSpec with JRuby

I had a little bit of a struggle last weekend setting up RSpec with JRuby so I thought I would share the way I set this up. I am not sure why I could not find more information on how to do this so I thought I could help the next guy. Anyways, I am using JRuby 1.3.0RC2 which comes bundled with RSpec 1.2.6 which is great but there were two issues I needed to address before using this in my Rails application.

The first issue was introducing RSpec into my Rails application. It turns out that this is simple. First you need to install the RSpec-Rails gem like this:

jruby -S gem install rpec-rails

Next switch to your Rails project home directory and scaffold out the RSpec components like this:

jruby -S script/generate rspec

This will introduce an rspec folder with the initial scaffolding you will need to write RSpec tests for your Rails application. This only needs to be done once.

The next thing I wanted to do was use AutoTest so that my tests would run in the background while I am coding. This way I can make changes to my code and tests and have the modified tests run on a continuous basis. When we ran the RSpec scaffolding in the Rails application we received an autospec script in the script folder. This is what will allow you to have this perform your local continuous testing. The only other gem you will need is the ZenTest gem which is used for AutoTest and AutoSpec.

jruby -S gem install ZenTest

You are now setup to run all of your Rails RSpec tests manually with Rake from your project home directory:

jruby -S rake spec

Or you can turn on AutoSpec and let this happen in a Terminal like this:

jruby -S script/autospec

I am also using the latest NetBeans IDE (6.7 RC1) for development and find that AutoSpec works great there as well. To do this right click on your project folder and click AutoSpec. This will kick off the script. Here is an example of some of my results:




NetBean also has a nice navigator window for seeing an outline of your specs:


I think that RSpec and AutoSpec provides a very easy and productive way to practice TDD in your Rails applications. Well back to writing more tests...

Friday, March 27, 2009

I Code Better Without A Computer

Alright so this might sound a little silly because we need a computer to actually write code. However, I find that most of my best design, code, and refactoring efforts happen when I am not at a computer. This has been a common theme for me since college where I would wake up with a thought about some problem I was working on but could not resolve while conscious. I would literally wake up some nights with an answer to something that I obsessed about during the day.

I continue to find myself doing the same thing with my code. This happens when I am driving, sleeping, watching TV, playing WoW, showering (don't think too hard on that one) or while my wife is trying to carry on an important conversation (bad idea BTW). I just tell her that I was listening but spawned a new thread while she was talking. This tends to not work in my best interest so don't try that one. I will let you know when I think of a response that won't get you in trouble.

I guess I found out that I was not the only person who experiences this behavior when I attended Neal Ford's On the Lam from the Furniture Police presentation. There he explained how the right and left sides of your brain operate and how they contend for time. The right side of your brain is where your creative non-linear thoughts occur while the left side of you brain spends it's time with rational linear thought processes. It turns out that if you can occupy the left side of your brain with mundane white noise like sleeping, driving, showering, WoW, the wife, whatever...you free up time for your right brain to produce meaningful analytical abstractions without your left brain interfering.

How many times have you resolved an issue while you are in the process of explaining it to a coworker. Your own blabbering can shut down your right brain so your left brain can reason things out! Here is another cool technique that Neal Ford suggested which sounded bizarre at first to me but then made good sense (to me at least). He suggested putting a rubber duck on top of your monitor and when you get stuck you explain the issue to the duck. This is not a magic duck (I don't think). The point is you are freeing up your right brain to perform the tasks you are really interested in.

I am pretty interested in understanding more about how the brain functions and will probably read Andy Hunt's book Pragmatic Thinking and Learning: Refactor Your Wetware. Maybe if I can control my mind I might be able to control my code. Those of you that know me might agree...

Swiz is the Shiz

Now that I am doing more Flex development I am back to researching MVC frameworks for the Flex client. I initially did what most Flex developers do as they start learning and create inline code that cannot be maintained. From there I went to the other side of the spectrum and tried Cairngorm which did exactly what it said it would do but at the price of being very heavy but keep your code organized. The biggest problem with Cairngorm is that it lead to code explosion with all of the objects it required you to create. Needless to say I wanted to find something simpler.

I then researched some other available frameworks like PureMVC and Mate. PureMVC looks like and octopus of classes and seems like a Cairngorm like framework with incremental improvements. Mate was a lot closer to what I wanted but seemed to introduce too much custom framework.

Finally, I found Chris Scott's Swiz framework. Swiz works that way I think since I do so much Spring development in Java. Swiz's main goal is reduce the clutter you maintain in Flex like singletons and service locators by using dependency injection of your components in your application. Swiz also comes with a very intuitive annotation model for dynamically dispatching and registering event listeners to your methods. All of the nonsense you would normally write with some of the other frameworks are abstracted in Swiz and you end up with little framework noise. Visit the Swiz site and look at the docs. You will be up and running in about an hour if you understand how dependency injection works already. You can also check out Christope Coenraets Swiz example for a simple running example. Also look at the Flex 360 video from Chris Scott for a full explaination about this framework.

Tuesday, February 24, 2009

Mockups

I found this cool little mockup tool that is very easy to work with called Balsamiq. I generally use OmniGraffle for sketching mockups and wire frames but I found this tool to be very enjoyable to work with. When you DnD you elements to the screen you get lots of options for editing that is very intuitive. Here is a quick example of something I whipped up with this tool so you can see what you can do in 2 minutes. The images are cartoonish but I think it will resonate well with end-users when doing design meetings or technical presentations. Simple! Easy to use! Great tool!

Monday, February 16, 2009

Hudson, run a bypass

I thought I would share a pleasant experience I had with a CI (continuous integration) tool called Hudson. I have used other tools like this in the past including Anthill, CruiseControl, and TeamCity. While these tools did their job none of them seemed as easy to use as Hudson.

Hudson downloads as a self contained war file that launches from a command line:

java -jar hudson.war

That is really it to get running and there is nothing else to install. Hudson comes with a built in servlet engine called Winstone. There are no configuration files that you have to touch because you use the built-in intuitive UI to configure the Hudson server and your projects. There are tons of plugins available that can be used to extend the core functionality or you can write your own custom plugins. We run Starteam (yuck) for source control internally but I found a plugin for it and installed it from the web administration. Very simple! I was able to configure SCM checkout, setup email notifications, and execute our build script successfully in about 15 minutes without knowing the product. If you want to see what awesome open source projects look like check out Hudson.

Sunday, February 1, 2009

Flex 3 Builder on Mac OSX

I ran into problems installing the Flex 3 Builder Professional edition on my Mac. This was because my current version of Java was set to 1.6.0. Before you install make sure you go in your Java Preferences (from spotlight) and make sure your Java application setting is J2SE 5.0 32 Bit by dragging it to the top of the list (temporarily). Then install Flex Builder 3 from the DMG file. You will not encounter any errors in the installation.

Finally, I needed to use the latest version of Java but Flex Builder still needs to run on the 1.5 JDK. For this I went through Finder to edit

/Applications/Adobe Flex Builder3/Flex Builder.app/Contents/MacOS/FlexBuilder.ini

From here just add these lines to the top of this file so you can use the right version of Java:

-vm
/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0

-vmargs
-Xdock:icon=../Resources/flexbuilder.icns
-Xdock:name=Flex Builder
-XstartOnFirstThread
-Xms128m
-Xmx512m
-XX:MaxPermSize=256m
-XX:PermSize=64m
-Dorg.eclipse.swt.internal.carbon.smallFonts
-Dorg.eclipse.swt.internal.carbon.noFocusRing

Now when Flex Builder starts it will use the right version of Java. Go back into Java Preferences and move Java SE 6 back to the top of the list if that is what you want.