SADP Active Learning
SADP Active Learning
Mohan Madame
Mandar Kulkarni
Yogesh Khubchandani
ABSTRACT
● Design Patterns are standard solutions to problems in object-oriented
software engineering has proven fruitful in the software design unit.
● These patterns guarantee better quality software and at the same time a
novice designer feels at home when it comes to understanding the system
functionality.
● There are many design patterns that solves specific software design
problems. One of which is the Singleton Pattern which deals with the
object creation mechanism.This paper highlights the various issues in this
pattern
What are design patterns
● Design Patterns are a way of implementing a common solution to a
common problem in object-oriented software.
● They describe the proven solutions to recurring problems.
● They are categorized into :
1. Creational Patterns
2. Behavioral Patterns
3. Structural Patterns
What is singleton design pattern
Issue 1
● The constructor is not protected.
● If the constructor is protected or public then a class, which is
in the same package, can create object of Singleton class
Issue 2 which violates the Singleton criteria.
● Hence it is usually private in nature.
● If a thread is preempted at Line 2 before the assignment is
made, the instance member variable will still be null, and
another thread can subsequently enter the if block.
● In that case, two distinct singleton instances will be created.
Issue 3
● Because multiple classloaders are commonly used in many
situations—including servlet containers—we can end up with
multiple singleton instances
Issue 4
● If we serialize a Singleton and then deserialize it twice, there
will be two instances of the singleton
● Solution is to implement the readResolve () method.
Issue 5
Applications