Scott Clee's posts

C you again

Wednesday, April 7th, 2010

I was on a conference call today and someone mentioned that C has regained its place as the industry’s most popular programming language. I couldn’t believe it, after all Java has ruled the #1 spot for the last four years.

A quick check on the TIOBE index showed this to be true:

April 2010 Language League

The explanation they give is not that C is growing but that Java is declining. So what does this mean for the industry? Is Java dying? Is there another contender for the top spot gradually working its way up the ladder?

The one thing that stands out is that C is a good language to know. It’s been around a while and it’s not going anywhere in a hurry. I wonder if they’re still teaching it at college and university :)

Communicating in coffee

Friday, November 20th, 2009

I was looking for a quick and simple way of passing a Java object between two Java programs with a wire connection between.

My first thought was object serialization. The problem with this mechanism is that it’s very brittle (change an object on one side and not the other and it goes bang!!). Also, it only really works if you have control of the JVM levels on either side. Which in this case I did, but if I was to share the code with others then they might not be in the same position.

I next considered what XML utilities were packed with the latest JVMs. This led me to JAXB. It seemed an ideal solution. Though it did imply that I either had to start from some XSD, or I had to correctly annotate the classes that I wanted to encode. This seemed a bit more overhead than what I was after.

Obviously there are other solutions… Web Services, 3rd party XML / JSON tools. But again, the consideration around overhead and also the hassle of downloading 3rd party libraries turned me away. After all, I’m just after a quick and simple solution for what is a basic application.

In sMash I would have used some of the great JSON / XML libraries that are supplied out of the box. But I’m not using sMash this time, so I need to look at what’s supplied in the Java class library.

After chatting with a colleague I found the answer.

He recommended I use the java.beans.XMLEncoder & java.beans.XMLDecoder classes. After a bit of fiddling with Input/Output streams I created some utility methods that allow me to make a single call to these services. They encode / decode any Java object that follows the Java Beans specification i.e. it has a zero arguments constructor and getter / setter methods for all variables in the class.

I have pasted the utility methods here for your convenience. Note, because I am running this code on the mainframe I need to explictly request that the bytes be returned in UTF-8 format.

public static String getXMLFromObject(Object object)
{
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
final XMLEncoder            encoder      = new XMLEncoder(outputStream);

String result = null;

encoder.writeObject(object);
encoder.close();

try { result = new String(outputStream.toByteArray(), "UTF-8"); }
catch (UnsupportedEncodingException e) { e.printStackTrace(); }

return result;
}
public static Object getObjectFromXML(String xml)
{
Object result = null;
try
{
final ByteArrayInputStream inputStream = new ByteArrayInputStream(xml.trim().getBytes("UTF-8"));

XMLDecoder decoder = new XMLDecoder(inputStream);

result = decoder.readObject();

decoder.close();
}
catch (UnsupportedEncodingException e) { e.printStackTrace(); }
return result;
}

(apologies for the dodgy formatting. It comes out ok on the editor screen)

Mobile blogging

Saturday, May 23rd, 2009

I’ve been the owner of a HTC Vario III Windows Mobile based phone for over a year now. As time has gone on I’ve found myself doing more and more things via my smart phone. However certain things were very restrictive due to the crummy version of Internet Explorer that comes with Windows Mobile. Obviously I could have paid for Opera, but who wants to do that in the “free” world.

Recently I discovered the Iris Web browser developed by torchmobile.com and it’s been liberating. Now, I don’t disagree that this powerful type of browser interface has been available for other mobile platforms for a while (yes iPhone, you still rock). But for me I can breathe again.

So officially count this as my first post written soley from my dinky little smart phone.

(Slightly different topic: my mobile contract is up soon, shall I go Android?)

ssh it’s oh so quiet

Friday, April 24th, 2009

Ok, we discovered a long time ago that Telnet and FTP happily broadcast your username/password combo in plain text. So then we started using Secure shell (SSH) and Secure copy (SCP). Obviously with these being Linux based technologies there are Windows utilities such as WinSCP.

Everything is great and all are happy. However, it doesn’t stop there…

The clever bods who wrote SSH allow you to pass command line parameters to the remote system that will get executed and the output returned to your local system. Here’s an example:

ssh me@example.com ‘ls’

This will run the ls (list files) command on the remote system and return you the result, though not before prompting you for a password. So, to make the experience even smoother you can perform some magic by swapping digital keys to remove the dependency on passwords. I’ve used the following Web page a bunch of times to set up SSH login without password.

Enjoy this post and the sunny weather :)

Off piste

Friday, February 27th, 2009

Whether it’s known as off piste testing or explorative testing, there seems to be some value in tests that weren’t originally planned but suddenly come to mind. My question is: Should they have been planned in the first place?

I can understand straying off the path slightly when a defect is found and you go on the hunt for bug clusters. I can also appreciate that a person’s understanding of the system under test can grow as they use the code and so might discover additional areas that warrant testing. However, in this case I believe you should resort back to some formal test planning to ensure that an appropriate job is done of testing that area.

