Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Paradigms

Similar presentations


Presentation on theme: "Programming Paradigms"— Presentation transcript:

1 Programming Paradigms
Section 3.5 Programming Paradigms

2 Different Paradigms Paradigm means ways of programming.
Low-Level Programming Paradigm Machine code (First Generation) Assembly Language (Second Generation) Use of mnemonics LDA X ADD Y STO Z Procedural Paradigm (Third Generation) High Level Language Problem Oriented  have an syntax FORTRAN (Formula Translation) and ALGOL (Agorithmic Language) developed for scientific and engineering purposes. BASIC is a teaching language. Visual Basic .net, sits inside the microsoft .net framework and is used for windows based applications

3 Different Paradigms With procedural languages it becomes difficult to reuse code or procedures in different programs. If the problem changes then changing the methods/procedures becomes cumbersome To solve this problem Object Oriented languages were developed. Object-Oriented Paradigm In these languages, the data and methods are coded and designed together as a single unit called the object. Accessing the object is only via the object’s methods. Once an object is working it cannot be corrupted by the programmer. The data values of an object is included in its definition. The values of the object or the internal working of the object can be changes without changing any methods. C++, java, smalltalk Procedural programming languages operate procedures on data structures. OOP languages they group the methods and the data structures together in an object.

4 Different Paradigms Declarative Programming languages:
They encode a sequence of steps about how to solve a problem. The computer is told what the problem is not how to solve it. On the basis of the rules that are programmed it figures out how to solve the problem Expert systems. (use of knowledge base facts and databases)

5 Procedural programming language
They solve problems in sequence of steps. Using sequence, selection and iteration. They are close enough to english (all high level languages are) They use procedures and functions. All steps are in a sequence. With procedures there is a risk of variables being altered as their scope is unclear.

6 oop With object oriented programming, we deal with objects which model the real world. Gives more data security as we now clearly define the scope of the variable. CAR is an object X’s car would be an instance of an object Y’s car would be another instance of CAR object. A car would have the same properties. A type of object can be made into a class. An object is an actual instance of class. Class is a type of object, which has its properties and definition. Objects are referenced with variable. X’s car.

7 Declarative programming language
Where you tell the computer what needs to be solved but not how. Used for artificial language. Prolog. There is an inference engine, which holds the rules to manipulate the knowledge base which is the database containing the data. User inputs the query which is answered using the rules in the inference engine. Whatever happens in a procedural language using the selection and iteration statements, can be done without using these in declarative programming language.

8 Declarative programming language
If there is a two dimensional array called Person in VB. We’ll have it like this. In VB if we want to search all males, what will we do? 1 2 Female Hermione Ginerva 3 Luna 4 Male Ron 5 Harry

9 Declarative programming language
For index = 1 To 5 If Person[index, 1] = “Male” Then Msgbox(Person[index, 2]) End If However in declarative programming language we will not need to write any if conditions. Because we don’t need to tell the language how to find all the persons who are male in the array. All we have to do is to write the syntax for the query which in this case will be Male(X).

10 Structured program development
In these structured programming languages we break the problem into smaller modules or structures. Breaking of a big problem into smaller problems is called stepwise refinement. Uses functions and procedures. Parameters are passed to both function and procedures. Procedures don’t return any values. Functions return values.

11 Structured program development
In these structured programming languages we break the problem into smaller modules or structures. Breaking of a big problem into smaller problems is called stepwise refinement. Uses functions and procedures. Parameters are passed to both function and procedures. Procedures don’t return any values. Functions return values.


Download ppt "Programming Paradigms"

Similar presentations


Ads by Google