Java Reference
In-Depth Information
It is not enough just to have a solution to a problem. The solution must be practical and effective. Since the
solution to a problem is always related to the way the problem and the solution are thought about, the paradigm
becomes paramount. You can see that the solution provided by the monk may kill the hungry people before they can
get any help. The philanthropist's solution may be a good short-term solution. The politician's solution seems to be a
long term solution and the best one. It is always important to use the right paradigm to solve a problem to arrive at a
practical and the most effective solution. Note that one paradigm cannot be the right paradigm to solve every kind of
problem. For example, if a person is seeking eternal happiness, he needs to consult a monk and not a politician or a
philanthropist.
Here is a definition of the term “programming paradigm” by Robert W. Floyd, who was a prominent computer
scientist. He gave this definition in his 1978 ACM Turing Award lecture titled “The Paradigms of Programming.”
“A programming paradigm is a way of conceptualizing what it means to perform computation,
and how tasks that are to be carried out on a computer should be structured and organized.”
You can observe that the word “paradigm” in a programming context has a similar meaning to that used in the
context of daily life. Programming is used to solve a real-world problem using computational models provided by a
computer. The programming paradigm is the way you think and conceptualize about the real-world problem and its
solution in the underlying computational models. The programming paradigm comes into the picture well before you
start writing a program using a programming language. It is in the analysis phase when you use a particular paradigm
to analyze a problem and its solution in a particular way. A programming language provides a means to implement a
particular programming paradigm suitably. A programming language may provide features that make it suitable for
programming using one programming paradigm and not the other.
A program has two components, data and algorithm. Data is used to represent pieces of information. An
algorithm is a set of steps that operates on data to arrive at a solution to a problem. Different programming paradigms
involve viewing the solution to a problem by combining data and algorithms in different ways. Many paradigms are
used in programming. The following are some commonly used programming paradigms:
Imperative paradigm
Procedural paradigm
Declarative paradigm
Functional paradigm
Logic paradigm
Object-oriented paradigm
Imperative Paradigm
The imperative paradigm is also known as an algorithmic paradigm. In the imperative paradigm, a program consists
of data and an algorithm (sequence of commands) that manipulates the data. The data at a particular point in time
defines the state of the program. The state of the program changes as the commands are executed in a specific
sequence. The data is stored in memory. Imperative programming languages provide variables to refer to the memory
locations, an assignment operation to change the value of a variable, and other constructs to control the flow of a
program. In imperative programming, you need to specify the steps to solve a problem. Suppose you have an integer,
say 15, and you want to add 10 to it. Your approach would be to add 1 to 15 ten times and you get the result, 25. You
can write a program using an imperative language to add 10 to 15 as follows. Note that you do not need to understand
the syntax of the following code; just try to get the feeling of it.
 
Search WWH ::




Custom Search