5 - Programming Constructs and Paradigms
5 - Programming Constructs and Paradigms
and Paradigms
Objectives
▪ Analyze Relevant Tools and Standards for Effective
Implementation.
▪ Analyze Applicable Standards and Engineering Constraints
Introduction of
Programming Paradigms
Paradigm
▪ Paradigm can also be termed as method to solve some
problem or do some task.
▪ Programming paradigm is an approach to solve problem
using some programming language or also we can say it is a
method to solve a problem using tools and techniques that
are available to us following some approach.
Programming Paradigms
Imperative Programming Paradigm
▪ It is one of the oldest programing paradigm.
▪ It features close relation to machine architecture.
▪ It works by changing the program state through assignment
statements. It performs step by step task by changing state.
Advantages of Imperative Programming
Paradigm
▪ Very simple to implement.
▪ It contains loops, variables etc.
Disadvantages of Imperative
Programming Paradigm
▪ Complex problem cannot be solved.
▪ Less efficient and less productive.
▪ Parallel programming is not possible.
Three Broad Categories of Imperative
Programming
▪ Procedural Programming Paradigm.
▪ Object Oriented Programming.
▪ Parallel Processing Approach.
Procedural Programming
▪ Procedural Programming can also be referred to as
imperative programming.
▪ It emphasizes on procedure in terms of under lying machine
model.
Procedural Programming
Features of Procedural Programming
▪ Procedural Programming is excellent for general-purpose
programming.
▪ The coded simplicity along with ease of implementation of
compilers and interpreters.
▪ A large variety of books and online course material
available on tested algorithms, making it easier to learn.
▪ The source code is portable.
Features of Procedural Programming
▪ The code can be reused in different parts of the program,
without the need to copy it.
▪ The program flow can be tracked easily as it has a top-
down approach.
Object Oriented Programming
▪ The program is written as a collection of classes and object
which are meant for communication.
▪ In this framework, all real-world entities are represented
by Classes.
▪ Objects are instances of classes so each object
encapsulates a state and behavior.
▪ State implies the fields; attributes of the object and
behavior is what you do with the state of the object and
they are the methods.
Object Oriented Programming
▪ State implies the fields; attributes of the object and
behavior is what you do with the state of the object and
they are the methods.
▪ Objects interact with each other by passing messages.
Object Oriented Programming
Features of Object Oriented
Programming
▪ Encapsulation - This is a fundamental feature of Object-
Oriented Programming. Here you hide unnecessary details
in classes and deliver a simple and clear interface for
working.
▪ Inheritance - Inheritance is one of the core concepts of
object-oriented programming (OOP) languages. It is a
mechanism where you can derive a class from another class
for a hierarchy of classes that share a set of attributes and
methods.
Features of Object Oriented
Programming
▪ Data Abstraction - Data abstraction is the reduction of a
particular body of data to a simplified representation of the
whole.
▪ Polymorphism - Polymorphism is an object-oriented
programming concept that refers to the ability of a variable,
function or object to take on multiple forms.
Advantages of Object Oriented
Programming
▪ Data Security
▪ Inheritance
▪ Code reusability
▪ Flexible and abstraction is also present
Parallel Processing Approach
▪ Parallel processing is the processing of program instructions
by dividing them among multiple processors.
▪ A parallel processing system posses many numbers of
processor with the objective of running a program in less time
by dividing them.
Declarative Programming Paradigm
▪ In computer science the declarative programming is a style of
building programs that expresses logic of computation
without talking about its control flow.
▪ It often considers programs as theories of some logic.
Declarative Programming Paradigm is
Divided into:
▪ Logic
▪ Functional
▪ Database
Logic Programming Paradigm
▪ It can be termed as abstract model of computation.
▪ It would solve logical problems like puzzles, series, etc.
▪ In logical programming the main emphasize is on knowledge
base and the problem. The execution of the program is very
much like proof of mathematical statement.
Functional Programming Paradigm
▪ The functional programming paradigms has its roots in
mathematics and it is language independent.
▪ The key principle of this paradigms is the execution of series
of mathematical functions.
Database / Data Driven Programming
Approach
▪ This programming methodology is based on data and its
movement.
▪ Program statements are defined by data rather than hard-
coding a series of steps. A database program is the heart of a
business information system and provides file creation, data
entry, update, query and reporting functions.
Programming Guidelines
▪ Programming Guidelines refer to a set of best practices and
guidelines that developers follow while writing code.
▪ These guidelines ensure that the code is efficient,
maintainable and free of errors.
Programming Guidelines
▪ Using Pseudo Codes
▪ Control Structure Guidelines
▪ Documentation Guidelines
Using Pseudo Codes
▪ Pseudo Codes is an informal language that describes the
steps to solve a problem or to write a program.
▪ It is a high–level description of the code that helps
programmers to plan and organize their code.
Benefits of Using Pseudo Codes
▪ Improves code readability
▪ Eases code maintenance and modification
▪ Facilitates communication among team members
Using Pseudo Codes
Example:
Enter value
if value greater than 10
say “your number is greater than 10”
if value is less than 10
say “your number is less than 10”
Control Structures Guidelines
▪ Control Structures are used to control the flow of execution
in a program.
▪ Control Structure Guidelines are the set of rules that
programmers should follow to use control structures
efficiently.
Control Structures Guidelines Include:
▪ Proper use of if-else statements
▪ Proper use of loops
▪ Avoidance of nested loops
▪ Proper use of switch-case statement
Control Structures Guidelines Examples:
Documentation Guidelines
▪ Documentation is the process of creating, collecting,
organizing, storing and sharing information about a program.
▪ Are set of rules that programmers should follow to
document their code efficiently.
Documentation Guidelines Include:
▪ Proper use of Comments
▪ Clear naming conventions for variables and functions
▪ Use of meaningful function and variable names
▪ Proper use of white space
References:
https://www.geeksforgeeks.org
https://www.studocu.com
https://www.scribd.com
Prepared by:
Engr. Laila C. Hernandez, PCpE
MS Computer Engineer