Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

PROGRAMMING CONSTRUCTS & PARADIGMS

PROGRAMMING STANDARDS AND PROCEDURES


Programming standards and procedures refer to a set of guidelines and best
practices that developers follow while writing code. these guidelines ensure that
the code is efficient, maintainable and free of errors
IMPORTANCE OF PROGRAMMING STANDARDS
AND PROCEDURES
make the code easier
make the code more maintainable and easier to modify
reduce the chances of introducing errors into the code
ensure that the code is efficient and performs well
help ensure that the code is secure
PROGRAMMING PARADIGMS
Refers to a specific approach to writing code. there are four main
programming paradigms:

OBJECT ORI ENTED PROGRAMMI NG (OOp) Functional Programming

Logic Programming Procedural Programming


OBJECT ORIENTED PROGRAMMING (OOp)

Object-Oriented Programming
(OOP) is a programming paradigm
in computer science that relies on
the concept of classes and
objects. It is used to structure a
software program into simple,
reusable pieces of code blueprints
(usually called classes), which are
used to create individual instances
of objects. There are many object-
oriented programming languages,
including JavaScript, C++, Java,
and Python.
characteristics of OOp

ENCAPSULATION
refers to the bundling of data, along
with the methods that operate on
that data, into a single unit.
Containers are just one example of
encapsulation in coding where data
and methods are bundled together
into a single package. A key
benefits to hiding information about
attributes and methods using
encapsulation in programming is
that it prevents other developers
from writing scripts or APIs that use
your code.
characteristics of OOp

INHERITANCE
When a class derives from another class. The child class will inherit all the public and
protected properties and methods from the parent class. In addition, it can have its
own properties and methods. An inherited class is defined by using the extends
keyword.
For example, a child inherits the traits of his/her parents. With inheritance, we can
reuse the fields and methods of the existing class.
characteristics of OOp

POLYMORPHISM
Polymorphism is another fundamental
concept in OOP, which means multiple
forms. Polymorphism allows the use of
a single interface with different
underlying forms, such as data types
or classes.
Polymorphism means one function
with multiple functionalities or
representations
BENEFITS OF USING OOP

Reusability of code
Improved code organization
Improved code maintainability
Improved code security
FUNCTIONAL PROGRAMMING

Functional programming is a programming paradigm that focuses on the


evaluation of mathematical functions to perform computations.

Functional programming also emphasizes the use of recursion instead of


loops to perform repetitive tasks.

Functional programming can be useful in scenarios where the program


needs to perform complex mathematical computations or data
transformations, such as in machine learning or data analytics.

Functional programming languages include Haskell, Lisp, and Scala, but


many mainstream programming languages such as JavaScript and Python
also support functional programming paradigms.
Characteristics of FUNCTI ONAL PROGRAMMI NG

Pure Functions:
Pure functions are functions that have no side effects and always return the same output
given the same input. This means that the function does not modify any variables outside its
scope, and it does not rely on variables outside its scope. Pure functions have several
advantages, including that they are easier to reason about, test, and debug, and they can be
safely executed in parallel.

Immutability:
In functional programming, data is treated as immutable, meaning that once a value is
assigned, it cannot be changed. Instead, new values are created by applying transformations
to existing values. This ensures that data is not accidentally modified in unexpected ways, and
it simplifies reasoning about program behavior. Immutable data also makes it easier to write
concurrent and parallel code, because data can be safely shared between threads without
fear of conflicts.
Characteristics of FUNCTI ONAL PROGRAMMI NG

Higher-order
Functions:

Higher-order functions are functions that take other functions as arguments or


return functions as results. This allows for powerful abstractions and composability,
and enables developers to write reusable code that can be applied to a wide
range of problems. Higher-order functions can be used for a variety of purposes,
such as creating new functions on the fly, implementing generic algorithms, and
controlling program flow. They are a fundamental concept in functional
programming and are used extensively in modern functional programming
languages like Haskell, OCaml, and F#.
Benefits of FUNCTIONAL PROGRAMMI NG

Easier debugging:

