From c6945de3db036aa8ff9f15e635c00b192e90f002 Mon Sep 17 00:00:00 2001 From: Eric Hodges Date: Wed, 3 Apr 2019 02:10:45 -0700 Subject: [PATCH] Added a few words for clarity (#31744) Changes made to the third paragraph under OO concepts. --- .../design-patterns/object-oriented-programming/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guide/english/design-patterns/object-oriented-programming/index.md b/guide/english/design-patterns/object-oriented-programming/index.md index e5fec3f90ca..65aabb55152 100644 --- a/guide/english/design-patterns/object-oriented-programming/index.md +++ b/guide/english/design-patterns/object-oriented-programming/index.md @@ -21,7 +21,7 @@ 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. +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 an enemy. We can create a base class called person, and give it attributes like name, age, gender, etc. A person's behaviour can be walk and jump. A player and an enemy can then inherit these "qualities" from person, and can have added qualities like kill, score, eat, etc. This helps in reusing code and making your code structure much cleaner. Data hiding is another cool feature. In OO, we have the notion of private and public attributes. Private attributes can be accessed and modified only by methods of that particular class, while public data can be modified from anywhere in the program (within scope obviously). The main goal of abstraction is to handle all the complexity and hiding unnecessary details from the user. A real life example of this can be that of a car: When we push the accelerator, the car starts to move. All the internal mechanics that are involved in the movement are irrelevant to us and are hence hidden.