Building Software Cheat Sheet

10 12 2009

Building Software with a smile

I’ve been wanting to write this article for a while now, I use all my articles as personal notes, plus giving back to the community are something that counts in my book aswell. The article are about how we manage and build our software at work and the stuff im using for my private pet projects. It’s an ever evolving process, that will probably never stop. There’s always process’s that can be simplified. It’s a short article that you can use for getting a stack together quick. Enough chatter, onto the fun stuff πŸ™‚

Methodologies

We try to adhere under the ideas of people like Robert Martin (whom have summed up a lot of ideas of other people), go grab clean code you wont regret it. In short write code in a minimalistic readable way, remember to test it, care about your code and smile. Clean code really has summed it all up. Although there’s a lot of books on the topic’s of coding, testing etc. It’s my favorite. Oh and do not forget something like scrum.

Language

I’m not going to rant about why but we use Java, there’s several reasons but I have no deeper feelings about this topic, I havent looked enough into Ruby, Scala etc. to be a judge. Mostly that there’s so many things available for Java, however the same are the case for Grails, Rails etc. I just like static languages a bit more. However the topics in are not in depth about Java.

Building System

We are using Apache Maven 2, which has some really nice features like it’s convenience over configuration. There’s very good integration towards build servers and a huge list of plug-ins that’ll to the job for you. Just rememberer do it the maven way, and let the system work for you, do not fight it πŸ™‚ One side of Maven are testing, for that we are using a mixture of Junit4, Jmock and JBehave that ensures us maximum freedom and productivity.

Build Server

As for build server we are using Hudson, it’s simple and straight forward. It has great integration towards maven, I guess we could just as well have used Continuum but Hudson worked on first try Continuum did not. In Hudson we have three projects per Maven project, one for continuous integration and one for making a release and one for our metrics. The CI project are notified by our version system upon changes, then grabs the source and builds. The release project awaits when we are ready for a release, and then assigned build manager “clicks” build, awaits and downloads the finished release product, simple as that! The release process of course, checks out a fresh copy tags it in scm builds and releases/package the artifacts. I’ll write a bit about the metrics project below.

Metrics

Now what goes hand in hand with a build server are a metrics analyser like Sonar which actually are a bunch of subprojects packaged nicely together and presented in style. It’s really easy to add to any Maven project just have the sonar running and run mvn sonar:sonar and voila fresh metrics. Just remember sonar will only keep one set of metrics per day AFAIK.

Before I discovered Sonar I used a lot of time configuring Maven metric plugins. However Sonar does it all and easy, plus have a lot of features/plugins, like timeline hotspots and quick wins. Very nice all in all.

Version System

For scm we use Subversion, no real arguments here it works for me and I haven’t tried out any other scm. Most annoying thing though are that we are having some trouble using branches (svn 1.5 using eclipse/tortoise etc) otherwise not much to say. I’ve peeking a bit towards git, but haven’t had the time to go further.

Ticket System & Wiki

For Tickets/Defects/issues & Wiki we use trac. Reasons are that it’s simple and materialistic. Although sometimes to minimal, theres always a plugin that will just expand trac the way you want. Only thing that are bothersome is working with multiple trac sites. I’ve been eager to try redmine out, it seems like trac but can a bit more. So heres what im missing in trac:

  • Ticket dependencies
  • Multiple site support easy

IDE

We use Eclipse, mainly because it’s the one I’ve been using longest and one of our vendors has made a specific product based on eclipse. I’ve tried both subclipse and subversive, and can’t figure out what are best. None of them seems to be working optimally with branches. Only way to get a good diff when merging a branch are in svn command line :/ One note though we are limited to Eclipse 3.2 and plugins that support that. So it might be better in newer versions.

I’ve been told a couple of times by different people that idea, are better and actually will make you more productive. And now with the free community version I might give it a try.

Links

So following above, you should be set all the software mentioned in this article are free. Now go download and start making the world a better place. There’s a lot of projects out there waiting for you, either open source or for money. And just remember it’s better to try than not, some one once said it’s by our mistakes we learn πŸ™‚

Stuff we use:

Stuff that i’d like to investigate:

Ohh and if you have any comment’s feel free to write.





Cleaning Code Practically Episode 1

8 10 2009

Last Øredev I were at a presentation done by Robert Martin, author of the book Clean Code. I were really impressed by what his message where. So we are trying to follow his word at work and today a topic came up. So a colleague had this code:


public String getRequestString() throws MQException {
String request = "";
request += Helper.leftRightFilled(true, String.valueOf(getSessionNumberAndIncreaseIt()), '0', 3);
request += Helper.leftRightFilled(true, getVersion(), '0', 3);
request += Helper.leftRightFilled(true, getTransaction(), 'X', 4);
request += Helper.leftRightFilled(true, getLanguage(), 'X', 2);
request += Helper.leftRightFilled(true, getCallersPhoneNumber(), '0',16);
request += Helper.leftRightFilled(false, dynamicSettingMQ.getCustomerNumber(), ' ', 16);
request += Helper.leftRightFilled(true, String.valueOf(dynamicSettingMQ.getNumberOfUnsucceededCalls()), '0', 3);
return request;
}

