4 Main Object-Oriented Programming Principles

0
198
Object-Oriented Programming

What is an object-oriented programming language? An object-oriented programming language us a type of coding language where programmers not only define the data type of a structure, but also the methods that control the object. We define objects as exactly what they are – Objects.

4 Types of Object-Oriented Programming Principles

Encapsulation

Encapsulation is why there are public methods and private attributes when you are programming in an object-oriented programming language. We need private methods because coding something and declaring it private means that only you or your programming team can see the method or attribute. This is so the core of your application does not destruct when someone wants to modify the program.

Encapsulation
Encapsulation in Java: Example

Polymorphism

According to the dictionary, polymorphism is “the condition of occurring in several different forms“. In object-oriented programming, polymorphism is when an object takes many forms through a common interface. We can explain this term better with an example.

Polymorphism
Polymorphism example in Java Pt. 1
Polymorphism 
Polymorphism example in Java Pt. 2

Abstraction

Most of computer science is built off abstraction. Just think, how else can we represent all the things that go on inside a computer? There are two forms of abstraction in Object-Oriented Programming: abstract methods and abstruct classes.

Inheritance

The dictionary definition of inheritance is “a thing that is inherited” and inheritance in OOP is exactly that. OOP languages have a feature where you can define a superclass, then as many subclasses as you like! An example is the best way to explain this.

Inheritance
Inheritance example in Java

In conclusion main 4 OOP languages are Encapsulation, Polymorphism, Abstraction, and Inheritance. This is the OOP languages that will help you with your OOP. If you enjoyed this article, check out: TECH TERMS EVERY PROGRAMMER NEEDS TO KNOW. Therefore, If you want to learn more about programming? Read more on StarkFeed tech section.