Tuesday, September 25, 2007

Random Newbie Stuff

This post is strictly for people who have just entered into the software profession. I have jotted down some random things that I have faced myself or seen other people do wrong here. The solutions may seem to be pure common sense or banal, but I take that risk of being obvious because I know a lot of people who lack common-sense.

When I was coding in Fortran and C just to get something working, first days as a programmer, I never bothered about anything. I just wanted to get something done, by hook or by crook. Then, after joining a formal course on Computers, I had this notion of a good programmer being someone who spews out code which works on the first go. No errors, compiler or otherwise. Just works. Now, when I recollect what I used to think in those days, I almost feel its so lame that I shouldn't admit to it. But then, you learn soon after shooting yourself in the foot enough number of times that its just not worth it. You have to start coding and face the problems as they come. What I have found out over the years is that it is not only insane to try to write error-free code without actually coding, but also totally unproductive! I agree that human brain is a marvelous thing, but why waste it on stuff which a computer is kick-ass in doing. Don't sweat a lot about syntax and stuff. You anyway have Google, if nothing else. I suggest you, of course, learn the syntax and stuff, but there is no need to memorize it, like a lot of people I know try to do. You will remember stuff if they are important enough. Others, you can always look them up.

A lot of people like to talk about high level, abstract, potential "solution" to a lot of problems. They think and analyze for a long time and fear getting their hands wet. I know I used to do it and I know people who still do. All I can say is that its sheer "balls". You cannot just talk about problems. You have to get down to code at sometime and actually solve them.

Something I have found out is people don't learn the right things at the right time. If you are learning Java, there are reasons why you should, I would suggest you start from the command line and go through the Java classpath hell before you start doing stuff in an IDE like Eclipse or IntelliJ. You need to know how things work under the covers, irrespective of what it is that you are learning.

Something that boggles people down is the size of a code base, either when they join a project middle way or when they have to understand how something works. One thing you need to understand is that it is written in a language, I assume, that you understand. Just think of it as a novel or a text book that you need to read. The chances are you cant digest everything that is there in a day or even in a week. Just like reading a book, you need to start from the beginning, logical i.e., and then move deep into the code base. You will surely finish it, sooner or later! Just like a book, some code appeals to you and some don't. Its up to to you if you really want to work with some code or not. You can always do this. Or bail out.

A few things that I can think of which are done blatantly wrong and which can be fixed easily, with some mental effort.

Tuesday, September 18, 2007

Redesign the World

As a professional programmer, one of the things I constantly crib about is the fact that NOTHING fits my current requirements. No single tool, no open source library, no neat application, no nothing. I just get frustrated. Something that I want is automation. I don't want to be bothered with repeating something more than twice. I get all pissed because I have to do it. If its repetitive a computer got to do it. Why in the hell would I want to waste my time and effort??

Sometime back we were using Antlr as a Parser on our project. Given the simplicity of our grammar, we thought Antlr would be a perfect fit. But turns out, it was not! It was so painful that we replaced it with a hand written parser in about a day. With complete test coverage.

Given this attitude of "Redesign the one tends to redo a whole lot of things. The most important thing to keep in mind when you want to replace something that already exists and is very irritating is that it solves the problem. Doesn't matter if its not done well, if its slow etc etc. Because the chances are, by the time you reach where that tool/library is, you would have inadvertently ended up making some compromises or hacks every now and then yourself. Unless of course, there is a very strong reason such as the project productivity/velocity is getting screwed etc. to replace the tool.

What's more important is to be wary of what I call the "Quick-Win" syndrome. When you want to replace, lets say, Cruise Control or Selenium RC, its easy to get carried away thinking, "Its just a freaking while loop" and start off. The chances are you will get the basics quiet right, in fact may be better. But there are so many corner cases and issues that something like CC takes care of which were shielded from you that you just wont be able to "hack it" away to glory in a weekend. You will get a quick win in the sense that it works perfectly well in the happy path and feels Oh-so-close-now to the solution that you wont be prepared to give up until the contrived corner cases start biting you. But its just normal that you think its just one of those things or lets just hack this one away quickly which ends up in something "enterprise" like Selenium RC.

All I am saying is, when you want to replace something once and for all, don't think of it as a weekend hackday thing. Especially if its something big. So, take your time and make some wise decisions before starting off.

