• Java thread safety with wait/notify.
    Mar 31, 2010

    Something I realized today with Java thread wait/notify mechanism was that when thread A calls wait() on object O and thread B calls notify, thread A does not immediately continue executing, because thread B may still hold the lock, so regardless of calling notify, thread A will have to wait for the lock. So here is example :

  • Why to write test code.
    Mar 24, 2010

    In today's world of test framework availability, we often feel very lazy to write unit test cases. Frameworks like JUnit exist for long time, but very few people actually make full use of it. I am not going to cover technical aspects of JUnit or any similar framework now, but I am shortly going to write about the reasons why test code is necessary from my experience.

  • Starting JPDA in Tomcat 6 in Ubuntu
    Mar 17, 2010

    I needed to debug a tomcat application, and in order to use Eclipse remote debugger I had to start JPDA from tomcat6 from Ubuntu. The default startup script does not have a jpda start parameter, so we have to add one ourselves.

  • Performance Tip : Make Comparators Singleton
    Mar 12, 2010

    In Effective Java 2nd Edition, Joshua Bloch mentions that Comparator objects should be always Singleton in order to avoid unnecessary Object creation (Item 21, Use functions objects to represent strategies). It gave me a thought that not only Comparators should be made singleton, but all function objects.

  • Java Object Design Tip : Make setter return the instance of an object instead of void
    Mar 7, 2010

    We are all taught in the first classes of object-oriented programming to have all instance variables private and assign getters and setters for them. The traditional way of doing this is having getters not to take any parameter and have the return type as the type of the instance variable which it fetches, and setter having void as return type and parameter of type of the instance variable. The improved way of this is having setters to return the instance of the object on which it is being invoked, adding benefits I mention below. In many situations we end up having to set many properties on a given object, so our code ends up in something like this:

  • My tips on passing Sun Certified Programmer for Java 2 Platform Standard Edition 6.0 (SCJP6 310-065)
    Feb 23, 2010

    Woohoo! Today I passed SCJP 6 exam from Sun! Now it will take four to six week for me to get the official certificate and all the paperwork, and after that I will probably go for SCJD, Sun Certified Java Developer.

  • How I removed Blogger NavBar.
    Feb 17, 2010

    Google says NavBar is useful, but using it for a long time I did not find any use for it. Clicking next blog from my blog, I kept getting art blogs in Spanish, Portuguese or one of Scandinavian languages. So I thought its time to get rid of it.


subscribe via RSS