Because functional programs are composed of pure functions, they do not have
side effects or dependencies on external state. This makes it easier to reason about
the behavior of the program and debug issues that may arise.

Better code maintainability:

Functional programming emphasizes the use of small, reusable functions that can
be combined to create larger programs. This modular approach to programming
makes it easier to modify and maintain code over time, as changes to one function
can be made without affecting other parts of the program.
Benefits of FUNCTIONAL PROGRAMMI NG

Better scalability:

Functional programming can be highly parallelized, which makes it well-suited for


distributed and concurrent systems. This makes it easier to scale up the program
to handle large amounts of data or traffic.

Improved code quality:


Functional programming encourages the use of pure functions, immutability, and
other best practices that can lead to code that is more reliable, easier to test, and
less prone to errors. Additionally, the functional programming paradigm can help
eliminate certain types of bugs that can arise in imperative programs, such as
those caused by mutable state.
Logic programming

Logic Programming is a type of


Programming Paradigm that is based
on the concept of formal logic. It is
primarily used for building intelligent
systems that can solve complex
problems by representing them as a set
of logical rules.

The most popular Logic Programming


language is Prolog, which stands for
"Programming in Logic". Prolog is a
declarative programming language,
which means that the programmer
specifies what the program should do,
rather than how it should do it.
characteristics of logi c programmi ng

DECLARATIVE
Logic Programming is a declarative programming paradigm, which means that the programmer
specifies what the program should do, rather than how it should do it. The program consists of a
set of logical rules and constraints that are used to derive solutions to the problem.

NON-PROCEDURAL
Logic Programming is a non-procedural programming paradigm, which means that the
programmer does not need to specify the sequence of steps to solve the problem. The program
derives the solution by applying logical rules and constraints.

BACKTRACKING
Backtracking is a key feature of Logic Programming, which allows the program to search for a
solution by trying different possibilities. If one possibility fails, the program backtracks and tries
another possibility.
Benefits of logic programmi ng

NATURAL LANGUAGE REPRESENTATION


Logic Programming allows the programmer to express the problem in natural language,
which makes it easier to understand and communicate

EASY TO DEBUG
Logic Programming is easy to debug because the program consists of a set of logical
rules and constraints that are easy to verify.

FLEXIBLE
Logic Programming is very flexible and can be used to solve a wide range of problems,
including those that are difficult to solve using other programming paradigms.

EFFICIENT
Logic Programming is often more efficient than other programming paradigms because it
uses backtracking to search for a solution, rather than brute force.
procedural programming
Procedural Programming is a
programming paradigm that
focuses on the procedure, or
sequence of statements, that are
executed to achieve a specific task.
In Procedural Programming, a
program is structured in terms of
procedures, which are also known as
functions, subroutines or methods.
These procedures can be called by
other procedures or from the main
program to accomplish a task.
characteristics of Proceduralprogrammi ng

MODULARITY
Programs written in procedural languages are divided into small modules or
procedures, which makes it easier to understand and maintain the code.

SEQUENTIAL EXECUTION
Procedural languages execute the code in a sequential manner, from top to
bottom. This means that the program follows a set order of execution.

REUSABILITY
Procedures can be reused throughout the code, which makes the code more
efficient and reduces the need for repetitive coding.
Benefits of procedural programming

Easy to learn

Code Reusability

Faster Execution

Structured Programming
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.

Usi ng pseudo codes control structure guidelines

documentation guidelines
Using pseudo codes

Pseudo Code 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. The
benefits of using Pseudo Code include:

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. The
Control Structure Guidelines include:
1. Proper use of if-else statements
2. Proper use of loops
3. Avoidance of nested loops
4. Proper use of switch-case statements
control structures guidelines
Example:
Swtich-case

If-else
Documentation Guidelines

Documentation is the process of creating, collecting, organizing,


storing, and sharing information about a program. Documentation
Guidelines are the set of rules that programmers should follow to
document their code efficiently. The Documentation Guidelines
include:
1. Proper use of comments
2. Clear naming conventions for variables and functions
3. Use of meaningful function and variable names
4. Proper use of white space

You might also like