Friday, August 3, 2007

Mundane Problems

I have an IOC container with some beans which are listeners. I have a POJO which is in itself a listener to some events. I want to notify my beans when the POJO gets notified of some event. But, because of some intricacies in how my container works into which I won't go, I have to get the list of all beans only at the time when my POJO gets notified. Kapeesh?

Well now the problem is I can hack my way out of this by passing an instance of the IOC container to my listener which will then get a list of all the listener beans in it and notify it away to glory. But then, my POJO now needs to know about an IOC! Damn. So, I won't want to do this. This is how we solved it:

We created an interface which provides the listener beans to anyone who wants to notify them. Then injected this interface to the POJO. This is how it looked:


public interface BeanListenerProvider {

List getBeanListeners();

}

public class POJO implements SomeListener {

public POJO(BeanListenerProvider listenerProvider) {
this.listenerProvider = listenerProvider;
}

public void getNotified(SomeEvent event) {
//Do Anything...
foreach (BeanListener listener : listenerProvider.getBeanListeners()) {
listener.notify(new AnotherEvent());
}
}
//Whatever follows...
}


The good thing about this is that I now have the POJO decoupled from my container. This may be a rookie thing to do but it is easily lost when you are working on a Friday afternoon after working a lot with Eclipse code base. This led to an interesting conversation with Hakan, my teammate, about being a pragmatic coder as against being an idealist coder.

A lot of problems are mundane. Its only what you do to solve them in a clean way is going to make your work interesting. A clean code indeed gives one a kind of satisfaction which nothing can beat. OK, may be sex, but that's about it.

Friday, July 27, 2007

Weekly Review - "Next"

I am late by a year. Sorry about that. Apparently, I was wrong when I said this. "Next", the recent Michael Crichton's book, was a complete waste of my time. For one thing, I just dint get what was Crichton's point. OK, so, the chimp talks. OK, so, the parrot talks. OK, so, something weird has happened to some turtles. OK, so, ah, wait a minute. What? Are you just repeating stuff or, ah, FUCK IT. It was really not worth reading it. I hope Micheal Crichton starts writing in his usual self, or else it will be about time I stopped reading his new books.

Current Work Pattern

Finally! I got the much longed for time when one can ramble on the net for random people to see. I mean you people. So, lets get on with it.

These days I have been working a lot. By that I don't mean I am working like Abhi, where you just work for the heck of it and are always bitching about it. I am enjoying a lot at work these days. I reach by about 10.30 in the morning. Break for lunch for about 25 minutes. Then work till 7. Play Unreal Tournament till 8. Then leave and come back by 9. For me, those are long hours.

Thing is, I am amidst some really kick ass people with loads of experience and exposure. My team has only 5 people, 3 other developers and a QA. All with at least 6 years experience. I am working with him, him and him, all developers. Some of the more geeky-cool people at work and incidentally in my project. Especially, Hakan is one funny person and is a very and I mean very pragmatic person. I just love all the discussions, technical or otherwise I have with these people. All the vehement talking in TGIF is not to be forgotten. Good for me.

On an other note, one of the things I was thinking about lately was, "Is technology a means to an end or is it an end in itself?" A very philosophical question indeed. And I am sure a lot of people at my work have a ready answer, An end in itself. But some of the more introspective ones may say, "Hmmm, depends." That is exactly the answer I get from a lot of people. They just don't want to commit to a side. Only a few people know why they shouldn't be taking a side. This is indeed something that can potentially lead to a long discussion. Can't wait.

Discussions till now: Why should Earth be Flat, Why Shouldn't Earth be flat(Discussed after about 45 minutes of rigorous drawings of flat earth on our story wall!), Is it sensible to have a fear of Aliens, Education vs. Creativity, Intelligence - Fucked if I know what it meant, Genomes and People are stupid.

Monday, June 4, 2007

Code Poetry

When you listen to good music, anything that you perceive is soothing or whatever qualifies music as good to you, you will feel a sense of satisfaction. Even though the music itself is not yours, you can always enjoy it. Ever read a piece of article which is crisp, to the point and yet drives the point in such an affirmative way that you are just happy that there are people who write without bull-shitting? Then there are the sculptures, the paintings and a whole lot of other arts which require an artist to create them but even more, people who appreciate the art itself. I am going to write about a form of art which is lost among a lot of people. The art of writing code, the cosmetics of it rather. Some of the key things to keep in mind if you want to write code that appears like poetry:

