View RSS Feed

Design Patterns

Design patterns in Java.

  1. Protected constructor

    by , 03-09-2012 at 07:49 PM
    For allowing the singletonís sub-classing, there is a possibility to use the protected constructor. Such technique consists of two main drawbacks which makes the inheritance of a singleton impractical.

    • If constructor is protected then instantiation of the class can be done by calling the constructor from some other class present in the similar package. Creation of the singletonís separate package can avoid it.
    • For using the derived class, change all getInstance calls present