Enums are classes too. Neat

September 29, 2009 Leave a comment

Got this from Effective Java, which I would strongly urge anyone to read before they write production code in Java.

Copied from here

Eg:

public enum Direction {
    NORTH { public Direction getOpposite() { return SOUTH; }},
    EAST { public Direction getOpposite() { return WEST; }},
    SOUTH { public Direction getOpposite() { return NORTH; }},
    WEST { public Direction getOpposite() { return EAST; }};

    public abstract Direction getOpposite();
}

Also possible

public interface Direction {
    public Direction getOpposite();
};

public enum ValidDirection implements Direction {
    NORTH { public Direction getOpposite() { return SOUTH; }},
    EAST { public Direction getOpposite() { return WEST; }},
    SOUTH { public Direction getOpposite() { return NORTH; }},
    WEST { public Direction getOpposite() { return EAST; }};
}

PS: WordPress has changed a LOT over the year!

Categories: Java, Technology Tags: , , ,

Prashanth blogs in Desitech.in

October 12, 2008 1 comment

Prashanth seems to have lots of time these days. Not only does he have time to frequently update his blog, but he’s also started co-authoring desitech.in.He promises to focus on IT in india rather than his usual posts about other men’s wives and romance between diplomats.

Good luck dude!

Categories: Personal Tags:

Things I’ve learnt in the past year at Amazon

September 28, 2008 10 comments

Well, Time seems to fly with one of those out of service mach-3 planes these days. It’s already been more than a year since I tricked Amazon into thinking I know shit. To commemorate this grand event, I thought I’d bring this blog back from coma to post something.

This one year has probably been the best in my life so far. You might think that’s exaggerating, but try throwing in a couple of years of wasted childhood, a rural high school and four years of struggling to pass in college and you’d see my point.

But it’s not just me, ask anyone working for Amazon Chennai and they’d tell you the same thing. The brain power here is astounding. Everyone is a rock star. It’s a warm, fuzzy feeling to know that you’re probably the dumbest person in the crowd.  To really tell you how cool Amazon is, I’ll have to write a 1000-page book with a 100 page appendix on why each character is cool.

But I digress.

Coming back to our headlines today, these are a list of lessons I learnt the hard way (that’s a fancy way to say that I was caught with my pants down). These mistakes were caught by highly trained individuals. Do not attempt to repeat them at home, or anywhere else.

  1. Keep it simple.

    This is the first thing I learnt out of college. You don’t need to spend 4 hours writing code for an optimal implementation if can get a sub-optimal one working in 30 minutes. You will normally have 10 other things to worry about when you’re working on this one. Just get the easiest, right way to completion. Measure. Improve. Repeat as necessary.

  2. Relate every task to the goal

    It’s easy to lose focus on the larger picture when you’re lost in the woods of detail. Here’s a simple solution – Whenever you take any decision, see how it helps you progress in the overall vision.

  3. Always back assumptions with data

    Within Amazon especially, you’ll quickly learn that numbers are your friends. If you’re crazy idea has enough numbers to back it up, you’ll suddenly find that it’s not that crazy anymore.

  4. Never leave your code base worse than what it was

    I’ve seen real war stories based on this one. Even if you can’t improve the code base, try not it add more filth into it. Overtime the percentage of good code will push you to clean up the remaining filth

  5. Test – Code – Test

    I confess. I don’t practice this myself. Well, at least not exactly. It’s usually Code – Test – Code – Test for me. I usually write out simple happy cases and then use test cases to fill in my test cases. Now that I’ve preached it, I’m now forced to practice it.

Other random stuff:

  1. Java is actually a nice language. Thanks to Bloch. (Someone buy me the second edition 😀 )
  2. Zsh is awesome!
  3. Ruby is not bad. But I still like Python for some reason.
  4. Track the time you spend working. You’ll be surprised to find how amazingly inefficient you are.
  5. Planning is important. The plans themselves are useless.
Categories: Amazon, Personal

22 and counting….

“I think grown-ups just act like they know what they’re doing” – Calvin

I can’t agree more. Wait, maybe that’s because I never grew up 😐

Anyways, it’s been fun staying alive for the past 22 years and I hope this body can take the same amount of abuse (if not more) for another good 50 years.

And, a very happy birthday to my classmate Pradeep who’s also celebrating his birthday today.