* One thing I think is the key to art is that there should be nothing redundant in the your work. It kills the genius behind the art itself. In the same way, there is no place for something which has no purpose in your code. Get rid of those variables and fields which you have because you think they may be useful in the future. Get rid of private/helper methods which are not used anymore. They are like random noise in a symphony.

* Claustrophobia is not something that only humans suffer from. You can't expect to write "The Prey" by Michael Crichton in 3 pages and expect people to read the whole thing. At the same time, I won't read a 10,000 page version of "The Prey" either. I enjoyed reading the 400-odd paged version thoroughly. The content mattered only after the spacing was properly. So, keep in mind to leave spaces as required by the conventions of the language that you are using. Like a space after an "if" and before the start of the parenthesis of the condition in Java, etc. When you write code, don't be prodigal in leaving white spaces and empty lines. They don't add value. They are a distraction. More often than not, people wonder as to why there is a new line and if they missed some logical separation marked by the demarcation. Follow the conventions all the time and be bold only when the situation calls for "dire" measures, and even that only when it comes to leaving a new line.

* Don't initialize local variables on one line and use it in the next line alone and nowhere else. You don't need such variables. For example:

int length = someList.size();
doSomething(length);

Here, there is no need for you to use 'length'. In fact, I would argue that the intent is much clearer when you write something like:

doSomething(someList.size());

Here you know, without an extra level on indirection that you are "doing something" with the size of the list. Traditionally, having a lot of variables was advised because function calls were very costly. But there is such an advancement in processors and compilers that there is virtually no difference between using a variable and a getter method of the variable. Given this, I would write something like this:

foreach(String name : getNames()) {
//whatever
}

This is a nice way to write "for each" statements without using local variables for the lists/arrays and you will appreciate it once you start using it.

* If you are programming, say in Java, make sure you choose an order in which you want to import stuff, so that it is consistent over the whole of your project. This keeps things neatly. For example, I would have all the bundled java classes be imported first. Then other stuff which are, say, javax stuff. Then I would import stuff which are from my project. This way when I, say, create a patch between my older version of a file and a newer version, I can be sure that if there is a change in the import, its because of a change in the code that affected it and not the order in which stuff are imported. In fact, I think this is a really important code cosmetic if you are using code versioning.

* Try avoiding the use of comments for private methods and variables and instead use a name which suggests what it does. The use of a good name is something that is emphasized the most by almost everyone but is something which is either not leveraged or abused beyond any use. Don't keep a constraint on how long the name should be. At the same time avoid using articles like 'a' and 'the' and try making the method sound like a sentence when it is read with the argument that is sent to it.

Most of the stuff here are in fact built into IDEs for the language you use. The options to do these may be obscure or obvious, based on the quality of the IDE itself. Its important to use them to write clean code.

These are some of the things that I think which makes a code appear clean and pure, like an art. I have seen some seasoned OO programmers who use these rules and many others and just to see them spew the code out is like watching someone paint. And the code itself reads like poetry.

Friday, June 1, 2007

Hacking

I know the media has hyped up the word "Hack" and "Hacker" so much and so bad that the true meaning of the words are lost among the masses. But what really ticks me off is that even a lot of people in the industry think I "broke" into a website or some network where I am not supposed to go and got my work done when I say, "I hacked my way around this stubborn problem". Illegally. Yeah, right, if I were a "Black Hat" I wouldn't dare write stuff with my identity so blatantly given away!

So, here's what Hacking means - HACK
And here's what Hacker means - HACKER
And the actual word which stands for "hacking" as people conceive is - CRACKER

I hope this makes a difference. Thank You.

Tuesday, May 29, 2007

On the Lot!

This new reality show on Star World, is just amazing. It has everything that a movie buff would want to watch. This show is about selecting the best director for the $1 million contract with DreamWorks. It somewhat resembles The Apprentice but it's nothing like it.

