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:
1) Procedural Oriented Programming Approach (POP)
Here, procedure means to process and Procedural oriented programming Approach means process-based Programming Approach.
Basically, it consists of 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.
Example of Programming paradigms
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 the 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 the POP approach the main program or task is divided into functions.
Characteristics of POP: (Programming paradigms)
1) Emphasis on doing things. (process)
2) The process is divided into functions.
3) Functions share global data.
4) It follows a top-down approach.
Advantages of POP:
1) It is a relatively simple approach.
2) Easy to keep track of program flow.
3) It is quick to approach.
Disadvantages of POP:
1) Data are give in second class status.
2) Difficult to make new data types.
3) Updation is very tough in POP.
A function has complete access to global variables. (data can easily corrupt)
2) Object-Oriented Programming Approach (OOP):
Because of the disadvantages of the POP concept force to found a 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: (Programming paradigms)
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 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 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 called a child or derive class.
And the class from which the 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 the programming paradigms.