So what does that leave for off piste testing?

Obviously this assumes that you’ve done some formal test planning up front. I know this isn’t the case for everybody so I guess I can ask an alternative question int that case: If all your testing is done off piste (i.e. unplanned) then are you comfortable that all risk areas are being covered?

I think my preference would be to have a mixture of both, however I still can’t shake the feeling that off piste testing is simply areas that we’d forgotten to test!

Polishing gold

Friday, February 13th, 2009

It’s not every day that someone takes something that you’ve worked on, gives it a bit of a polish, hands it back to you, and then you go “Wow look at that cool technology!”

Today that happened to me. I was pointed towards a YouTube channel called CICSFluff (interesting name there!). There’s three flashy videos that some professional media company must have created:

CICS Events and WebSphere Business Events providing Insight in to Action

New Face CICS – The CICS Explorer

CICS and WAS Working in Harmony

I promise you this isn’t me marketing a product! I’m just amazed at the magic that can be created with a bit of paint and a voice over :)

Enterprise ready situational applications

Friday, February 6th, 2009

Where I was at: I quickly needed to expose some information. So using my laptop I created some Project Zero services written in Groovy that exposed the information via JSON and some pretty charts. My laptop is constantly in and out of its docking station. So in order to make the information available I cloned the Project Zero setup on a server and scp’d the changes across whenever I made local updates. All was fine.

Where I got to: A colleague then needed to create some additional services based on some of the work I had already done. So they cloned the Project Zero setup to their laptop and scp’d across any changes they made to the server. So as you can imagine, at this point we got into the position where we were occassionally overwriting each others updates on the server image. We needed change management.

Where I’m at today: I brought in Rational Team Concert (RTC) to act as a source code repository and change management environment for the Project Zero code. Into RTC I installed the codehaus Groovy plugin for Eclipse to provide me with Groovy syntax highlighting. A quick ant script later and I was able to deploy all the changes to the server on demand. Not stopping there, I decided that I was also fed up of breaking existing services when I was hacking away at the code. So with RTC being built on Eclipse I knew that JUnit came bundled by default. So, with a quick implementation of HTTP requests using the HttpURLConnection class (which is also bundled with Java) I then had a nice JUnit test suite to (literally) give me the green light before I check any changes in. Not only this, but my colleague then synchronized the changes into their RTC client where it picked up the JUnit tests and was able to run them on their laptop.

Project Zero, Groovy, Rational Team Concert & JUnit – what a combination. (and it puts me in a great position for TDD also!)

Where I’m at tonight: At a bar in Edinburgh, warming up for the big game on Sunday. Come on the reds!!!

Disposable server

Tuesday, February 3rd, 2009

I’ve been writing a hand-on lab for the upcoming Share.org conference and need to supply a source code repository for use in the lab. After a little pondering, the following neat solution came to me:

  1. Boot ubuntu on a laptop using a live-distro CD
  2. Insert a memory stick containing an install script, a cvspserver file and the source to be added to the repository
  3. Run the install script to dynamically install and configure CVS and check-in the source code
  4. Run ifconfig to get the IP address of the laptop and supply this to the lab attendees along with the CVS connection details

The install script (install.sh) contains commands extracted from this page and executes them in turn.

It looks like this:

sudo apt-get install cvs
sudo apt-get install xinetd
sudo cvs -d /var/lib/cvs init
sudo cp cvspserver /etc/xinetd.d/cvspserver
sudo /etc/init.d/xinetd restart
sudo chmod -R a+rw /var/lib/cvs
cd project
cvs -d :pserver:ubuntu@localhost:/var/lib/cvs import -m “Importing my project to CVS repository” . new_project start

I now have a fully configured CVS server that can be disposed of at the end of the lab.

What I learned today

Tuesday, January 20th, 2009

Just some of the things:

  1. As a Test Architect I get asked to review test plans and provide advice/recommendations. Sometimes these can be on topics that I know very little about. Today I grabbed a team member (who was previously a customer) and took him for a tea. Thirty minutes later I walked away knowing that little bit more about the product I work on and discovered additional areas that deserve testing attention. That was a great coffee “break”.
  2. I’ve been asked to provide a code sample for another team. We have buckets of this stuff around, however it was all written with automation in mind. I’ve discovered this does not lend itself to being opened up as easy to read samples. I wonder if there’s a way to meet in the middle and provide useful (automated) samples?

Did anyone else learn anything interesting today?

CICS & PHP – PHP grows up

Thursday, January 8th, 2009

I’ve heard many customers say to me “It ain’t real until it’s in CICS“.

Just before Christmas CICS continued its ongoing mission to support every major business programming language since the beginning of time by announcing that PHP has arrived on CICS.

Why am I writing about this on a test blog? Well, I did some of the preliminary system testing and two guys in my team did a cracking job of the rest. So this is another thing that we (as a wider team) are all proud of.

Go ahead and play, but please direct any problems to the other guys in my team ;)