Sunday, November 12, 2017
OOP explained (1) -CONCEPT-
This article is a summary on the video above.
Object Oriented Programming (OOP) is preceded by the Machine Language, Assembly Language, and Procedural Language (like C), and the concept of it is to let it similar as the thing-in-itself in natural environment. We perceive external world as the collection of Objects.
OOP has the following features:
While procedural language only has global variables and bunch of functions accessing to each of those, this also means that there are no independent entities, just nothing but the pile of chunks. (Even though C has modules)... Relying on global variables is often risky since then variable becomes accessible to which are not supposed to. The concept of Object is that to make it split into a unit easy to understand. On this paradigm everything is regarded as an Object. For instance, EMPOLYEE can be a single object, and it can have the attributes (instance variables) and functions(methods).
Class is a template for the Object. Object is, on the other hand the instantiated copy of this class.
This definition means there is Type (String) and variable (x), String is the class template since it is generated only once, but x is the object of String since it is a instantiated variable (copy) of that template. (Singleton is an entity only generated once, accessible from anywhere, seems little bit like a class)
In order to define the class, OOP thinks we should not expose what is not necessary, so the number of methods are ABSTRACTED (filtered) just only which is crucial as the part of interface to connect with external something.
Little bit similar to Abstraction (Since only what is necessary as interface should be exposed as public but else should be eliminated from class or be private). For example, vending machine only has button and coin-slot and box to retrieve cans for customers, it is kind of interfaces nevertheless it has so much components inside of it.
5,6 Inheritance, Polymorphism
Child inherits from its parent. Parent should be abstracted as much as possible since all the peculiar detail should be defined and implemented in each child classes. Also, Polymorphism means a single definition of class can be implemented in various ways as its child node. For instance, if the superclass is defined as OS, then we can define each object as MACOSX, MSDOS, UBUNTU, FREEBSD etc....
So these six are main concepts of the OOP. In the next article, I would like to introduce the SOLID principle.
Posted by Unknown at 7:20 PM