Programming languages are classified into two types, procedural languages, and object-oriented languages. In procedural languages, programs are written where developers concentrate on what is happening. As you know that C is a procedural language. Whereas in object-oriented languages, developers concentrate on data and how it is being affected. In this tutorial, you will learn basics of Object Oriented Programming (OOP) language. One of the essential features of OOP is the abstraction. It means hiding the complexity from the users.
For an example, if you are driving a car, you don't need to understand the complexity of thousands of individual parts that form a car. Though a car consists of thousands of objects, from the user's perspective it's a single object, which can be controlled by few interfaces.
OOP Principles
There are three principles, which are followed in OOP. The principles are discussed below.
Encapsulation: It is a wrapping mechanism to bind data and code together to keep both safe from outside. It prevents arbitrary access by other codes which are written outside of this wrapper.
|
|
Inheritance: It is a technique by which an object acquires some properties of another object. For an example, Animal class can be classified as Mammal and Reptile. Hence, both Mammal and Reptile inherits Animal class. Thus, inheritance can be considered as the classification problem.
|
|
Polymorphism: It is an important feature of OOP that allows developers to perform a single action in different forms. If you are familiar with Data Structure, you do understand that multiple linked lists are to be created for different types of data. But in OOP, a generic class can be defined by which different types of data can be managed.
|
At this moment, you may not be able to understand these principles. But don't worry, these are very easy. You will understand these principles gradually, as we will go ahead.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.