DEV Community

Charity Parks
Charity Parks

Posted on

OOP...What is it?

What is OOP? OOP is short for 'object-oriented programming'. 'Objects' have properties. For example, lets say that 'dog' is the object, and its properties could be: size, breed, color, sex. OOP is a set of techniques that use objects as central principle of program organization.

The four principles of object-oriented programming are encapsulation, abstraction, inheritance, and polymorphism.

Encapsulation: When each object keeps its state private inside of a class. In our dog class is where we encapsulate all of the 'dog' logic. Other objects have no direct access to its state. They would need to call on public functions called methods.

Abstraction: Objects should only allow publicly certain details while hiding all of the behind the scenes implementation. Only show what is relevant to the other objects.

Inheritance: When objects are very similar but not completely the same, yet they share common logic. Creating a child class that reuses all of the parent class's fields and methods and adds their own to it. This way we form a hierarchy.

Polymorphism: This happens when defining a parent class with logic to be reused and then the children classes implement their own version of it for themselves.

This is just a start to explaining OOP. Stay tuned for more!

Happy Coding!

Top comments (2)

Collapse
 
akrambzgh profile image
Akram Bouzoualegh

that's what i need!!!!!!!!!!!!!

Collapse
 
adam_cyclones profile image
Adam Crockett πŸŒ€

OOP the only programming style that needs a manual, it's a shame but anyway thanks for explaining πŸ‘