What is programming paradigms? | How many types of programming approaches? | computer knowledge only at thetechknowledge.com
Basically, the programming approach means a way of doing programming.
So, there are two basic types of programming approach:
Procedural Oriented Programming Approach (POP): programming paradigms
Here, procedure means to process and Procedural oriented programming Approach means process-based Programming Approach. Basically, it consists the functions (explained in next paragraph) and data stored in different variables (in which data can store in memory)
In, the POP problem is viewed as things to be done.
Reading (input), calculating (process), and printing (output)
We can understand the concept of POP by an example, if I have a main program or task so, in POP approach this main task is divided into a subtask and for implementing this subtask we need a set of programs called functions. These functions can be interrelated. So, the conclusion of this example is that in POP approach the main program or task is divided into functions.
Characteristics of POP: programming paradigms
- Emphasis on doing things. (process)
- The process is divided into functions.
- Functions share global data.
- It follows a top-down approach.
- Advantages of POP:
- It is a relatively simple approach.
- Easy to keep track of program flow.
- It is quick to approach.
- Disadvantages of POP:
- Data are given second class status.
- Difficult to make new data types.
- Updation is very tough in POP.
A function has complete access to global variables. (data can easily corrupt)
Object-Oriented Programming Approach (OOP):
Because of the disadvantages of the POP concept force to found the new and better programming approach than the POP approach called Object-Oriented Programming approach.
We know that in the POP approach the main program or task is divided into functions.
Whereas, OOP approach combines a group of related functions and variables into a single Unit called as an Object. We refer to these variables as properties and functions as a method.
For Example, A car consists of different types of functions or methods. Like start, move, stop, etc. And also consist of the model, color types of variables or properties.
Concepts of OOP’s:
Let’s get some brief knowledge about main OOP’s concepts:
The object is define by any real-world entity. Which have properties and methods (tasks or functions) It can also define as an instance of a class (Explained in the definition of class)
For example, A Bank Account is an object. Which consists of properties like Account number, Account type, etc. and it also consists of withdrawing money, deposit money types of tasks, or method.
More Example of the object: A student, a dog, a car, etc.
Class is the collection of related types of objects.
Class is the blueprint that its object follows. Classes cannot directly communicate with another class. It can communicate via objects.
For example, Animal is one type of class which consists of various types of animals and these animals have some common properties and functions
More examples of a class: birds, cars, etc.
Abstraction is nothing but showing only essential parts and hiding the implementation. We can also call Abstraction as data hiding.
For example, if you download and install any software so.exe file comes with that software and when you run that .exe file we can use the software but we can’t see the methods, properties are used to create the .exe file that means all the implementation parts is hiding.
Encapsulation: Encapsulation is the binding of variables (properties) and functions (methods) in a single entity.
For example, a class, which consists of functions and variables.
An Inheritance is a very important concept of OOP.
Inheritance means acquiring the properties of one class to another class.
A class that acquires the properties of another class is call a child or derive class.
And the class from which child class acquired properties is called a parent or base class.
For example, the animal is class, and mammals are one type of animal so it acquired some property from animal class.
So, basically mammals are child class and animal is parent class.
Polymorphism: programming paradigms
Polymorphism means ‘many forms’. We can also define Polymorphism as performing a task in different ways.
Especially Polymorphism in java language has two type
Compile-time Polymorphism (static binding)
Run Time Polymorphism (Dynamic Binding).
An example of static polymorphism is Method overloading, and an example of dynamic polymorphism is Method overriding.
So, that’s all about the introduction of two basic types of programming approaches.
Thanks for reading programming paradigms.