A proper shell in windows

Thanks to a posting on our mailing list I am trying out mintty, a tty shell emulator for windows which runs on top of cygwin.

So far so good, feels like the real deal.

You can install it by running “setup.exe” in the cygwin folder and install it from the package list under “shells”.

I added a couple of lines to my ~/.bash_profile

export PS1="\W> "
alias clear='echo -e "\033c"'

As there didn’t seem to be a default “clear” command to clear the terminal. Got the trick from here. Also good is The tips and tricks page

To get a nice “Bash prompt here” you can install the chere package from the cygwin setup (same as above) and then run:

chere -i -c -t mintty -s bash

One oddity I’ve found is that if you execute a batch file which uses CMD.exe, CTRL+C doesn’t seem to work. It breaks out of the program but then output still appears! So you need to run .sh files in there.


Walk the streets of your codebase: inFusion, Code City and a MOOSE

Moose is a framework built in Smalltalk for code analysis. Here’s a brief guide to get it up and running (at least on OS X). One very interesting application which is built on top of it is called CodeCity built by Richard Wettel. The instructions below are how you go about installing and using CodeCity. The picture above is a code city generated from a project I worked on.

The size of the building is determined by the number of methods, the width and length by the number of attributes and the colour by the number of lines of code (lighter blue is more lines of code). The “districts” are packages. You can see straight away from this view that we have one large “CBD” which is a result of us having a single package called “model” rather than more granular, domain related packages (.acccount, .customer, etc) which would be my preference.

A second immediate observation is that we have a syscraper; what is this? In this case, its actually a stub class, which shouldnt even be in the production codebase. Straight away we have found some value from the visualisation. I tend to believe that this may be a result of our IDE tools (such as CTRL+SHIFT+T or CTRL+N which allow us to browse classes by name). Whilst great for encouraging Ubiquitous language I think this view of the codebase is very focused and heads down, and when concentrating on delivery, perhaps we need to come up from the detail level every now and again. Its why I enjoy the package view in IntelliJ in which multiple source folders together and presents classes as top level “leaves” in the tree so that its easy to see the structure of your packages, compare to eclipse.

I recently printed out the city and stuck it on the wall and was pleasantly surprised by the interest it generated by passers by, so I think its a really useful tool for showing the team something which is inherently hard to “see”.

These instructions are for a java project.

1) Download inFusion

Although its commercial software you can download it and use it for free. It will read in your source code and save it to a file in Moose (Famix) format. This can then be used by CodeCity.

You can download inFusion here. On its own, inFusion is a useful metrics tool and provides some interesting visuals (see below) which I won’t cover in detail here. A good reference is Michele Lanzas’ work Object-oriented metrics in practice.

You can run inFusion as a gui to explore your codebase, or if you just want to get to code city, you can run it as a batch file.

To run the ui just go into

$: cd /Applications/inFusion/tools
$: ./inFusion.sh

or (windows)

C:> inFusion.bat

To export the codebase in famix format (must be 2.1):

$: cd /Applications/inFusion/tools
$: ./java2mse.sh $SOURCE_DIR famix21 $TARGET_FILE

or (Windows)

C:> cd C:\development\external\inFusion\tools\inFusion
C:> java2mse.bat $SOURCE_DIR famix21 $TARGET_FILE

You may need to chmod +x the file.

On windows you can run the .bat file.

2) Load your source code

(theres a folder icon on the right). This takes a while and eventually presents you with a html view of your project stats in the bottom window.

An example of the output is shown here:

To do anything interesting, you right click (or two finger-click on a macbook trackpad) over “java” this will be whatever the name of your root directory is, maybe “src”.

One option there is to Run tool -> Famix 2.1 exporter. This is the format you want to export for code city. Its important that its 2.1

Again you might have to chmod +x the script.

Notice that you can also run another extremely cool tool, called DuDe which analyses duplicate code fragments in your code base.

3) Now your ready for code city

Download it from here.

There are versions for windows os x and linux.

