Posts tagged: Java

Master Jack

Everybody knows the old adage – “Jack of all trades, master of none”. I agree with this. So does the whole open source movement (in general). Thunderbird is a good example of an application that does one thing but does it well. Compare that to the old Mozilla suite that did mail, newsgroups and web browsing and one integrated applications and all the problems that came with that.

At Kraya, we believe in being able to do one thing and one thing well. Ironic since we do so many things. Kraya has become more like an operating platform for building a whole set of tools on top. Similar to running multiple applications on your computer. They all do one thing and one thing well (unless we are talking about something like Microsoft Outlook which does loads of things badly).

Then there is the synergy between the different teams that is sometimes absolutely crucial to the success of some of the projects.

As an organisation, we are a little off the wall and don’t really follow the mainstream. We believe that tools and technologies have a specific space they are meant to fill (yes, including microsoft products). They really have no competition as far as desktop operating systems are concerned for users who are not entirely technically literate. Sure the Apple Mac’s are great (and potentially better than Windows) but they have effectively priced themselves out of the mainstream market.

Linux, while fantastic is just not user friendly enough for the masses. My argument with Microsoft is in it trying to fill gaps with products that just can’t handle it. The Server platform while a good product, is not ideal for the range of circumstances under which it is deployed. Microsoft products are very easy to set up and use which also means that the products are generally very easy to set up wrong as well.

Products like Linux (yes, I am generalising) can be a lot more complex to set up but once it is set up, it can usually run without any issues for years. I have servers & desktops that have not been restarted for years (apart from the odd hardware upgrade / change). This is a testament to the sturdiness of the software.

Microsoft Server software is getting there. I remember the days of NT, when I was responsible for a couple of servers. They had to be restarted every fortnight, without fail before it would just fail to work. It was like clockwork…

Part of the reason why we do so many things is that we are different enough and wish to work with companies who can accomodate our very specific needs and there are very few (none that we felt could do that job as well as we could or better).

This has lead us down the path of setting up teams specialing in each area.

  • Software Engineering (which is split up in several areas as well, Java, PHP, Web, Desktop, Middleware and so on),
  • Systems (again split into multiple areas, Web systems, Office Server Infrastructure, Linux Server, Windows Servers and so on),
  • Technical Support (again, Windows based desktops, Mac based desktops, Linux based desktops, Laptops, Hardware and so on).

Krish has set up a film production company to follow his passion for making films and this will be launching with a splash over the next few weeks / months. We have already won a couple of small projects,  he is working on a few projects of fiction and music videos.

Kraya’s new R&D department is involved in developing 2 products and a third project completely unrelated to software.

So, how are we not the jack of all trades and master of none. Well, we are good at technology and all the other things we do as a coincidence. We are good at getting to understand needs, then going out there and finding all the tools that needs to be put together to solve the problem in the most effective manner.

We are currently in the process of putting together some case studies that can demonstrate this in more details… 😀

Eclipse TPTP on Ubuntu (64bit)

I run ubuntu 64 bit (technically, I run an ubuntu 64bit vserver which I access from ubuntu 32 bit but thats not really relevant).

In the open source world, I expect that all things which are accessible as 32bit are also accessible and 64bit and ubuntu makes it automagic enough that everything just works. Yes, I run into problems with closed source software like Flash Player (recently resolved with flash player 10) and the Java Plugin but that is another story. I use Eclipse and wanted to do some performance analysis and benchmarking to find a bottleneck and installed the TPTP plugin; and ran into a problem. It just didn’t work.

To resolve it, I turned to google… In this instance, it turned out to be a distraction and a red-herring. It lead me in the direction of installing libstdc++2.10-glibc2.2_2.95.4-27_i386.deb which was difficult at best since there was only a 32bit version of the package and that wasn’t even in the standard repository.

In the end, digging deeper, I found that it simply missed the following shared object libstdc++.so.5.

All I had to do was install libstdc++5:

sudo aptitude install libstdc++5

and it worked… 😀

Now, I think that ACServer which Eclipse uses to do TPTP should not link to an outdated library but that is another issue…

Hibernate Domain Model Testing

One of my pet peeves with Hibernate has always been how difficult it was to test it. I want to test the persistence of data, loading the data back and any specific funtionality with the domain model.

Simple? NO! The main problem was the management of the data set. I had set up, in the past fairly interesting classes to test the functionality using reflection, and injecting the data from the classes themselves through the data provider mechanism of TestNG. However, this was error prone and clunky at best. It also made dependency management of data quite cumbersome.

With a view to resolving this, I also looked at DbUnit, unitils and Ejb3Unit. They all did some things that I liked but lacked some functionality that was important.

This led me to write a simple testing infrastructure. The goal was straightforward.

  • I need to be able to define data in a CSV (actually it was seperated by the pipe character |, so PSV) based on entities.
  • The framework should automatically persist the data (and fail on errors)
  • It should test that it can load all that data back
  • It should run as many automated tests on the DOM as possible.

The framework uses the CSV files to read the data for each of the classes (using the excellent SuperCsv library). It needs an Id field for internal reference. As long as the id’s match within the CSV files for the relationships, it will be persisted correctly into the database even when the persisted id’s are different.

For example, I could have a Contact.csv with 5 records (ids 1 through 5) and a Company.csv with 3 records (ids 1 through 3).

The Contact.csv records can map to the id specified in the Company.csv file and when the records get persisted, they will be associated correctly, even if the id’s in the database end up being different.