P.S: Special thanks to JP who had the Calvin quote in this jabber status message

Categories: Personal

Amazon Kindle: Reading will never be the same again

November 19, 2007 24 comments

After more than ten years of revolutionizing the way books are sold, Amazon is all set to revolutionize books themselves. Our new e-book reader, the Amazon Kindle launches today.
Read Jeff’s personal letter at http://www.amazon.com.

I’ve had the privilege of working on this project and it’s been an incredible roller-coaster of a joy ride.

You can get more info from Newsweek’s cover story on the kindle here.

In my opinion, there’s one feature that trumps things in Kindle’s favour. Free Wireless, For Life.
This means two things to me:

  • You only have to pay for the books and Amazon will back it up, store your annotations and bookmarks at our site. You don’t lose your books even if you lose your kindle.
  • Books will *never* be out of stock for the kindle and they arrive the minute you order them.

Oh and did I mention that I worked on this product?

Categories: Technology Tags: , ,

Chennai at 3:11 PM

October 28, 2007 5 comments

Damn, I need a camera.

Oh well, I’ll at least help spread the word

http://www.311pm.com/

This guy is definitely from CEG

October 25, 2007 2 comments

I’ve been following this blog quite a while now. As much as it looks like a spin off from XKCD, his stuff is still good!

I also suspect that he a CEGian. There’s evidence littered over in his articles. especially the last one about practicals.

  • I had to write the algorithm first and get it checked from the prof. My theory on algorithms …. be as ambiguous as possible , use proper and misleading English , and go to a prof who doesn’t know the language.
    Making use of misguided ME lab attendants. check
  • I was going to get a 90+ , and some people who studied all night and put a lot of effort were only going to get 70 or an 80 because of some kutti problem like “segmentation fault”
    Surrounded by studious nerds. check
  • Surrounded by faulty equipment. Check

CEGian for sure!

Categories: College, humour Tags:

Pick of the (last) week

September 23, 2007 Leave a comment

A little late this week. Better late than never I guess 🙂

  1. Chinna Chinna Aasai by A.R.Rahman in Roja. Gets me everytime
  2. Mun Paniya Yuvanshankar raja’s best melody to date. The instrumentation is too good for words.
  3. Thirupathi ezhumala venkatesa by Deva. Ganaa at its simple best! Deva simply rules when it comes to gaana. Maybe it’s because gaana can’t be *inspired* from other songs, if you know what I mean 😉
  4. Hurricane 2000 by the Scorpions. I never liked rock as much until I heard this song.
  5. In my place by Cold Play. Inspite of all the noise, this song still sounds melodious to me 🙂
Categories: Personal Tags:

Social Service

September 20, 2007 Leave a comment

Lisp tutorial
Read this for more info

And no, I haven’t read the book yet 😀

Categories: Technology

Pick of the week

September 14, 2007 Leave a comment

I recently saw Mark Chu-Carroll friday random ten articles and liked the idea. So here’s the Indianized(or rather tamilianized) version for your taking – My Pick of the week! A list of five songs that have fascinated me over the week.

And the winners of the inaugral edition are…

  1. “Maha ganapathim” from Morning Raaga by Amit Heri and Mani Sharma. Vinayak Chathurthi special! The best rendering of the song I’ve heard to date. Suda Ragunathan at her best. I don’t know what happened to the Mani Sharma that composed for this movie. All his other movies seem third rate compared to this one. I almost refused to believe that this was one of his works for a while.
  2. “Yennadi Muniyamma” from Vaathiyar by Imman. One of the few remixed songs that still sound nice! Karthick has done a great job in rendering the song
  3. “Dreaming of you” from the Scrubs OST by The Coral. I still can’t figure out why I like this song so much. I almost feel disappointed that its only about 2 minutes.
  4. “Yentha kuthariyal varuvaan” from Satham Podathey by Yuvanshankar Raja. The movie that marks yuvan’s return to good music. He’s finally back to his old form after a huge pestering pile of noise he’s composed in the recent times. Shreya Goshal’s shines with her ability to set the mood for the song
  5. “Kallori Salaikkul” from Sivapathikaaram by Vidyasagar. Probably the only song about college life that makes sense. I’m still trying to find out who wrote this song.
Categories: Personal Tags: