From c8a0d6efe6c11acbbe90472d9317c7ccd38f88ec Mon Sep 17 00:00:00 2001 From: jonathanelscpt Date: Wed, 31 Oct 2018 04:27:51 +0100 Subject: [PATCH] added note for describing the four pillars of OOP (#20532) --- .../design-patterns/object-oriented-programming/index.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/guide/english/design-patterns/object-oriented-programming/index.md b/guide/english/design-patterns/object-oriented-programming/index.md index d903d1dace2..90dda1cfd08 100644 --- a/guide/english/design-patterns/object-oriented-programming/index.md +++ b/guide/english/design-patterns/object-oriented-programming/index.md @@ -17,6 +17,8 @@ What makes OO programming powerful is its ability to do the following: * Encapsulation * Abstraction +These are collectively known as the "four pillars" of OOP. + In procedural programming, we simply create variables and change them when required. However in OO programming, we can literally simulate real world objects. Encapsulation is achieved by creating a specific class for an entity, for example dog. Objects of this class are then created, which are nothing but instances of the class. Each object has its own attribute values. Another extremely useful concept is that of inheritance. The idea is that a class can inherit attributes and behaviour from a base class. For example, while creating a game, we have a player and enemy. We can create a base class called person, and give it attributes like name, age, gender, etc. Person's behaviour can be walk and jump. A player and enemy can then inherit these "qualities" from person, and can have added qualities like kill, score, eat, etc.