The show started off its first episode with 50 wannabe directors selected of the 12000 lot. These are selected from all over the world, not just US. They were asked to pitch a story based on the logline given to them. Some pitches were so good that the audience actually lived through them. Each episode tests for the directing skills in different areas like comedy, horror etc.

Steven Speilberg and Mark Brunett (Survivor, The Apprentice) have produced it. Distinguished directors Brett Ratner (X-Men), Carie Fisher (Star Wars) and Garry Marshall (Pretty Woman) are the judges. They give brilliant reviews unlike The Apprentice trio who just focus on blasting and searching a scape goat. Moreover, you don't have to see the contestants fighting with each other selling a Donald Duck sticker'd water bottle. There are no made up fights or fake emotions either. I mean, on Apprentice, a guy irritates his team mates by sleeping all the time, while on a particular task and don't get eliminated. In the next episode, he is an amazing leader and the previous manager will be acting dumb and eventually does a lousy job. Finally, one of these would end up being the winner and the judge in the next season.

None of those crap are there on this show. You can watch it at 10pm Tuesday on Star World in India.

Thursday, May 24, 2007

Me and ThoughtWorks.

Yesterday, I had been to ThoughtWorks (You might want to click on this link! I don't think that it's their official website.) That place was just incredible. It was a fusion of say, a design firm and a lot of geeks workin in a software company. Right from ambience to crowd, everything was good. They have everything in their pantry that my current office lacks. Literally everything! The lunch out there wasn't all that great but then again, at least they have free food, unlike some places, where you have no food at all!

So, why did I go there? I had an interview. As I said, I loved everything about that place but my interview. It was disastrous. I stammered, fumbled and was not confident while answering, I went blank, like the whole time. All in all, I blew it.

Initially, they started asking questions about the concepts that I had used in my final year project. Later on, as the interview progressed, they tested my knowledge in basic Computer Science concepts. In the end, they probably would have asked me about my hobbies etc etc, but I dint make it to the end. It was one of the best interview's that I have attended. The fatal mistake I did was that I lead the interview exactly towards the concepts I barely knew.

In the end, HR spoke to me well, helping me figure out what went wrong. I had this sentence going on, in my mind, which a classmate of mine had said seriously in college. "Given the opportunity, time and resources, I'll prove myself!".

I was overwhelmed with my yesterday's experience. If you care about your code, you should try it too. Btw Abhishek and Chethan have got calls from ThoughtWorks. Hope they get through and give us DIFFERENT treats :)

"I learnt something yesterday!" (Like kayle from Southpark) You should always pick your company based on work and not pay. (Yea Yea! I know that you already know it). Anyways, so I decided not to apply for any other company but (thoughtworks and few more!)

Tuesday, May 22, 2007

Weekly Review - The State of Fear

I know I am late by about 2 years to write this, but what the hell?

If you have read Crichton's Congo, Sphere or Timeline you will definitely be disappointed of this book. Micheal Crichton's novel the State of Fear is, well, almost there. It is not exactly your kick-ass-sci-fi-action-and-what-not Michael Crichton novel, not completely. It is somewhat there. For example, the novel is too much of a science journal than a novel, which is fine if there was just as much action too. At the end of the day, if I wanted to know about Global Warming, or the lack of it, I would go read the journals myself online. Apart from that, the book is an OK read. There is no Levine or Malcolm or Marek or Harry in this book, as in no character that is worth remembering. A very seemingly annoying pedantic government agent who always speaks politically correct is the only striking character. Apart from that, the characters are mundane.

If you are a hardcore Crichton fan, you wouldn't mind reading this book. Otherwise, don't judge the author just from this one book. I am sure this is just an "one off" book that he wrote!

Thursday, May 17, 2007

LIG Musings

I somehow found more free time than I usually get at office yesterday and today. So, I was surfing for some blogs and reading stuff about LIG. Then I realized that of lot of people write for an audience and try to be "politically correct" and a few others are offensive for the sake of it. I, for one, write whatever I think is right, without trying to be generously obscene, at the same time not trying to censor myself when I think using a fuck here and an asshole there whenever I think its appropriate. Now, coming to what I want to say here, is it a necessity for you to be diplomatic in your opinions and liberal in your thinking if you want to be heard? This made me write this.

For one, I am more conservative than liberal and oriented towards the right.

