Tuesday, May 17, 2011

Lets Un-Uncomplicate

The world is a beautiful place if you can see things simply. But once you are in the software it becomes ugly and you start seeing things in a completely different way. I have seen thing happening so may times – that I felt like writing this one out.

Its story time here – so enjoy!

The “Hello! World”

You must have written a “hello world” program in your life. It’s the simplest program that you can write in a programming language . So I will tell you a story with “Hello! World”.

In a software company, “ComplicateSoft” (henceforth called as “CS” – for simplification!), there was a requirement from a customer to write a program which will print “Hello! World”. But as with any customer, there is a catch – they did not know where will it be getting printed or how many times will it be getting printed. So they said the “Archie” of “CS” make something generic. Actually the customer said “make something which will do the job in most cases”, the “Archie” documented it as “generic”.

The Dev-Archie meet

“We will do it the proper way”, said Archie.

Dev guy, “Yeah, makes sense – cool.”

So the dev guy wrote a good old Java class, which has a simple method which prints “Hello! World”.

Dev was happy as he never got a easier project than this. So he even wrote it in TDD.

Archie came along and saw that piece of code and said, “Okay, but that’s not generic enough. Dude, make the string “Hello! World” externalized”.

So the dev guy, did.

Next, Archie said, “Dude we do not know where this will get printed no sys-out. Take a output stream instead!”

Well this should be all. The dev guy did that.

Next, Archie said, “This class is doesn’t have any state so lets make it a Singleton.”

The dev guy thought wow! I will implement a design pattern now on this – cool.

The Archie said, “Now we have to make sure that if someone request this as service over the web, do a WSDL for it and test it with a client.”

Dev guy did that!!!

Now Archie thought about the requirement once more and remembered the phrase, “don’t know how many times will it get printed.”

If it needs to printed multiple times with a distributed file system?

He asked his dev guy a final thing – “Can you make this class support Hadoop map-reduce”

The dev guy ….

The end.

Hope you enjoyed.

1 comment:

Tom Elam said...

Love it, Samik! By the way, do you know about CouchDB views? They use map-reduce.