Guru on Rails

if you don’t sacrifice for your dream then your dream becomes your sacrifice.
Sydney, Sat 01 Jun 2019
Four major principles of OOP
Thu 23 Aug 2018

I wrote a bunch of articles about higher level of Object Oriented Design. But I think it's necessary to know the basic. Thus, that is the reason we have this article. Let's go through some points.

Four major principles of OOP, we might know them.

  1. Encapsulation.
  2. Abstraction.
  3. Inheritance.
  4. Polymorphism.

Encapsulation

Hiding data, restricting the access. At last article, I introduced you about modeling objects so we know that an object will be like container, in order to contains data. Not all of data we want to show for the outside or their relatives. We encapsulate data and we also provide the accessors to retrieve them. That is encapsulation.

Abstraction

“An abstraction denotes
the essential characteristics of an object that distinguish it from all
other kinds of object and thus provide crisply defined conceptual
boundaries, relative to the perspective of the viewer.” — G. Booch,
Object-Oriented Design With Applications, Benjamin/Cummings, Menlo
Park, California, 1991.

For me:

  • Abstraction is represent for essential behaviors in real world.
  • More high level. Not focusing on implementation but about the logic.
  • Giving the others knowledge about this object.

Inheritance

(to be continue...)

Polymorphism