Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming paradigms

Similar presentations


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

1 Programming paradigms
Lecture I Programming paradigms

2 Programming styles Unstructured: - This style of programming helps us to write small and simple programs. In this programming no separate procedure were written for repetitive task. Generally we avoid such type of programming. Structured:- This style of programming helps us to broken down a large program onto small independent tasks that are easy to understand without having to understand the whole program. These tasks are developed independently, without the help of other tasks Object-oriented Programming: - ??

3 What is a paradigm Programming paradigm refers to how a program is written in order to solve a problem.

4 Different Paradigms Imperative paradigm Functional paradigm
Logic paradigm Object-Oriented paradigm

5 Imperative Paradigm First do this and next do that Characteristics:
Straightforward abstractions of the way a traditional Von Neumann computer works Execution of computational steps in an order governed by control structures Similar to descriptions of everyday routines, such as food recipes and car repair Typical commands offered by imperative languages Assignment, IO, procedure calls Language representatives Fortran, Algol, Pascal, Basic, C "Procedural programming"

6 Functional Paradigm Evaluate an expression and use the resulting value for something Characteristics: Discipline and idea Mathematics and the theory of functions Atemporal Time only plays a minor role compared to the imperative paradigm Applicative All computations are done by applying (calling) functions The natural abstraction is the function Fits well with computations driven by needs

7 Logic Paradigm Answer a question via search for a solution
Characteristics: Discipline and idea Automatic proofs within artificial intelligence Based on axioms, inference rules, and queries. Program execution becomes a systematic search in a set of facts, making use of a set of inference rules

8 Object-Oriented Paradigm
Send messages between objects to simulate the temporal evolution of a set of real world phenomena Characteristics: Data as well as operations are encapsulated in objects Information hiding is used to protect internal properties of an object Objects interact by means of message passing In most object-oriented languages objects are grouped in classes Classes are organized in inheritance hierarchies

9 OOP Programmers define not only the data type of a data structure, but also the types of operations that can be applied to the data structure. Data structure becomes an object that includes both data and functions. Enable programmers to create modules that do not need to be changed when a new type of object is added.

10 Features of OOP Encapsulation Data abstraction Inheritance
Polymorphism Message passing Extensibility Genericity

11 OO Concepts Object Encapsulation Class Inheritance Interface Package

12 Object models the real-world objects that you find in everyday life.
A software object.

13 A bicycle modeled as a software object.
Object example Consider a bicycle, for example: A bicycle modeled as a software object.

14 Encapsulation Hiding internal state and requiring all interaction to be performed through an object's methods is known as data encapsulation.

15 Benefits Modularity: The source code for an object can be written and maintained independently of the source code for other objects. Information-hiding: By interacting only with an object's methods, the details of its internal implementation remain hidden from the outside world. Code re-use: If an object already exists (perhaps written by another software developer), you can use that object in your program. Pluggability and debugging ease: If a particular object turns out to be problematic, you can simply remove it from your application and plug in a different object as its replacement.

16 Class A class is a blueprint or prototype from which objects are created.

17 A hierarchy of bicycle classes.
Inheritance A mechanism for organizing and structuring your software. A hierarchy of bicycle classes.


Download ppt "Programming paradigms"

Similar presentations


Ads by Google