Friday, January 31, 2014
Monday, January 27, 2014
Chrome adds a sound icon to the browser tab window in which a video (basically sound) is being played.
If the sound is muted, the icon gradually disappears.
Monday, December 30, 2013
While I was doing my investigation to find a suitable Java web framework to use in a personal project, I came across this study done by RebelLabs. They have two comprehensive posts on 8 different frameworks -
- Spring MVC
They have rated these frameworks on different parameters and also on the type of application to build. Search no further, read these two articles:
I finally went ahead with using Play! framework. In some other post, I will talk more about Play. But, for now I did a fun thing. I went to http://www.googlebattle.com and tried to find out how other frameworks fight it out with Play in the Google battle. Following results definitely show that Play framework is picking up faster than any other Java web framework.
Friday, December 20, 2013
Sunday, December 15, 2013
This is an excellent video for all those developers who have never tried their hand at web based applications. Building applications for web is a paradigm shift from building traditional thick clients or server based applications.
The video explains many of the basic technology abstractions over Web such as HTTP, Cookies, Sessions etc.
Monday, September 24, 2012
What's in a name? A rose by any other name would smell as sweet. Everything’s in a name when it comes to code and some other things.
Names shouldn’t spread disinformation.
As in above pasta example or the variable ‘cache_2008_temp’, there is a certain amount of disinformation being spread. If the variable was named ‘a’ and the bottle didn’t have any label, they wouldn’t tempt anyone to make assumptions. Variables which spread disinformation are dangerous because there is a chance that their intention might be deciphered wrongly.
I have picked the following code snippet from a previous post of mine :
localTimeWhenNyNext17HoursOccurs allow you to breeze through the code when you read it. Now let me rewrite the code using bad variable names.
Variable names shouldn’t require a comment to understand them.
In code snippet 3, we see that the variable ‘cache_2008_temp’ has been commented to tell us that it is used to store history or records in 2008. But, what happens to the code where it is used? Anyone who reads the code using that variable is bound to get confused. It destroys the readability of the code because that name makes no sense – it spoils the code story. So, after sometime a developer who maintains that piece of code thinks that no longer is the 2008 history necessary then she might just rename the variable as ‘cache_2009_temp’ and use it to store history of 2009 records. But she might forget to update the comment. As code evolves comments get outdated and hence reliability on comments to understand the code can be dangerous.
So instead of naming the variable in snippet 3 ‘cache_2008_temp’ we could have named it ‘historicRecordsOf2008’ or just ‘recordsIn2008’. Names should convey the intent correctly. Such names bring a clarity to the code. Code cannot achieve simplicity if there isn’t any implicit understanding of names.
A variable name like ‘cache_2008_temp’ is difficult to pronounce and use in discussions. Instead ‘historicRecordsOf2008’ can be easily be used while discussing the code. Use names which you can pronounce and hence can easily use while discussing the code.
To have good names you need to think, think hard. And that takes time. But as Uncle Bob says choosing good names is hard and takes time but saves more time than it takes in future.
Tuesday, September 11, 2012
Ok I understand that the answer to this question is pretty simple. But, I have seen many people faltering in interviews when asked this question.
We have a class with a public delegate and a property which exposes an instance of the delegate.
Now TestEvent is a multicast delegate. We can create an instance of the class Temp and add our method to TestEvent
Similarly some other class might create another instance of Temp and add its own method to TestEvent
And when Temp calls RaiseTestEvent method, all methods added to the multicast delegate TestEvent will be called. Now think about this for a moment. Doesn’t an event do exactly the same thing? Subscribers add their event handlers which get called when the event is raised. So, why do we need events and their fancy syntax? For that you should know that events can be raised only by the class which defines it, unlike the public delegate which can be called from outside the class by using the instance of the class in which it is defined. This is the main functionality of an event, where the class that defines it controls when an event needs to be raised.