Object Oriented, Whats this again? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 2

Object Oriented, Whats this again?

Wat, Read the title again

23rd May 2017, 6:19 PM
Washiul Alam Sohan
Washiul Alam Sohan - avatar
2 ответов
+ 5
In OOP, the whole functionality of the program revolve around objects. Objects are nothing but instances of a class. You can think of a class as a blueprint. When you create an object you use that blueprint for processing your specific data values.
23rd May 2017, 6:31 PM
Maaz
Maaz - avatar
+ 1
And the fundamental principles of OOP are Abstraction, Encapsulation, Inheritance and Polymorphism. In short.. Abstraction is about how we can abstractly describe real world objects in our programs. Encapsulation means hiding object's inner data or implementation complexity. It can look like a "black box", so you do not need to know what exactly is happening inside the box, but you have some external mechanisms (methods) which you can use to change it's state or tell the object to do some functionality. Encapsulation also helps to maintain object's consistency and security. Inheritance is a powerful mechanism in OOP which helps to reuse code and extend behaviours of classes. One of the other benefits of it is classes hierarchy. Polymorphism is a concept of using different types of objects to do some functionality.. or to have some functions or methods to act differently according to the actual types of parameters... for example, we can place markers at some POIs on google maps and we are able to use different types of markers, markers of different color and shapes.. and we can use the power of polymorphism to have a List<Marker> (collection of markers) where Marker is the base class and we can put in the List GreenMarker, RedMarker, AnimatedMarker, and so on.. which are subclasses of Marker.... Having that list we can pass it to a method which will draw them on a layer and they will be drawn according to their actual types.. Polymorphism can be achieved through inheritance (subclassing), methods overriding, overloading, interfaces and abstract classes...
23rd May 2017, 7:59 PM
Aibek T.
Aibek T. - avatar