• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
Programming ParadigmWhat is a Paradigm? The dictionary defines a paradigm as an “example, model or pattern”. If we are touse a more specific definition of a paradigm; a paradigm is an idealized pattern of usage under which some agent can operate. From this definition a programmingparadigm is the pattern of thought that computer programmers can operate whenwriting a program. A programming paradigm is a way of thinking about problemsand their solutions, or an approach on how to use a computer to implement thosesolutions.For a programmer to solve a particular problem, he needs to know several things,namely:
Must have a clear picture of what the problem is supposed to do.
Must have an understanding of how the program should work to produce thedesired result.
Must understand how the program fits in its environmentIn order to understand what a program is supposed to do, how it should work, andknow the environment in which it should function, the programmer must form amental model of the problem. A mental model is like a simulation of an object or anabstract concept. It is used to predict the behavior of the problem under differentcircumstances. The purpose of a paradigm is for the programmer to have mentalmodels of a solution to the problem.A paradigm is not to be confused with the programming language. While theprogramming language provides the means of to program the computer, it does notnecessarily provide a mental model for the programmer. But there are instanceswhen a particular programming language seems to impose a programmingparadigm. For example, the C + + language being object-oriented approach insolving problems.Major Programming Paradigm There are several kinds of major programming paradigms; the most common arethe following:1.Imperative2.Logical3.Functional
 
4.Object-orientedIt is quite possible that a problems is solvable with one type of paradigm canalso be solved using the others. But there are certain types of problems that arebest solved by following a certain paradigm.Imperative Paradigm The imperative programming paradigm is characterized by programming withstates and commands that modify the states. Imperative means a command ororder, while a command or a procedure means a particular course of action. Itmeans that imperative programming implies procedures (or programs) ordirections for performing an action. The imperative paradigm is an abstraction of real computers, which are based onthe Von Neumann machine. Computers have registers and memories; thesememories can be thought of as storage for variables. Imperative programming isbased on the idea that the program manipulates the stored variables. A variable,which implies a particular location in memory, may be assigned a value and alater re-assigned to another value. The collection of names and the associatedvalues together with the procedures for manipulating them constitutes thestates. The imperative paradigm assumes that a computer can maintain throughenvironment variables any change in the computations process. It recognizes thefact that computers have re-usable memory that can change state.Computations are performed through a guided sequence of steps, in whichvariables are changed or referred to. The order of the steps to follow is crucial,because a given step will have a different effect depending on the current stateof the variables.For example in a shorting program, the initial state includes the array of valuesto be sorted. When the program is finished the final state are the sorted values,while the intermediate state represents the progress towards this goal.Popular programming languages are more often imperative mainly because of two reasons: 1) The imperative paradigm closely resembles the actual computeror machine itself, so the programmer is much closer to the machine. 2) Becauseit is the only one sufficient enough for widespread use.An imperative language can be easily translated to an efficient machine code, sothey are considered highly efficient. The imperative paradigm is also popularbecause the programmer can easily express his own solutions to the problem.
 
Some disadvantages language with this paradigm is that some problems arehard to model using this paradigm. The order of the steps is crucial, whichmakes it difficult for some problems. And unless programs are carefully written,an imperative program can only be understood in terms of its executionbehavior. The reason is that during the execution of the program, any variablemay be assigned a different value or the control may be transferred to adifferent location that makes it hard to determine current state of the programmay need to be examined.When imperative programming is combined with subprograms it is calledprocedural programming also called structured programming. Examples of procedural programming languages are FORTRAN, COBOL, C and Pascal.Logical Paradigm The logical paradigm takes a declarative approach to problem-solving. Variouslogical assertions are made about a situation to establish all the known facts. The role of the computer becomes maintaining data and logical deductions andrelations. This logical approach to a problem is useful for expressing problemswhere it is not obvious what the function should be.A logical programming paradigm can be divided into three steps:1.A series of definition/declarations that define the problem domain.2.Statements of relevant facts.3.Statements of goals in the form of queries. The solution is derived from deduction of the available facts, and they arereturned as query. The logical programming paradigm has several advantages.One, the system solves the problems; so programming steps themselves arekept to a minimum. Second, since it is largely based on mathematical logic,proving the validity of a given program becomes simple.Functional Paradigm
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...