The 2 Neil Johnsons!

Posted by : Tyler Durden | Saturday, July 23, 2011 | Published in

If you don't know who Neil Johnson is, then you can gladly skip this post....and go on to other things in life....well, if you don't have that...then at least go on to other things on Facebook.....

This Neil dude you used to play for Zimbabwe around 10-14 years back I guess, right around the time I was growing up eating, drinking and sleeping cricket...Good old days!..Sachin going mad over Dam Fleming in Sharjah...that carnage by Sanath in 96 WCup!..dream debuts of 2 future Indian Greats in a Lords test match...and LBNL this Neil Johnson!! Wasn't he something...This guy used to open the batting, bowl the first over and also was a lightning in the field....there was nothing he couldn't do on a cricket field...Too bad that he was playing for Zimbabwe! All of us who used to discuss ONLY cricket in any free time we got...(Cricket Cricket Cricket!)...we found Robin Singh's puking habits a better topic to discuss than 'Trojan War', the English classic.(and trust me...he did that more than once on the field !!!). We all just LOVED this Neil guy! He was the ultimate Cricketer...no disrespect to the Indian Batting "Gods" here..!

Well, what used to happen was, whenever we played cricket...the guys who open the innings will NOT get a chance to bowl and vice versa. And for the others in between, the order used to be reversed....last batsmen will get first bowling...last-but-one will get 2nd over...so on and so forth..! That was actually in the Indian School cricket rule-book! And growing up under those weird rules...seeing this Neil Johnson do the unimaginable (open both the bowling and batting!) just made us his GREATEST fans!.. And during this period...A good fren of mine - Ashwin, and I tried to emulate Neil and guess what....we did the IMPOSSIBLE too. Yes, never before has anybody heard a story of 2 kids (4th Std) open both the bowling and batting for their team! I mean, it was like getting away with MURDER!! What happened was, we both were the best 2 batsmen and bowlers in our little unit, but obviosuly if we opened batting, we can forget about bowling in that match. Even though Ashwin was the captain, he could do very little about it! But it so happened, in one game when we were defending a very low total...He just will not listen to anyone, any threats of complaints to our P.T sir, and bowled the first over and gave me the 2nd! And as fate would have it, we won the match VERY easily...and from then on, every match was like this and no one could argue as we were winning all the matches...It was MAGICAL....But we both knew we were just one loss away from all this being taken away by our jealous and worthless teammates! And I still remember this 2 Neil Johnson period went on for atleast 4 months of that year! But it was one of the best times! Thanks to Neil Johnson who gave us that pretty brilliant idea that we can do both in cricket - even if were 9 year olds !! If he was born in this cricket crazy country, we would have had anothr GOD to pray to everyday :PP.S: The GOD angle is definitely a pun on all the fools out there who keep calling some 'cricketer' a GOD. And once again guys, pleaseeeeeeeee....Its just a GAME :)

Interface - A Real Beauty

Posted by : Tyler Durden | Sunday, May 22, 2011 | Published in

Ever wondered why do we use interfaces in programming. Of course I am talking about the main stream languages - C#, C++, Java etc. Many know all the text book reasons, some are obvious reasons - and some others- we seldom come across practically. The obvious reasons -

  • Easily extendable(meaning a class can implement multiple interfaces etc..).
  • Standard contracts. You have the common methods in the interface. And different Classes can implement the logic in their own way. The client calls the class that is applicable.

It all is beautiful, Agreed. But nonetheless the actual beauty of using an interface lies in the fact that TDD(Test Driven Development) becomes bloody easy. Everything falls nicely into place.

Many developers don't really understand what unit-testing is all about. They write some obviously passing unit tests and that's that. Not much effort really goes into writing good unit-tests. Well, you can't always blame the guy who is coding. There are many hidden implications here.

First of all, if he is writing some new code which is using many other existing classes(utility classes or core business specific classes or anything for that matter), its not always possible to unit-test his new code. Reason - The old classes were written without the "testable" approach in mind. Secondly, if this new code has some Database calls or Web Service calls, then its tricky to write unit tests (or at least that seems to be the myth out in the wild!). So, the guy goes.."Nahh..Forget it. Its hard. Am sure my code works OK. No need to unit-test. Unnecessary effort"

In the first case - you should have followed the TDD approach when you wrote the old classes to begin with. Try to refactor the code into what I call the 'Testable Interface' design.

In the second case - IT IS POSSIBLE. You just have to mock the DB calls and put the web service calls behind an interface. Again Testable Interface Design.

Testable Interface Design:

If you have to write a class to do,

  1. Call a web service and get some output A.
  2. Process that output(some business logic) into an output B.
  3. Write B to the database.

If I ask developers to unit test this, many would write some code which tests the whole process end - end, all the 3 steps. But technically our job is to test ONLY step 2. The web service call is external to your code, so you can't control it. So you shouldn't write a test that depends on the output A. And coming to the Database call, you shouldn't write a test which actually writes stuff into a test database. That writing might fail if there is a bug in the Stored Procedure, which is again not your problem, I mean not your code's problem.

So just test Step 2 - business logic. But how? If you write a test which calls the method, it goes through all the 3 steps. How to manipulate the functionality of that method, so that it only does Step 2. That's where Mocking comes in. The most cutest thing I laid my eyes on since Meg Ryan!

You just have to mock the output of the webservice and the database and just test your business logic. Hmmm sounds nice, but what's mocking. Mocking is nothing but making the objects return what you want. So if you can find a way to make the webservice(obj 1) and the database(obj 2) to return some output, your problem is solved.

