Friday, 30 April 2010

Operation "Bad Apple"

For a long time Apple didn't really impinge on my consciousness. Any time I tried to use a Mac I went away feeling frustrated. A child of the Windows age, I'd grown up to love Linux through Ubuntu, and the Mac just seemed too alien.

That all changed when I saw the video where Steve Jobs introduced the iPhone.

I knew as soon as I saw that video that I wanted an iPhone. I stood in a queue on the day the original was released. And then, when the 3G version came out, I queued again to upgrade to it. The iPhone acted as a gateway drug to the world of Apple. I couldn't bring myself to use Windows on a day to day basis, so went out and bought a Mac Mini. And then, having drunk the kool aid, I went out and bought a Mac Air. I'd turned from sceptic to true believer through the seductive wiles of the iPhone.

And for a while I was happy. I moved all my development at home to my Macs. My Ubuntu machine went into semi-retirement. The whole "Unix with a friendly interface" thing appealed.

But that's all gone now. When Apple sued HTC for patent violations, it confirmed my suspicion that I had backed the wrong team. And so Operation "Bad Apple" began. I am gradually ridding myself of the bad Apple stench. I have ordered a custom build PC on which I intend to install Ubuntu 10.04. I've ordered a Acer 1810TZ for my portable computing needs. And I already have a HTC Desire.

In my brave new world I will do all my development on Ubuntu, I will write apps for Android, and I will never buy another Apple product again. As far as I'm concerned, Apple are no longer a company for developers.

I'm switching sides.

Wednesday, 28 April 2010

Link: Interview with Rich Hickey

 On what prompted him to write Clojure:
One watershed moment for me was when I designed and implemented a new system from scratch in Common Lisp, which was a new language for me at the time, only to have the client require it be rewritten in C++, with which I was quite proficient. The port to C++ took three times as long as the original work, was much more code, and wasn't significantly faster. I knew then that I wanted to work in a Lisp, but realized that it had to be client-compatible. I worked on bridging Common Lisp and Java, while doing functional-style programming for clients in C#, for a couple of years, then bit the bullet and wrote Clojure.
http://www.simple-talk.com/opinion/geek-of-the-week/rich-hickey-geek-of-the-week/

He always seems to have something interesting to say.

Monday, 26 April 2010

How to Manually Build and Configure Msysgit

Up to now I have held off from putting all my code in github for one reason - I couldn't access private repositories from work because of the corporate firewall I am behind. But the introduction of Smart HTTP Support has changed that. Unfortunately I had some problems getting this working on my work PC, so I have documented the steps I had to go through for future reference.

I'm a heavy Cygwin user so I first tried to clone over https using the Cygwin version of Git. After working out that I needed to set a https_proxy environment variable (in the format username:pass@proxy-address:port) I then hit a problem whereby I couldn't specify my github password. Git prompted for a password, but for some reason wasn't accepting the input when I typed it in. Strange.

After pondering this for a while I decided that there is probably a good reason that msysgit is the recommended method for running Git on Windows, so decided to install it. However, our firewall blocks downloading .exe files. I have full admin rights on my PC, but I can't download .exes. It used to be that you could circumvent this check by adding a query string to the end i.e. some.exe?a=0 - but somewhere along the way our clever admins spotted this flaw. Since I couldn't download the .exe installer, I had to find a way to build from scratch.

The first problem was getting hold of the source code. I couldn't use Git to get it, for obvious reasons, so instead I downloaded zip archives from http://repo.or.cz/w/msysgit.git/ and http://repo.or.cz/w/git/mingw/4msysgit.git (see the links in the shortlog section, for example). I unzipped the msysgit code into C:\msysgit and then unzipped the contents of the 4msysgit archive into the C:\msysgit\git directory. Building and installing was then a simple case of opening a cmd window in C:\msysgit and running msys.bat.

Then I had to add the following to my Windows path: c:\msysgit\bin;C:\msysgit\mingw\bin

I also created a quick launch shortcut with the command: /share/msysGit/add-shortcut.tcl QuickLaunch

Running git --version confirmed that git was installed correctly. I was then able to clone my private repository by:
  • Setting global git config http.sslverify = false
  • Setting the https_proxy variable
  • Running: git clone https://username@github.com/me/myrepo.git myrepo
