SECTION 3.5 PROGRAMMING PARADIGMS. DIFFERENT PARADIGMS Paradigm means ways of programming. Low-Level...

11
SECTION 3.5 PROGRAMMING PARADI GMS

Transcript of SECTION 3.5 PROGRAMMING PARADIGMS. DIFFERENT PARADIGMS Paradigm means ways of programming. Low-Level...

Page 1: SECTION 3.5 PROGRAMMING PARADIGMS. DIFFERENT PARADIGMS Paradigm means ways of programming. Low-Level Programming Paradigm Machine code (First Generation)

SECTION 3

.5

P RO

GRA

MM

I NG

PA

RAD

I GM

S

Page 2: SECTION 3.5 PROGRAMMING PARADIGMS. DIFFERENT PARADIGMS Paradigm means ways of programming. Low-Level Programming Paradigm Machine code (First Generation)

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

Page 3: SECTION 3.5 PROGRAMMING PARADIGMS. DIFFERENT PARADIGMS Paradigm means ways of programming. Low-Level Programming Paradigm Machine code (First Generation)

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.

Page 4: SECTION 3.5 PROGRAMMING PARADIGMS. DIFFERENT PARADIGMS Paradigm means ways of programming. Low-Level Programming Paradigm Machine code (First Generation)

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)

Page 5: SECTION 3.5 PROGRAMMING PARADIGMS. DIFFERENT PARADIGMS Paradigm means ways of programming. Low-Level Programming Paradigm Machine code (First Generation)

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.

Page 6: SECTION 3.5 PROGRAMMING PARADIGMS. DIFFERENT PARADIGMS Paradigm means ways of programming. Low-Level Programming Paradigm Machine code (First Generation)

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.

Page 7: SECTION 3.5 PROGRAMMING PARADIGMS. DIFFERENT PARADIGMS Paradigm means ways of programming. Low-Level Programming Paradigm Machine code (First Generation)

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.

Page 8: SECTION 3.5 PROGRAMMING PARADIGMS. DIFFERENT PARADIGMS Paradigm means ways of programming. Low-Level Programming Paradigm Machine code (First Generation)

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

1 Female Hermione

2 Female Ginerva

3 Female Luna

4 Male Ron

5 Male Harry

Page 9: SECTION 3.5 PROGRAMMING PARADIGMS. DIFFERENT PARADIGMS Paradigm means ways of programming. Low-Level Programming Paradigm Machine code (First Generation)

DECLARATIVE PROGRAMMING LANGUAGE

For index = 1 To 5If 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).

Page 10: SECTION 3.5 PROGRAMMING PARADIGMS. DIFFERENT PARADIGMS Paradigm means ways of programming. Low-Level Programming Paradigm Machine code (First Generation)

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.

Page 11: SECTION 3.5 PROGRAMMING PARADIGMS. DIFFERENT PARADIGMS Paradigm means ways of programming. Low-Level Programming Paradigm Machine code (First Generation)

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.