I think it's necessary to know the basic. Thus, that is the reason we have this article. Let's go through some points. But I firstly want to say that this is conceptional level. So don't pay attention on implementation. This is ideas we keep in mind while designing and coding.
Four major principles of OOP, we might know them.
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.
This is conceptional level. A class should know only the other's interfaces, not implementation.
“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.
- 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.
Child inherits all parent's attributes and behaviors so it can replace parents.
It means one name many forms. In ruby we can achieve it through:
- Duck Typing pattern.
- Decorator pattern.