First put both the client code that calls the WebService and the code that writes stuff to the database in an INTERFACE.

Implement its logic in a class,

And write your main code like this,(Please click on it to view clearly)

So you basically are allowing the client to pass an implementation of the Interface IExternalCalls in one of the constructors. Hence the client can control the functionality of that interface i.e., the methods which call the WebService and interact with the DB are under your control. FINALLY...Huff..!

So your test code goes something like this (am using the Moq library - very simple to use)

See......Simple eh! :)

Top 10 signs that you are not getting laid anytime soon

Posted by : Tyler Durden | Monday, May 16, 2011 | Published in

1. When you have spent at least 82% of the weekend in a radius of 100 meters from your front door.(Going out for a hair-cur, groceries etc won't count as an outdoor activity)
2. You order a virgin margarita when the girl's having a beer.
3. When your arms are way more healthier than the rest of your body!!!
4. If you keep thinking about why you won't get laid for most part of your day and decide to write a blog about it. Something like this.
5. Even after 4 dates you don't/can't touch him/her other than a handshake or while crossing a busy road.
6. The 1st thing you say to your date after the initial pleasantries falls into the below categories (and/or) similar ones
  • Jayalalitha's election win
  • Dhoni's new bald look
  • Your views on the whereabouts of WikiLeaks founder
7. You take her to Fast and the Furious 5 and act like that's the most coolest movie ever.
8. When you openly make fun of her shopping addiction...they all have it and YOU JUST SHOULDN'T GO THERE...TRUST ME ON THIS.
9. When she catches you staring at her friend's you-know-what.
10. A corollary to the above: When the you-know-what you were staring at belong to her sister.....you can forget the phrase getting laid for a period of 7 months or until her next birthday whichever is the farthest.

Verdict - Peculiar and dumb

Posted by : Tyler Durden | Sunday, April 24, 2011 | Published in


I’ve come across many interesting people in the course of my 22 year old life...till today. Some funny, Some sad, Some cunning, Some helping, Some cool headed, Some “i don’t give a damn” and also Some really really brainy ones. But none more so peculiar or weird than Andy German.

Met him when I was very very young. May be too young to even remember the first time I saw him. He was in the same class as I was. This kid used to sit in the first bench, wore rugged uniform without a tie, but had all the answers that a 9 year old was supposed to know and was every teacher’s pet. I would have swapped places with him any day.....until I really got to know him. This kid was weird. He had his days and when it wasn’t his he was very very different.....I mean not really his usual self. I mean one day, he would give speeches like a roaring Hitler, the next day he would be as silent and shy as a cat. One minute he would look like the saddest kid on the block, and the next he would be the class clown cracking up all his friends. He always had something going on inside that big head of his. Some days he used to brood over something deeply....so deeply he never uttered a word the whole day. And once when I asked him what he was thinking about, he went...”Nothing really, just wanted to see how many people would notice me like this!!”....What!!? Imagine a 9 year old having these things in his head.....This guy had problems!

Anyways I did remain friends with him post school. He went to a good college, graduated ok and did get a job as soon as he passed out. But still he has this weird behavior or the outlook on life...whatever you wanna call it. He never grew up, never matured, I thought whenever I used to talk to him. I once went to him when I was on a real personal low and felt like i could use some little cheering. After 10 minutes I realized what the hell was I doing trying to get some comfort from this guy who half the time was depressed himself. But 10 more minutes into it, I actually forgot about my problem and was already feeling like studying (which is a pretty boring thing to do when you are down). I don’t know what he said that made me feel better, I mean people talk you out of depressed mood and you end up going to some movie or something and slowly get over your problem, but 10 minutes with this guy and I was studying an hour later with a full 100% concentration. And this wasn’t a happy coincidence, as many a time, he was always there for me and has helped me directly or indirectly in many things.

Now I am thinking, OK this guy is pretty mature, has finally grown up and is no more a kid. But guess what, an year later he comes to me feeling low and not really himself. And I ask him, what’s going on. And after an hour of conversation, I find out he is depressed just because he started feeling a guy sitting next to him at work was funnier and wittier than him. My first reaction...So what? BFD... But he just wouldn’t get my point. He has to KNOW that he is more funnier than this 3rd guy. My first conversation-route.....It doesn’t matter if he is more funny than you...didn’t work. So having no other choice, I switched to a more childlike manner. I tried to think of the funny things that he had said and thankfully did recollect some and told them to him. That seemed to make him a bit normal, then went home but was still looking bitter the next day. And a couple of days later he is his usual-self, I mean the not-so-unhappy self. I ask him, what happened? He actually proved to himself he was funnier than this other guy.....by telling a few more jokes at the lunch table and even got a couple of testimonials to certify the fact!.. He could then sleep at night.

An year later when he was again feeling depressed, probably coz he needed proof that he was more intelligent than the guy that sat next to him on the bus on the way back from work. Just guessing J. I just told him to just forget if it was anything like that, it doesn’t matter in the long run. And then he opened up to me. He has been trying that since a long time, but just couldn’t do it. And the only way he can sleep at night is to solve the problem the hard-way...even when he does know it really doesn’t matter. It was sad.

I just worry about him about the day when he will face a situation where he doesn’t have a choice, doesn’t have a way to prove to himself that THING which makes him ok and move on with his life. Coz when he does face it, it’s really possible that this genius will go crazy. Peculiar and I should add immature for having still not grown up.