And it is true that news channels, especially NDTV and the likes are laureling pseudo-liberalism, for that is what it is, so much that people actually hesitate to express their opinions any more, for the fear of being considered intolerant. At least the ones I have seen speaking are. And of course, everything is a "national catastrophe" these days. And the things that are actually one are a political taboo to be mentioned. Idiots. Hippocrates.

On a different note, do you like nude paintings? Would you gift one to your girl friend/boy friend's mother?

Thursday, May 10, 2007

Another Number On The Wall

I used to work for a CMM level 5 company. That is to say I have been through hell and more. A lot of people I talk to believe that the off shore model of development survives on the number of people/resources that is at a company's disposal. Though, it is absolutely true when it comes to a lot of big shot service providers in India, I don't think services/consulting software companies are just that, a herding shepherd collecting sheep. It is much more than that. And people have a tough time comprehending why I say "Fuck CMM" because they are made to believe that you get your ISO certification, your CMM & PCMM certification and a business model following the Infosys and you are all game for a software company. Hell, just working at one of these places will make parents of girls virtually drool and ask you to marry their daughters. I don't have a problem with that, however.

By being a CMM level 5 company, a company follows a set of processes. Everything is process-driven and person independent. So, for a big shot IT company in India, more often than not, each person joining in is more of a head count increase rather than a value add. They aren't looking at heroes who can do a lot things on their own, rather people who do what they are told and do it well. So, your ability to do same things repeatedly without thinking is what counts and not, say, your ability to use diophantine equations to make your computer work in parallel universes to solve the Traveling Salesman Problem.

My point is as long as you don't mind the fact that you are just a number in a SAP software, another brick in the wall, just someone who is, by definition, "replaceable" by someone, anyone, else then you can continue what you are doing. Otherwise, its high time you had a good contemplative look at your job and say, "Fuck CMM" and move on.

Wednesday, May 9, 2007

Abhi in Yelahanka!

Sheikh Hasina is in UK.
.....
.....
After Many Many Days.....
.....
.....
Sheikh Hasina Back to Dhaka.
Abhi is in Yelahanka.

Software Delivered and Open Source??

After delaying by 2 months, I finally "delivered" the software I had promised to Rollwell. They will be running the Inventory Management System (IMS) soon. It was awesome being a BA (Business Analyst). I got to act all doophusy and make bimbo comments such as "Second combo box gets populated based on first combo box?? Radical" and the like. However, after fire fighting till 3 am and then doing UAT during breaks in the office, I delivered a very stable and "does-what-it-is-supposed-to" IMS. The customer was really happy. He was blown away by the simple yet clean UI, which Swaroop had a little and my brother had a lot to do with.

While I was explaining how we have used all open source tools which are all legal and have free licenses, the customer was shocked. He asked, "But Pavan, if you have used Open Source, anyone from the Internet can access my data!" Apparently the concept of Open Source is quiet well known these days. I am sure people think, "We have 2 words, "Open" and "Source". I mean, how difficult is it?" Go figure!

All in all, it was a job well done. Next time around, I plan to be the "short tempered cynical dev". Wish me luck.

Saturday, April 28, 2007

Education for the Real World, Really

I haven't been able to write any blogs these days, because I've been busy studying for Certification exams from Sun microsystems. And I plan to write many many more of these, from vendors like Oracle, SeeBeyond, IBM, LOMA (domain certifications) and finally Microsoft. The motivation for writing them is to get such a huge stack of vendor certifications to go with my resume, no one should be able to see the engineering degree. Things went really wrong for four years with that type of (irrelevant) education.

This is the kind of education that I really enjoy. It's directly relevant to the real world, unlike most of what they taught in engineering. It's mostly multiple choice questions, or actual programming assignments. Plus, no one has to go through the horrendous ordeal of reading my handwriting.

I'm enjoying this a lot, it feels just like the good part of college life. Waking up on the day of the exam, thinking "damn, I got up four hours late. Stupid alarm clock...", realizing that I haven't completed even half of the original "preparation plan", riding to the exam center thinking "I'm surely going to fail", waiting for your turn with nervous anticipation and actually passing in the end.

I strongly feel that the whole of education should be restructured this way, starting with the engineering courses. What do you say?

Tuesday, April 24, 2007