I intermediately though that could be more readable, so I just pushed a lot into functions, and did a little to the helper class:

public String getRequestString() throws MQException {
String request = "";
request += createSessionNumberString();
request += createVersionString();
request += createTransactionString();
request += createLanguageString();
request += createCallersPhoneNumberString();
request += createCustomerNumberString();
request += createNumberOfUnsucceededCallsString();
return request;
}
protected String createCallersPhoneNumberString() throws MQException {
return Helper.leftRightFilled(true, getCallersPhoneNumber(), '0', 16);
}
protected String createCustomerNumberString() throws MQException {
return Helper.leftRightFilled(false, dynamicSettingMQ.getCustomerNumber(), ' ', 16);
}
protected String createLanguageString() throws MQException {
return Helper.leftRightFilled(true, getLanguage(), 'X', 2);
}
protected String createNumberOfUnsucceededCallsString() throws MQException {
return Helper.leftRightFilled(true, dynamicSettingMQ.getNumberOfUnsucceededCalls(), '0', 3);
}
protected String createSessionNumberString() throws MQException {
return Helper.leftRightFilled(true, getSessionNumberAndIncreaseIt(),'0', 3);
}
protected String createTransactionString() throws MQException {
return Helper.leftRightFilled(true, getTransaction(), 'X', 4);
}
protected String createVersionString() throws MQException {
return Helper.leftRightFilled(true, getVersion(), '0', 3);
}
}

At first the colleague thought it was nice, but then remembered he really needed a overview of locations used in the string manipulation. So a thing between the two are needed:

public String getRequestString() throws MQException {
String request = "";
request += createSessionNumberString('0', 3);
request += createVersionString('0', 3);
request += createTransactionString('X', 4);
request += createLanguageString('X', 2);
request += createCallersPhoneNumberString('0', 16);
request += createCustomerNumberString(' ', 16);
request += createNumberOfUnsucceededCallsString('0', 3);
return request;
}
protected String createCallersPhoneNumberString(char fillWith, int length) throws MQException {
return Helper.leftRightFilled(true, getCallersPhoneNumber(), fillWith,length);
}
protected String createCustomerNumberString(char fillWith, int length) throws MQException {
return Helper.leftRightFilled(false, dynamicSettingMQ.getCustomerNumber(), fillWith,length);
}
protected String createLanguageString(char fillWith, int length) throws MQException {
return Helper.leftRightFilled(true, getLanguage(), fillWith,length);
}
protected String createNumberOfUnsucceededCallsString(char fillWith, int length) throws MQException {
return Helper.leftRightFilled(true, dynamicSettingMQ.getNumberOfUnsucceededCalls(), fillWith,length);
}
protected String createSessionNumberString(char fillWith, int length) throws MQException {
return Helper.leftRightFilled(true, getSessionNumberAndIncreaseIt(),fillWith,length);
}
protected String createTransactionString(char fillWith, int length) throws MQException {
return Helper.leftRightFilled(true, getTransaction(), fillWith,length);
}
protected String createVersionString(char fillWith, int length) throws MQException {
return Helper.leftRightFilled(true, getVersion(), fillWith, length);
}

Im not satisfied, but not sure it can be done more clean? And if you are wondering about why we are doing all this string manipulation, we are working with some legacy MQ. If we split up the code without parameters as above we lose the quick overview.. But could the code be simplified even more please come with your suggestion..





Eclipse 3.2 And Subversive

3 07 2009

Seems like gremlins in my machine, first time we at work did a branch the branch received changes from trunk. But did not push stuff back to trunk. Merging was simple since the branch always was up to date with trunk and only had a few changes..

Some time passed and we tried doing a new branch, a few problems, but at last we finally made the branch. Worked with it, but now subversive and tortoise refuses to merge the branch back again! I’ve tried a million things. In the end I checked out trunk removed the affected parts and added the ones from the branch and commitet those again. Just to get our system into working order..

My primary suspicion now are that doing branches are very affected by which svn provider you chose, nothings confirmed, but I know we’ve switched providers since the first successful branching.

Any other experiencing troubles with this ancient version of eclipse & subversive?





WicketStuff Artwork new release

26 05 2009

Ever tired of using endless hours of css’ing just to find out that what you did breaks in IE.. WicketStuff Artwork is all about making your wicket site turn into art, easy. It’s a package consisting of two modules

  1. Liquid
  2. NiftyCornersCube

Both modules will let you do round corners on containers simple and easy, just add a behavior to your wicket component or your page and thats it.
Liquid will let you do all sorts of advanced stuff with your markup containers, for example add a shadowed border, see this screenshot:

Liquid Examples

Liquid Examples

NiftyCornersCube are really quick to render and requires less cpu processing so it has some advantages but are also very limited in effects. See here:

Nifty Examples

Nifty Examples

