Object Oriented Programming (OOP) is a Programming Paradigm which is based on the concept of objects. Objects are entities that contain Data and Methods. Data refers to the values, variables or state that are used within the program and Method are the Procedures or Functions which manipulate that data.
In OOP, a computer program implements logic by making use of these objects that interact with each other. For this purpose multiple objects of similar or distinct structure are created within the program. Implementing similar objects again and again can consume time and creates redundancy in code. Class provides a solution to this problem. It acts as a blueprint or foundation for defining the structure of an object. Class is thereby used to first design and then to create similar multiple objects. …
In a computer program, control flow is the order in which set instructions are executed. A control flow statement changes program flow, to achieve specific results, by choosing a path from available paths. These statements can be based on some condition; executing instructions only when some condition is met; or can be unconditional; arbitrarily transferring the flow to some different instruction set. The goto statement was the most basic form of unconditional transfer. It transfers the control to the labelled instructions set.
Goto performs one-way transfer of control which means the control is not expected to return after executing the labelled instructions set. On the contrary, calling a Function usually returns the control after execution. In earlier programming, goto statements were used extensively. However, with increasing complexity it becomes harder to maintain computer programs because goto resulted in non-linear change of control flow which was harder to understand compared to linear transfer. …
Procedural Programming is an Imperative style of Programming Paradigm. It is a style of writing computer programs using procedures. Procedural Programming solves a problem by implementing and making use of various procedures.
Procedure is a sequence of computer instructions for performing a specific task. When we need to perform that same task again somewhere else then instead of writing the same instruction set again, we will call the procedure to perform the task. Procedure are also referred to as Routines, Subroutines and Functions. Procedures enable Modularity in a computer program. Procedure may have input arguments in order to perform given tasks. …
Functions in general, applies computation on given input and returns the output. It relates input to an output.
f(x) = x + 2;f(1) = 1 + 2 = 3;
f(2) = 2 + 2 = 4;
Above mentioned is a simple function that adds
2 to the input value and returns output. It relates value
[1,2] => [3,4]. Similarly, a function in computer programming is a block of instruction that performs computation on given input and returns the output.
Functional Programming is such a style of writing computer programs using these tiny functions that works together and perform required computation. …
A program is a set of instructions that instruct the computer to perform a certain task. And Programming Paradigm are the styles of writing a computer program. Paradigms can be broadly classified into Imperative and Declarative programming based on how and what the computer is instructed to do.
Yes. An imperative program tells the computer about how to perform certain tasks. While a declarative program tells the computer about what to do and not really caring about how the computer does it.
Let’s imagine you are into shopping. You want to buy a T-Shirt. In your head you will have conditions and logic getting popped. …
Paradigms are patterns. We found patterns in every phase of our day to day environment. Whether it be eating, drinking, sleeping or any other part of our life, patterns will always be a part of it. Hence a pattern can be termed as something, a philosophy, idea, theory or method through which we approach certain actions. The same is the case around with programming.
Programming Paradigms are the certain set of constructs and ideas through which we program a machine. It is a style of writing programs.
Imagine this, a friend of yours asks you for a favour. Since you are good with handwriting and forming statements, on the first day the friend asks you to write his / her name on a piece of paper. Ah that’s simple, you wrote it with precise penmanship and it’s a wonderful creation you put on paper. The second day, the same friend comes to you and asks you to write a statement about his / her personality. You activate your brain cells and think of something. You put that out on a paper and the problem solved. The third day, the same friend comes to you and asks you to write an essay about his / her friendship with yours. You are now into thinking and forming patterns to write the entire thing. Assuming this situation goes around for some days and each day your friend asks you to write on different topics. Eventually you will start forming patterns and follow it in certain cases. …