What do you think of the outcome of this World Cup?

Who do you think will win 2007 Cricket World Cup?
Australia, of course
New Zealand
Sri Lanka
South Africa
India
Pakistan
Bangaladesh
  
pollcode.com free polls


Wo do you think, will play the best in the finals?
Shane Bond
Fleming
Styris
Jayasurya
Murali
Sangakkara
Ponting
Hayden
Gilchrist
Smith
Gibbs
de Villiers
  
pollcode.com free polls

Tuesday, April 10, 2007

Object Bootcamp - Place where I learnt things

Since we talk about our work place and all here, here goes nothing.

I switched jobs and now work for a Software Consultancy. It is a kick ass place to be. The culture, the people, the technology. O! I am love with the place. Since I joined newly and I barely have any experience, I had to under go a training called an "Object bootcamp". It is the best thing. EVER! Here's how it works.

The objective of the bootcamp is to teach freshers how to do Object Oriented Design - the agile way. It started off with a brief 20 min discussion on what is OO, what are the concepts in it and the language which we were to use, Java. In my previous company I had a 30 days training on the same! Pfft. What followed for the next 4 days was pure bliss.

We followed Test Driven Ping Pong Pair Program. Pair Programming means 2 people work on the same computer, one person types or drives and the other person reviews, thinks, suggests etc. Test driven programming means, even before we write actual production code, we write a unit test for it and then write production code which makes the test pass. Ping Pong programming means one person writes a test and the other person makes it pass. Then he writes a test and the first person makes it pass and the cycle continues.

We were given different problems which were almost like actual customer problems. Each problem is split up into a number of stories. Each story represents a requirement. We follow 5+15 minute cycles or iterations - 5 minutes for deciding on the necessary classes, their jobs and the first test that we would write and the 15 minutes are for implementing the same in the TDD ping pong way. Oh, and we have to switch pairs every third story. So, we cannot pair with the same person for more than 2 stories. Meaning your code base keeps changing every now and then. (This is where having tests help because if you make a change you can just run all the tests and be sure you dint break anything which the other person already had running.)

The first 2 days were about basic design concepts. Aggregation, Delegation and Inheritance. When to use what? How to decouple classes? How to get tests passing withing 15 minutes etc. The remaining 2 days were about design patterns - How to identify the need to use a pattern, some common patterns, refactoring into a design patter etc.

All in all, it was a great learning experience for me. Given the sort of teaching I was exposed to at my college and also at my previous employer, I always thought the faculty would be shady no matter where you. Boy, was I proved wrong.

On a finishing note: We came across an interesting situation where we had a method in a base class which was returning an instance of one of its derived classes. Is this a good thing? What do you think?

Monday, April 9, 2007

Yet Another Opinion Seeking Blog

Given a choice between money and power, what would you choose? Choose under the premise that they are mutually exclusive. Don't start off with how valid that assumption is etc.

Good Reads

Check out Goodreads. You can find good reviews on books there. You can also give ratings of your own and store the books that you would want to read later.

If you are signing up then make sure that you don't send invite to all your friends in your address book. You can (should) skip that step.

Friday, April 6, 2007

Movie Review: Namastey London


It's a must watch. I say, go watch it in PVR; you won't get that feeling if you just watch it on a DVD. Yes, that's the exact feeling that you get when you hear Sudhi sing. The director of this movie has been extremely diligent in picking up scenes to convey his confusion.

After watching the movie, I was compelled to read the reviews. I found this ,totally misleading review.
Well it's true that this movie is not like the usual romantic ones, but it is like the usual flop ones. It is very very prosaic till Akshay Kumar's entry, which is after 42min:54 sec and after that it continues to be so.

The film revolves around the story of a London bred girl of Indian origin. It's about how she wants to marry a man of British origin and how she ends up in India marrying an Indian groom. At the start of the movie, too many issues are presented and throughout the movie it's not clear as to what issue the director is addressing.

Watch out for Katrina's knee length short skirt scenes including the controversial one at Ajmer dargah. The funniest part of the movie is the acting of side actors, like Katrins's mother, Imran's parents etc. You can include even Katrina's acting to that list.

I'll give it 1, no not out of 5, out of 10. That 1 would be for Katrina Kaif. Again, not for her acting.