The framework also looks for the CSV file which has the same name as the class within the location defined within the configuration file. This means that as long as the filename matches the class name, the data loading is automatic.

For simple classes, the Test case is as simple as:

public class CompanyTest extends DOMTest {

public CompanyTest() {
super(Company.class);
}
}

The system (with the help of testNG) is also easily flexible to define object model dependencies. Just override the persist method (which just calls the super.persist) and define the groups to be persist and .persist

in this particular case, it would be

@override

@Test(groups={“persist”, “Company.persist”}

public void persist() {

super.persist();

}

For all dependent classes, I then depend on the Company.persist group (For the ContactTest class for example, since it needs to link to the Company object)

You can specify OneToOne and ManyToOne relationships with just the CSV files – just defining the field name and the id of the object to pull in.

ManyToMany is more complex and requires an interim object to be created within the test section. If the Contact to Company relationship above was ManyToMany, we would create a ContactCompany class with just the two fields – Contact & Company, then create a csv file with three fields, id, Contact, & Company. The framework currently always needs an id field.

You would then need to write a method within the ContactTest or CompanyTest(I use the owning side) to read the CSV file in and pump the data. This process is a little bit complex just now.

With an appropriate amount of test data, you are able to write a test suite that can consistently test your domain model. More importantly, you can configure it to drop the database at the start of each run so that once the tests are complete, you have a database structure and data than can be used for testing of higher level components (EJB/Spring/UI/WebApp)

We currently use this framework to test the domain model as well as distribute a data set for development and testing of the higher tier functionalities.

For the future, there are several additional features this framework needs:

  • It currently needs the setters/getters & constructors to be public. This needs to be FIXED
  • Refactor the ManyToMany Relationship code to make it easier and simpler to test and pump data
  • See if we can ensure that additional tests which data is done within a transaction and rolled back so that the database is left in the “CSV Imported” state on completion of tests
  • Easier Dependency management if possible

This framework is still inside the walls of Kraya, but once the above issues are resolved and it is in a releasable state, it will be published into the open source community. If you are interested in getting a hold of it, email me and I’ll provide you with the latest version.

The easier and quicker it is to test, the more time we can spend on writing code… :-) The higher the coverage of the tests, the more confident you can be of your final product.

To more testing…

Design

Admitting to being a techie – I have often overlooked design. In fact, I have often explained to (potential) clients, using the analogy of a ferrari that we make the engine and everything else work while somebody else makes it look gorgeous. For me, how something looks was largely irrelevant – as long as it worked well.

This explains why, for a long time, I used a fairly bland desktop environment. My desktop itself was just pure black with no wallpaper. Ironically, I would remove all the icons, so it would be pure black and nothing else.

This should have tipped me off on my own desire for design. I thought my desire for black stemmed from the “good old” days of DOS when the screen was black and my love for the linux terminal. As an aside, I used to reconfigure the terminal windows in X to have a white on black background as well – so much better for the eyes. In fact, I still don’t understand why everyone uses a white background for terminals and such like. Paper was white because that was easier. There is really no reason for the screen to be white too…

Now, this was before I bumped into Enlightenment (at this time, it was E16) and to put it bluntly, I was captivated. This this was absolutely gorgeous. Fairly unusable since I was used to GNOME and of course Microsoft Windows. I thoroughly enjoyed this until it became more of a distraction…

I ended up reconfiguring GNOME to be prettier – in fact, I had the Mac OS X theme for a while which I enjoyed.

I then dabbled with E17 and it was absolutely gorgeous – E16 paled in comparison. I ran into a bug where some java applications would jump a few pixels when changing the decorations. This was a real pain since I was developing a Java application at the time. I spent an entire day trying to “fix” this before I realised that it was E17 screwing it up and not my code… :-(

More recently, I thoroughly enjoyed Compiz with the shaky windows and such like – I just always wished that I could actually throw a window and watch the momentum carry it that extra distance.

Nevertheless, this bridged the gap enough to E17 to keep me happy for a little while.

Last week, I dabbled with E17 again to see if the issue with Java was resolved. To my surprise E17 had changed more or less completely – it was bridging the gap between a window manager and a full fledged Desktop environment.

However, there was a problem. It looked like I couldn’t get it back to its old glory of absolutely fantastic graphics without some effort in configuration. One other issue I ran into was that maximising a screen would fill it up across both my monitors. Another thing I could configure but then, it all seemed like too much effort.

E17 gives me the feeling that this is where user interfaces will end up – it automates so many of the things that makes it quicker to do anything. However, it still lacks some of the “basics”.

E17 is a very good example of a UI that tries to conform to what I call the “Invisible Interface” which I will be writing about later.

To bring it all back to now, I found it a hassle to go through all the available themes for WordPress for the Company Blog as well as my own.

I used to take great pleasure in going through dozens or hundreds of themes and picking ones that I liked but after doing it a few times (for Firefox, Thunderbird, my phone, GNOME, GDM and my flat), it gets a bit repetitous.

Now, for a wish. A website that pulls in all the different themes for all over the world for everything. A one-stop-theme shop. Here, I could go through and pick a general theme that I liked and download it for all the applications, my phone(s), mp3 players (and of course, taking it to the next level, all the gadgets at my flat).

That gives my life more uniformity. Perhaps this is something that Designers could take on… Say Hugo Boss, and design something that even matches your clothes, shoes, hair – everything.

That way, you could have your own unique branding… and while you are at it link it into Gravatars and you are also instantly recognisable

Now for the issue of privacy – I think I best leave that for another day.