You can grab the latest snapshot release here:
http://wicketstuff.org/maven/repository/org/wicketstuff/artwork/1.4-SNAPSHOT/

And see howto checkout the examples here:
http://wicketstuff.org/confluence/display/STUFFWIKI/Wiki

Basically it’s just this svn url:
http://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/wicketstuff-core/artwork-parent/artwork-examples
But you should check out the whole wicketstuff core in order to build dependencies.

Now please come with more ideas and JS libs to add to the Artwork package πŸ™‚ I want to see some comments on how to improve it πŸ™‚

Regards Nino





Cloning Ubuntu installation

26 04 2009

Hi you might want to upgrade your disk from time to time, so you either need to clone or ghost it. Heres how I do it.

First prepare the disk with the GUI tool gparted. I like to have a few partitions, one for winblows, one for winblows games, one for ubuntu and one ext3 for storage.

Then copy your system (remember not to have too many apps open at this time wierd stuff could happen once you start up the other disk)
Open a terminal and write:

sudo rsync -a -x --exclude /media/newdisk / /media/newdisk

Make grub active on the new disc, in the same terminal or another write:

grub> setup (hd0) (hd0,0)

Which installs grub into the MBR of hd0 (hda) using the boot files that were already in /boot on hd0,0 (hda1).

Now you can do "kernel (hd0," and then tab in the grub command line to find partitions. Once you identify your drive you should also be able to do the math for the partition.

Okay almost done, now we have to go edit the grub menu.list located under the /boot folder of the new disk, ubuntu are using uuids to identify partitions. So it’s time to open gparted again, remember that we did it the last time from a terminal, we do the same thing again “sudo gparted”, and find the partition where you copied the system to and then right click and press info now theres a field called uuid, copy paste those into the appropriate of the menulist like here :

example

title Ubuntu 9.04, kernel 2.6.28-11-generic
uuid 49753240-3c10-4fdb-a624-6b07b5071d09
kernel /boot/vmlinuz-2.6.28-11-generic root=UUID=49753240-3c10-4fdb-a624-6b07b5071d09 ro quiet splash
initrd /boot/initrd.img-2.6.28-11-generic
quiet

title Windows XP Home
uuid 4D9D89C529CA8435
makeactive
chainloader +1

So before wiping the old disk I suggest that you try booting the new one, just in case something went wrong. I had no troubles with it, but it’s always nice to have a backup.. Most motherboards today have a option to boot from different disks.

I’ve used this blog here as source http://encodable.com/tech/blog/2006/10/30/Ubuntu_Linux_Hard_Drive_Upgrade
as well as this one http://samuelcheng.wordpress.com/2009/02/04/transferring-ubuntu-to-new-harddrive/





Adjust Webcam settings ubuntu

8 04 2009

My solution was to run this small tool :

luvcview -f yuv -l

I have a creative live im ultra.. Works like a charm.. Now if I could only get my twin display working when I play games!





Integration Testing With Nortel SCE / Part 1

3 04 2009

So you are developing with the Nortel SCE and want todo integration testing. Theres no support for it in the framework itself. So we think and think. The SCE communicates via voicexml or VXML towards the MPS. This happens over http protocol, that means the we can use Jmeter to sniff the communication between MPS and SCE (JBOSS / struts). So in practice to make this work you need to setup the http proxy on jmeter and then go into the SBClient.cfg located here : C:\Program Files\Nortel Networks\SelfService\PERIvxml\config\ on a standard installation , edit these two lines:


client.inet.proxyServer VXIString localhost
client.inet.proxyPort VXIInteger 9000

Proxy server are the machine where you have jmeter running and port are the one you specified when setting up the proxy, id recommend using 9000 since the default 8080 clashes with the SCE Jboss port. After changing the parameters you need to restart the MPS service.

So there are two was of recording, on your local machine using the mock interface provided with SCE / eclipse ( execution view / WVADS ). Or on your test facility where you actually can dial in as normal, and record the scenarios. Just remember when you end Jmeter the proxy goes down aswell, meaning the MPS & SCE can no longer communicate, just comment out the 2 lines in sbclient.cfg to get it working again.

Tips

  1. Remember to switch recording controller in jmeter between scenarios. And one more thing this will only record the dialog between SCE and MPS, not the audio server.
  2. If you add appropriate listeners to your jmeter scenario when you replay you can even see the vxml responses.

Heres how a scenario from a very simple application looks (Just playing a couple of prompts):

SCE Jmeter Scenario

SCE Jmeter Scenario

After recording the scenarios they can now be replayed at wish for example as part of integration test. In the next part I’ll try to digest howto put in test coverage with coberatura, so we get some metrics on how much of our code actually are tested with this approach. Now sadly since SCE does a lot of auto generation I think the process will be partially manual, so we cannot employ a building server like Hudson for this:( If you have any ideas on howto run the SCE auto generation as a MOJO from maven or something please do not hesitate to write. As always comments are more than welcome πŸ™‚

If you are new to jmeter you can read more here, Jmeter site