OOP (Object Oriented Programming):
As opposed to the procedural arrangement of code, OOP is organizing code into classes and objects that imitate real world.
Fundamental concepts:
Abstraction: Focusing on the essential characteristics of some object while ignoring the unnecessary details, relative to the perspective of the viewer.
Encapsulation: Each object exposes an interface that specifies how other objects may interact with it, so the internal state can’t be changed in unexpected way. Essentially hiding the implementation complexities and details.
With encapsulation, a class can be reimplemented without system side effects as long as the class interface is not broken.
Modularity: The act of partitioning a program into individual components. This will reduce program complexity, even some modules can be changed without side effects as long as the interface remain fixed.
Hierarchy: the mapped relationships of sub- and super-classes is known as a hierarchy. This can be visualized as an upside-down tree, the top of which is known as the root.
Persistence: The ability of some object to save state across time.
Links: One object to use the services of another object.
Aggregation: The containment of an object to another object as one of its members.
Aggregation & Composition: Aggregation differs from ordinary composition in that it does not imply ownership. In composition, when the owning object is destroyed, so are the contained objects. In aggregation, this is not necessarily true. For example, a university owns various departments (e.g., chemistry), and each department has a number of professors. If the university closes, the departments will no longer exist, but the professors in those departments will. Therefore, a University can be seen as a composition of departments, whereas departments have an aggregation of professors. In C++ we can say the university contains departments objects by value, but contains pointer to professors.
Sometimes aggregation is referred to as composition when the distinction between ordinary composition and aggregation is unimportant.
Using Relationship:
An object function that instantiate objects from other classes and use their services within the scope of the function.
Access Control: The class define access control to its members, so members that related to internal implementation should have restricted access from the outside world.
Polymorphisms: An object can represent many types as long as they belong to a common superclass, so that sending a message to the object will give different action depending on the actual value of the variable at the moment. Without this feature we will end up having a big switch case to decide which object-function to call.
Polymorphic Function: multiple function definitions with different parameters with same name.
Multiple Polymorphisms: Using a virtual function as in c++, you can make polymophism, making the parameter itself a polymorphic object will give us the opportunity to create multiple polymorphism to any degree. Suppose we have a virtual draw function that draw a circle, or rectangle based on the actual subclass of the object, suppose we want to draw on many media types such as Printer or Screen, we can make Printer and Screen as a subclass of Device and send an object of it to the original draw function. Now the function will draw on the exact Device based on two things: the exact object, rect or circle and the exact device, Printer or Screen.
Overloading: Overloading allows multiple functions taking different types to be defined with the same name.
Interface: Specify one or more abstract method signatures, used by subclasses.
Subclasses and superclasses: Classes are often related in some way. The most popular of these relations is inheritance, which involves subclasses and superclasses, also known respectively as child classes (or derived classes) and parent classes (or base classes).
* This is the basics from my point of view, sure I am affected with my c++/java experience, any comments?
References:
1) www.wikipedia.org
2) Object Oriented Analysis and Design with Applications by Grady Booch