Loud logs help no one!

As a software developer, we have to be both Michaelangelo and Sherlock Holmes every now and then. Michaelangelo in the sense that every now and then we get the opportunity to create something stunning, something beautiful virtually out of nothingness. Sherlock Holmes because more often than not, things go wrong and we have to go hunting for the clues that will lead us to the perpetrator. Guess which one we get to play more ?

So that raises the question that how can we make debugging easier for ourselves? Since we write the code that breaks down, surely there is a way to ensure that we get something in the log output every now and then to ensure things went smoothly, or otherwise. Hence we developers starting putting random statements into log outputs and helped ensure that system administrators who have to monitor this output day in and day out hate us with the passion of a supernova. Well done lads!!!

So here is my beef. Lets not put every thing in logs. As Holmes points out to Inspector Lestrade in the case of A Study in Scarlet, it would have been much better for the former if the latter had not muddied up the scene with too much superficial information. A case in point is the starting up log output of JBoss. It is horrendously loud, verbose and useless. Most of it is INFO and very little is needed to be debugged. It takes 53 seconds to start, yes 53 seconds and in that 53 seconds Apple’s native terminal might run out of buffer space. And if something goes wrong, then well best of luck with your scrolling abilities.

There is a reason why discretion is the better part of valour, and debugging. Log only that which is critical. Remember, you are not the only one who has to see these logs and perhaps sift through them. System administrators and QA also have to look and sift through them and it does no one good when it is full of rubbish. We do not need to log everything. If someone tells you to err on the side of caution, tell them to bugger off.

Remember, a log output is like the program trying to talk to you. The more appropriate its trumption, the easier it is to understand.

Comments

Unit tests!

In the morning, I had a very interesting discussion with a colleague of mine. He was writing a simple handler which passed an annotation to a calling class about which we knew nothing. All we knew that by passing the annotation, the class did stuff properly. For those fortunate enough to have dealt with objects in python and ruby, behold the Java annotation example:

@Test
public void testSomethingWorks() {
    assertTrue("Eve knows ", alice.secret(), bob.secret());
}

More can be found at Java 1.5 Annotations

The @Test is the annotation, telling the whatever is reading the code that what follows is a JUnit test. Similarly we had an annotation, above a class method and the discussion started. My friend’s argument was  something that only did one thing, and that thing was just an annotation passing to a black box, did not need a equally trivial unit test. Now this test is made harder by absence of any decent mocking frameworks. That is, we could have mocked out the external utility that was a black box and done a fast and simple JUnit test, but not to be.

I asked my friend if he cared when/if the code was changed. On being answered in the affirmative, I asked him whether in that situation, he would like to know by our build light breaking, or by one of our system administrators coming to us and informing us?

Thankfully, that seemed to convince him that a test, whether trivial or not, is needed to cover a piece of code which does something. Any thing. I say thankfully because I really did not have any more arguments up my sleeve, other than my sanctimonious anger :P

Comments

Updating to Snow Leopard!!!

So today, I decided to update to Snow Leopard from Leopard. It took only 45 minutes using the real DVD. I am about to migrate from Microsoft Entourage to Apple Mail. All seems to be OK till I try to compile a LaTEX document.

What the !!!???!!!!

Where did my pdflatex binary go ?? I swear I had it!!! AARGHHHH . So I open a terminal and do

$sudo port install teTeX

but what the hell … now port is giving me errors as it cannot seem to compile some weird library thingy!!! I check my compiler by

$ which gcc

and I get nothing. Back to the DVD to re install XCode to get GCC. Now, I run a script which does database migrations for me to ensure I haven’t lost any data, and TA DA  … I cannot seem to connect to mysql. Almost knowing what I will get, I do the following :

$ which mysql

and once again I get nothing. So I ended up re-installing mysql, macports. But in the end when I tried to re-install LaTEX, I got this …


Error: You cannot install fontconfig for the architecture(s) x86_64 because
Error: its dependency expat only contains the architecture(s) i386.
Error:
Error: Did you upgrade to a new version of Mac OS X? If so, please see
Error:
Error: http://trac.macports.org/wiki/Migration
Error:
Error: Target org.macports.configure returned: incompatible architectures in dependencies
Error: Unable to upgrade port: 1
Error: Unable to execute port: upgrade Xft2 failed
Before reporting a bug, first run the command again with the -d flag to get complete output.

The annoying thing is, I am not on a 64 bit system. At All!

I am off to TextMate to find out if it has a LaTEX bundle somewhere. :(

Comments

Companies should have exchange programs

I honestly believe that companies, whose sole ware is based on technical competence, should have an exchange program. Even as I write it in the darkness of the night, I can hear the howl of people attempting to preserve the in house knowledge against their competitors. I assure you, that is not what I meant. Allow me to quote a local example.

In Melbourne, Australia, there are two well known companies that do not compete with each other, in any way; except for talent. I speak of realestate.com.au and Lonely Planet. What exactly is stopping these two companies exchanging developers so that the skills may be sharpened ? Exchange system administrators so that better ways of disaster recovery may be learnt? After all why not ?

I now can hear people say “Oh! But surely thats what conferences and development/sys-admin meet ups are for.” Yes they serve their purpose in spreading that information. But that information is not lived! If a developer from realestate.com.au paired with one from Lonely Planet while working at Lonely Planet, then the information that he gets there is learned and absorbed much much better. Let the exchange program be fore 6 months or a year! This will stop inter company inertia and promote a very healthy environment.

Think , O companies, of all the smart people that perhaps might not leave out of boredom of doing the same old all the time! Think of all the new tools that the people would bring back knowledge of! Think of all the new talent this would attract to you!

But do you have the guts for it ? Do you ?

Comments

Testing in Java

Mocking is hard in Java. I don’t mean “Hey you, abstract class, GROW UP!!!”.

How do I mock out a unit in Java ? What mocking framework is there to mock it ? Maybe I could use JRuby to mock it out but then, you would hope there is one in Java itself !

I have Sub::Override in Perl, I have RSpec‘s internal mockers, but in Java, I don’t know. JUnit does not provide anything of that sort. *sigh*

Comments (1)