Principles of Object-Oriented Programming (oops)
Object-oriented programming (OOP) is a programming paradigm using “objects” – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction, encapsulation, messaging, modularity, polymorphism, and inheritance. Many modern programming languages now support OOP, at least as an option.
The 3 major principles of Object-Oriented Programming
Encapsulation is the technique of making the fields in a class private and providing access to the fields via public methods. If a field is declared private, it cannot be accessed by anyone outside the class, thereby hiding the fields within the class. For this reason, encapsulation is also referred to as data hiding.
As the name inheritance suggests an object is able to inherit characteristics from another object. In more concrete terms, an object is able to pass on its state and behaviors to its children. For inheritance to work the objects need to have characteristics in common with each other. The parent-child relationship between classes can be represented in a hierarchical view often called class tree view. The class tree view starts with a general class called superclass (sometimes referred to as base class, parent class, ancestor class, mother class or father class), there are many genealogical metaphors). Derived classes (child class or subclass) become more specialised further down the tree. Therefore we usually refer to the relationship that links one child class to a parent class by the phrase “is a(n) ” x of y).
The word, polymorphism comes from Greek and means having several different forms. This is one of the essential concepts of object-oriented programming, where inheritance is related to classes and (their hierarchy), polymorphism is related to object methods.