31. July 2013 18:06
- Singleton object stores in Heap but, static object stores in stack
- We can clone the object of Singleton but, we can not clone the static class object
- Unlike static classes, we can use singletons as parameters or objects.
- we can implement interface with Singleton class but not with Static class.
- Singleton class follow the OOP(object oriented principles) but not static class
- Singleton class maintains state. It is thread safe.
- we can dispose the objects of a singleton class but not of static class
The difference between the Singleton and Static is Singleton Class can have value when Class object instantiated between server and client, such a way if three client want to have a shared data between them Singleton can be used. Static are always just shared and have no instance but multiple references.
29. June 2013 11:35
Abstraction allows us to represent complex real world in simplest manner. It is process of identifying the relevant qualities and behaviors an object should possess, in other word represent the necessary feature without representing the back ground details. Abstraction is a process of hiding work style of an object and showing only those information which are required to understand the object. Abstraction means putting all the variables and methods in a class which are necessary.
It is a process of hiding all the internal details of an object from the outside real world. The word Encapsulation, like Enclosing into the capsule. It restrict client from seeing its internal view where behavior of the abstraction is implemented. In Encapsulation, generally to hide data making it private and expose public property to access those data from outer world. Encapsulation is a method for protecting data from unwanted access or alteration. Encapsulation is the mechanism by which Abstraction is implemented.
Difference between Abstraction and Encapsulation
Abstraction is a process. It is the act of identifying the relevant qualities and behaviors an object should possess. Encapsulation is the mechanism by which the abstraction is implemented.
|Abstraction solves the problem in the design level.
||Encapsulation solves the problem in the implementation level.
|Abstraction is used for hiding the unwanted data and giving only relevant data.
||Encapsulation is hiding the code and data into a single unit to protect the data from outer world.
|Abstraction is set focus on the object instead of how it does it.
||Encapsulation means hiding the internal details or mechanics of how an object does something.
|Abstraction is outer layout in terms of design.
For Example: - Outer Look of a iPhone, like it has a display screen.
|Encapsulation is inner layout in terms of implementation.
For Example: - Inner Implementation detail of a iPhone, how Display Screen are connect with each other using circuits