In traditional procedural programming, a program is composed of data and a bunch of procedures, each of which carries out a subtask for data-processing. Object-oriented programming or OOP, however, breaks down this architecture and intertwined relatively-independent pieces of data and the methods manipulating them together. The new construct is called an object. As shown in the figure above, an object is composed of data (varibles) and code manipulating these data (methods). 2 OOP Features OOP has three important features: inheritance, encapsulation, and polymorphism. Inheritance means that an object can inherit from another object, thereby owning all the public data and methods from the parent object. Encapsulation means an object is encapsulated and relatively independent from the outside world. Keywords such as "private", "friend" or "protected", and "public" are used to control external access to objects. Overload means that a method inherited from a parent object can be reimplemented so that different decendents of the same parent class may have different behavior. 3 Singlton vs Static classes They essentially can do the same thing: (1) create a global instance, and (2) hold state variables (static classes have to use static vars though), (3) both should be used with caution, abusing either one of them will make your programs very hard to read and test. When makes Singlton stand up a little is it's support for OO features. (1) you can extend a singleton class, and (2) singleton class can implement interfaces, so you can pass it as arguments to methods expecting those types, etc. Comments
OOP has three important features: inheritance, encapsulation, and polymorphism. Inheritance means that an object can inherit from another object, thereby owning all the public data and methods from the parent object. Encapsulation means an object is encapsulated and relatively independent from the outside world. Keywords such as "private", "friend" or "protected", and "public" are used to control external access to objects. Overload means that a method inherited from a parent object can be reimplemented so that different decendents of the same parent class may have different behavior.
3 Singlton vs Static classes They essentially can do the same thing: (1) create a global instance, and (2) hold state variables (static classes have to use static vars though), (3) both should be used with caution, abusing either one of them will make your programs very hard to read and test. When makes Singlton stand up a little is it's support for OO features. (1) you can extend a singleton class, and (2) singleton class can implement interfaces, so you can pass it as arguments to methods expecting those types, etc. Comments
They essentially can do the same thing: (1) create a global instance, and (2) hold state variables (static classes have to use static vars though), (3) both should be used with caution, abusing either one of them will make your programs very hard to read and test.
When makes Singlton stand up a little is it's support for OO features. (1) you can extend a singleton class, and (2) singleton class can implement interfaces, so you can pass it as arguments to methods expecting those types, etc.