This is the punchline for a popular coffee shop chain.
We were just having a cup of coffee (actually ice tea) and since, there were a lot of house flies around, the topic came automatically to how to get rid of them quicky. Ideas poured in, from high speed blowers on the entrances to the repellers to a fantastic technique – get a gun and shoot them all. All being engineers, it just had to come down to optimizing resources so, we thought.. How about using a single bullet, Rajni style, along with, not one but, a bunch of knives forming a binary tree in the air so that the single bullet fired would get cut into halves time and again until suffices the no. of pieces of bullets required to kill all the flies.
Conclusively, we are ready with an algorithm to accomplish cleaning up all the house flies from our premises with a single bullet and with minimum execution time figured out. Just waiting for the flies to be back into the right position they were in when the algo was devised. 🙂
PS – I know this sucks.
It was a fun since the moment I got up. Esp as I knew I was getting together (just like every month) with three of my childhood friends and some of our siblings. As we went through our routine conversations on how someone has grown fat and someone has been looking weird, we planned for a movie and a lunch afterwards in this mall called Pacific which is “Trans Yamuna”. After the fun, we were window shopping (and apparantly shopping) and I suddenly realized that its been 4 months since I last visited a mall last… which is amazing considering that all this time I spent in a metropolitan with more than a couple of malls in the vicinity of my residence.
As soon as I told my friends about this fact, they all discounted this saying “Its not possible man, one couldnt possibly do that living in Delhi unless you just didnt step out of your house the whole time or were really stuck in office” and none of that was true for me. So, I popped a question to all of them – “How many times in the last 6 months have you guys visited our school, playing ground, college, our regular hangouts like CP & Old Delhi, our favorite eating joint etc & all the places we used to regularly go out ?“. And just as I expected, none of them had seen our school or college or the eating joint outside the college for years though a couple of them had visited CP a couple of times in last few months on the way to some other destination but not in the same way as we did during the our college days.
This made me wonder how our lifestyles have changed over time. How the fun of eating a Hot Jalebi in Purrani Dilli and playing football in the lawns of India Gate were replaced by watching a movie in a multiplex and a half-hearted lunch in a food court.
Is it just the age and change in time OR are we failing to understand the actual pleasures of life ?
Hmm… we have seen the TVs, cell phones, music players, CD/DVD players, cameras in the market in the last few years. What next ?
First of all, when I am talking about all this, this is specifically targetted for Indian market. Period.
We have had lot of propagation over convergence but not much of it is visible in Indian market till now. Lets see we do have cell phones which are bluetooth enabled, however, the most guys use the bluetooth for is for connecting to their bluetooth earpiece. Would love to see someone with a bluetooth stereo in his car connected to the cell phone, and taking call in his car on something as simple as honking, without having to talking on his cellphone speaker, mind u. How about a concept when you SMS your home phone which triggers your microwave to heat your food for 3 mins and your washing machine to go another round of washing and drying just when you are about to reach home.
Convergence for me is the next big thing for Indian Consumer Electronics.
Following are just a few tips and tricks around java technologies –
- When writing JDBC code, use PreparedStatement inspite of Statement as far as possible coz of more than one reasons. Its not only precompiled (which means if you are using the same object to fire the query multiple times on the db, its compiles only once and makes execution faster) but also it safeguards you from SQL Injections. To avoid SQL Injections, always used a parameterized query instead of concatenating the parameters to the query string.
- When writing database queries, always prefer joins to in queries. They are more efficient and respond quicker. Also, when firing a SELECT query on IBM DB2, always suffix WITH UR to the query to prevent any locks on the database.
- Whenever invoking a static method, invoke it on the class wherever possible and not on object.
- When designing an application and stuck in deciding where to put a certain method, always go by noun and verb theory (thats what I call it), entities are nouns and operations are verbs. Eg. Accountants transfer salaries, therefore, the operation or method trasferSalary() should be declared in Accountant class. If all the classes dont represent entities, which typically would be the case, then, just see what all data would be involved and which class should have access to it and who all would that class be exposed to and whose responsibility this operation is.
- Avoid using replace method in String class, it has a probability of failing you at some point. Use StringBuffer class instead.
- To get a formatted Date object, use SimpleDateFormat class instead of playing around with the Date string.
- Always have a null check before invoking an operation on an object whenever you are not sure if the object would be available.
- Catching all exceptions where they occur is not always the best way, for example, if there is an operation doesnt return anything, takes a value object and updates a row in the database, if there is an exception occuring due to the value object not being consistent shouldnt be handled in this method but should be thrown back to the calling method.
- When comparing a String object to a String literal for equalness, always use STRING_LITERAL.equals(STRING_OBJ), saves you from a Null check and gives you the same result anyways.
- When computing some value from the data coming from the same row of a database query, prefer computing it in the query itself if a db function is available. Normally, database functions are more efficient than computing in the code later.
Will be back with more now and then.
Ever seen a quick fix turning out to create a chaotic situation, thats called Story of a Side Effect. Happens a lot in maintainence projects when you are looking for a quick fix, inspite of reviews and testing rounds, you still manage to introduce new bugs.
I really feel for a team to prevent any side effects to creep in, testing done by testing team can never be enough. Their skills can make them look for bugs in other scenarios of the same module, however, only a developer exactly knows whether or not there is a shared code between modules and changing anything in one module can lead to affecting what all other modules. On the other hand, due to the mindset of a developers, they only test the code on the same patterns that they wrote it on (dont think many would be able to understand this sentence). The best way to capture side effect, therefore, is to have the developer point out the parts of applications to the testing team that the testing team should surely test thoroughly to get the best out of both skills.
PS – May be I have left some related point untouched in this blog, do make sure to point out that side effect to me.