The os x app is very handy and simply runs.

4) Import your MSE file

“Import Model(s) from …” “an MSE file” button.

5) View the city!

There are some keyboard shortcuts which werent obvious to me (help -> key mapping). You do W to “zoom in”, “S” to zoom out, “A” to move the whole scene left and “D” to move the whole scene right.

You can then navigate around using the arrow keys. If you press CTRL with the arrows, you rotate around the sphere of observation.

Some other cool features are to toggle contextual edges on (its a menubar icon, hover over them). You can configure contextual edges with incoming or outgoing invocations and then select an object and see “wires” indicating where the connections are.

Other features:

Make a snapshot of the picture as png
Import a set of MSE files and see an evolving city
View class blueprint of the classes

Enjoy your city!


Visualise codebase evolution with gource

This rocks.

Instructions for what I did to get it up and running are below. Once you have it, just go into an folder with a git repo and type:


A few minutes later and you are watching your codebase being built by mini avatars. This is an amazing visualisation, just need to work out how it can be used. I suspect that it might help teams to look back over time and see how much things have grown and where all the work goes. Potentially it could be synchronised to other visualisations to explore the history of a codebase.

Nyway, here are my steps to install:

There are instructions on the googlecode site. I’m running OS X and so can install with MacPorts.

First I needed to update and sync my macports. I tried using the port selfupdate but it didnt work for me so I just downloaded and installed the DMG from the ports site, but in theory you should be able to do:

sudo port selfupdate
sudo port sync

Then install.

Also I got

dyld: Library not loaded: /opt/local/lib/libjpeg.62.dylib

So needed to update tiff

sudo port install tiff
sudo port install gource

Hyperia: Adventures in REST at the Manchester Geek Night

I had the pleasure of Presenting at our Manchester Geek Night last night (Slides up at Hyperia).

Here is the abstract for the talk. It was good fun both writing the code and doing the talk. (thanks to Dan for helping to get it over the line with 4 half hour iterations the night before). Thanks to all who attended.

The web has been running for many years at a truly global scale on the Hypertext Transfer Protocol (HTTP). The architectural style of HTTP, known as Representational State Transfer (REST) has recently become popular as the basis for application protocols, aswell as the ubiquitous browser client.

This talk will showcase a simple framework called “Restfulie” based on the work of Dr. Jim Webber, Ian Robinson and Savas Parastatdis.

The framework consists of a REST client framework, and by default uses the VRaptor web framework for a backend.

The talk will demonstrate the framework using a demonstration application called “Hyper Fantasy”, which is an online implementation of the classic “Fighting Fantasy” books of Steve Jackson (http://en.wikipedia.org/wiki/The_Warlock_of_Firetop_Mountain) which provides a convenient metaphor in terms of following links to new resources, and client-side state.

I plan to extend the example and host it on the web. It will go through a rebrand to be called “Hyperia”. There are several possibilities for extension including secure requests, cross language implementation (Ruby and Java) Cloud hosting, multiple servers, caching and iPhone apps.


Hibernate Proxy InstantiationException

Changing entities to be lazy loaded led me to the following problem:

@OneToMany(fetch = FetchType.LAZY)
Caused by: org.hibernate.HibernateException: Javassist Enhancement failed: Thing
	at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:142)
	at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.getProxy(JavassistProxyFactory.java:72)
	at org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:402)
	at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3483)
Caused by: java.lang.InstantiationException: Thing_$$_javassist_38
	at java.lang.Class.newInstance0(Class.java:340)
	at java.lang.Class.newInstance(Class.java:308)
	at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:139)

Thanks to Kristian I jumped straight to the problem. From the Hibernate docs:

Cat has a no-argument constructor. All persistent classes must have a default constructor (which can be non-public) so that Hibernate can instantiate them using Constructor.newInstance(). It is recommended that you have a default constructor with at least package visibility for runtime proxy generation in Hibernate.

This should probably read “It is essential….”

Anyway now everything is real lazy so happy days.