Now that I know I can clone a private repository, and push changes to it, I am happy to use github for all my future development.

Credit Where Credit is Due...
This article proved very useful in working out what I had to do.

Friday, 23 April 2010

Sponge: For When You're Using Soap

The Problem
At my current job we have a suite of applications that all have the same basic architecture:
  • A Java web-start client talking to...
  • A server side deployed in JBoss which talks to...
  • Back-end .NET web-services
The .NET services front the core systems that the Java application connects to. The Java application is provided to customers who want to do business with us.

Both the Java side and the .NET side have a problem when it comes to keeping a development environment up and running. The Java guys don't really want to have to run the .NET web-service on their machines, and the .NET guys don't really want to have to run JBoss. What tends to happen is that the Java team try to connect to a shared .NET service which is either:
  • Borked or...
  • Incompatible with the version of the code they are developing
Cue lots of wasted time for all involved as people stop that they are doing to fix the shared service.

A Workaround
I wanted to find a way to be able to run up a development environment on my PC without having to rely on the back-end .NET service. I did this with a combination of:
I used SoapTrace to record some Soap exchanges, and plugged the responses into some mock web-services in SoapUI. This worked but it was a total pain in the ass to set up. It took ages to record all the Soap exchanges I needed, then I had to fiddle around in SoapUI to generate the responses, then configure SoapUI to return different responses for different types of request.

What I really wanted was a way to be able to record a Soap session and, at the flick of a switch, use the recorded responses to mock the web-service calls in my development environment.

Enter Sponge
And so Sponge was born. Sponge has the following features:
  • It can act as a Soap router, sitting between the Soap client and the Soap service.
  • Soap exchanges can be saved, viewed, edited etc.
  • Entire Soap sessions can be stored and used to mock out web-service calls.
  • The user can choose which response to return for a particular request type at the click of a button.
  • Previously saved Soap requests can be re-sent to the service.
  • It has a plugin mechanism to enable requests or responses to be dynamically transformed before sending / after receiving.
Sponge is the tool that I couldn't find that allowed me to work the way I wanted to work.  On the Java side, once I have a session recorded I no longer need to rely on the .NET web-service. And on the .NET side, given a session they no longer need to run the Java side of the application in order to generate requests.

The Technology
I had 2 goals when writing Sponge:
  1. Create a tool to help me in my day to day development.
  2. Learn Clojure.
The meat of Sponge is implemented in Clojure, with a thin(ish) GUI layer written in Java (using the Netbeans GUI builder).

Screenshot
This screenshot shows the key features:

  1. The top half of the screen shows some Soap exchanges.
  2. The bottom half shows the Soap request (on the left) and response (on the right) for the currently highlighted exchange.
  3. The response is in edit mode. By double clicking on the text panel it is possible to edit the xml.
  4. The 3rd exchange is highlighed in green, and has 'R' in the info column. This indicates that this row will be replayed i.e. if any request comes in that matches the Namespace, URL and Soap method of the replay row, then that response will be returned.
  5. The Replays column shows the number of times that response has been replayed.
Interested?
You can download the latest version of Sponge from http://github.com/NeillAlexander/sponge. It is licensed under the Eclipse Public License, and all the source code is available in Github. I don't intend to do any more development at this point in time. It does what I need it to do.

Installation instructions are included in the distribution, and there is also some basic integrated help which describes how to use it.

Feedback
If you make use of this, let me know what you think. Leave a comment here, or raise an issue on Github, or whatever. I'd love to know that someone else finds this useful.

Sunday, 4 April 2010

Goodbye iPhone, Hello Android

"Whooh! It's weird not smoking, I'll tell you that. But I'm glad I quit y'know because I felt like to be honest with you I was on the wrong side of the war against drugs, because I smoked cigarettes and gave the tobacco lobbyists and the tobacco growers any more fuckin' money for the poison they spread, and advertise all over our world..." (Bill Hicks, Revelations)
When Apple decided to sue HTC, I felt like I was on the wrong side. So this week I bought a HTC Desire.

My iPhone now lives in a drawer.