0% found this document useful (0 votes)
42 views22 pages

BMS 201 C++Programming Concepts 2021

1. Modular programming divides a program into modules that can be developed separately but coordinated as a suite. This allows programs to be prepared by a team and available more quickly. 2. Structured programming organizes programs in a way that increases readability, testability, debuggability, and modifiability. It assists in developing large programs through stepwise refinement and modularity. 3. Object-oriented programming (OOP) models real-world problems by decomposing them into discrete objects that combine data and behaviors. OOP emphasizes data over procedures and allows for easier addition of new data and functions.

Uploaded by

Brian Mutua
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
0% found this document useful (0 votes)
42 views22 pages

BMS 201 C++Programming Concepts 2021

1. Modular programming divides a program into modules that can be developed separately but coordinated as a suite. This allows programs to be prepared by a team and available more quickly. 2. Structured programming organizes programs in a way that increases readability, testability, debuggability, and modifiability. It assists in developing large programs through stepwise refinement and modularity. 3. Object-oriented programming (OOP) models real-world problems by decomposing them into discrete objects that combine data and behaviors. OOP emphasizes data over procedures and allows for easier addition of new data and functions.

Uploaded by

Brian Mutua
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 22

Programming Concepts

MODES OF PROGRAMMING
 Monolithic programming refers to the
largely undisciplined and non formalized
approach to the development of a
computer programs in which the
programme is allowed a completely free
rein. Programs produced in this way
reflect the programmer's own experience
and personal interpretations.
 become available more quickly as a

result.
MODES OF PROGRAMMING
 Modular programming is the approach to
programming that adopts a technique of
developing suites of related programs. The
overall program is divided into parts or
modules, each of which is developed
separately but on a coordinated basis. This
enables the complete suite of programs to be
prepared by the team of programmers if
appropriate and programs become available
more quickly as a result.
MODES OF PROGRAMMING
 Structured programming is an approach to
writing programs that are easier to read, test,
debug and modify. The approach assists in the
development of large programs through
stepwise refinement and modularity.
Structured programming serves to increase
programmer productivity, program reliability
(readability and execution time), program
testing, program debugging and serviceability.
MODES OF PROGRAMMING
 Macros – these are single instruction written
as a part of a program that will generate many
machine code instructions. They are
applications software commands which are
batched to perform a certain task which is
performed frequently. When the usual task is
to be performed, the invoking key to the
macro is pressed and the task is performed.
They are also useful where a user defines own
macros to facilitate the use of an application
package.
PROGRAMMING PARADIGMS

 The Procedure Oriented Programming (POP)


and Object Oriented Programming (OOP) are
basically two different paradigms for writing
code; more fundamentally, they are two
different ways of thinking about and
modelling the problem's solution. The OOP
deals with the elemental basic parts or
building blocks of the problem, whereas POP
focuses on the steps required to produce the
desired outcome.
PROGRAMMING PARADIGMS

 Note: The language used for writing code does


not determine if a program is Object Oriented
or Procedural; Object Orientation and
Procedural, is a way of solving the problem or
a way of thinking about the problem, not the
language used to write the code. It is possible
to write Object Oriented Programs in C (I.e.
POP language); and a Procedural Oriented
program in Java (i.e. an OOP language).
PROCEDURE ORIENTED PROGRAMMING (POP) TECHNIQUE

 This is a programming paradigm where a structured


method of creating programs is used. With POP, a
problem is broken up into parts and each part is then
broken up into further parts, which are known as
procedures and are centrally controlled by a main
program. A procedure call is used to invoke the
procedure. After the sequence is processed, flow of
control proceeds right after the position where the call
was made. Examples of procedure-oriented languages
are COBOL, FORTRAN, Pascal and C.
PROCEDURE ORIENTED PROGRAMMING (POP) TECHNIQUE

 Example: Consider the problem: "calculate the month


end closing balance for an account."
 The process is take the starting balance, subtract all the

debits and adds all the credits for the period and then
you arrive at closing balance. The key point for
procedural programming is identification and
articulation of the process or steps that must be
followed. In general terms, POP is a methodology for
modelling the real world or the problem being solved,
by determining the steps and the order of those steps
that must be followed in order to reach a desired
outcome or specific program state.
Characteristics of POP

 The emphasis is on algorithms


 The data moves openly around the system form one

function to another
 The large programs are divided into smaller programs

(i.e. functions)
 Most of the functions share global data
 It uses the top-down approach in program design
POP limitations:

 The POP does not model the real world problems very
well because its functions are action-oriented, hence
the functions do not correspond to the elements of the
problem.
 The programmers are forced to re-invent new solutions

to old problems, because whenever an external data


structure is being modified, all the functions that access
the data must also be revised.
OOP TECHNIQUE

 OOP is a methodology for modelling the real world (or at least the
problem being solved), by decomposing the problem into smaller
discrete pieces called objects.
 What makes an object unique is the formal and explicit
combination these smaller pieces' behaviour with its data into a
single entity. The object's behaviours are called methods in OO
terminology, while its data is called the Object's state.
 The OOP approach provides a way of modularizing programs by
creating partitioned memory area of both data and functions that
can be used as templates for creating copies of such modules on
demand.
 The OOP ties the data more closely to the functions that operate on
it, and protects it from accidental modification by external
functions.
 The OOP allows the decomposition of a problem into a number of
objects and then builds data and functions around the objects.
The characteristics of OOP
 The emphasis is on data rather on procedure
 Programs are divided into objects
 Data is hidden and cannot be accessed by external functions
 Objects communicated with each other through functions
 New data and functions can be easily added whenever necessary
 Functions that operate on the data of an object are tied together in
the data structure
 Data structures are designed in such a way that they characterize
the objects
 OOP uses the bottom-up approach in program design (i.e. the
overall program development is based upon the known
characteristics of the individual modules.
BASIC CONCEPTS OF OOP

 Object: An entity having an interface that hides its data


and sub-programs. It is a self-contained entity which
has an identity and characteristics of its own. An object
may represent; a person, a place, a bank account, a
table of data or any item that the program has to
handle. The programming problem is analyzed in terms
of objects and the nature of communication between
them. Whenever the program is executed, the objects
interact by sending messages to one another.
 Example: If a “Customer” and “Account” are two

objects in a program, then the Customer object may


send a message to the Account object requesting for the
account balance.
BASIC CONCEPTS OF OOP

 Class: This is a collection of objects of similar type


which is used as a template to replicate a particular
kind of object. Classes are thus like cookie cutters: they
are not cookies themselves, but are used to stamp out
identical cookies. Each different cookie cutter (class)
produces a different shape of cookie (object). Once
produced, different cookies are independent of one
another, even if they were made using the same cookie
cutter.
Basics concepts of OOP
 Inheritance: The ability to create a new class by adding to
or overriding parts of an existing class. The objects of the
new class acquire the properties of objects of another class.
This concept supports the concept of hierarchical
classification (i.e. each derived class shares common
characteristics with the class from which it is derived). The
inheritance concept provides the idea of re-usability
 Class Hierarchy: This refers to a set of classes and their
interrelationships. It helps to picture class hierarchies to be
having super-class (parent class) at the top and the subclass
(child classes) below.
 Polymorphism: The ability to take more than one form. It
can also be defined as the ability to use the same syntax for
objects of different types.
Example
 Example:
 In some programming languages, the addition

operation:
 For two numbers generates a sum.
 e.g.: 3 + 5 = 8,
 For two words generates a third string through concatenation of
the wo
 strings. e.g.:
 Computer + Programming =
ComputerProgramming
Example
 In OOP, polymorphism is used to describe variables
which may refer at run time to objects of different
classes. A single function can be used to handle
different number and different types of arguments. The
usage of a function to perform different types of tasks
is referred to as overloading
 Interface: This refers to a boundary across which two

systems communicate. Polymorphism allows objects of


different internal structures to share the same external
interface. This implies that a general class of operations
may be accessed in the same manner even though
specific actions associated with each operation may
differ.
Basic concepts of OOP
 Method: This refers to a procedure or routine associated
with one or more classes.
 Encapsulation: The ability to provide users with a well-
defined interface to a set of functions in a way which hides
their internal workings. In OOP, this is the technique of
keeping together data structures and the methods
(procedures) which act on them. This insulation of data from
direct access by a program is known as data hiding or
information hiding.
 Data Abstraction: refers to the act of representing essential
features without including the background details or
explanations.
Basic Concepts of OOP
 Private: This refers to either a variable or a method
which is known only to its class. (i.e. Exclusive use in
the program.)
 Public: If a method or variable is public, it is known to

every part of the program. (i.e. General use in the


program.)
 Dynamic Binding: Refers to the linking of a procedure

call to the code to be executed in response to the call.


The code associated with a given procedure call is not
known until the time of the call at run-time.
Basic Concepts of OOP
 Message Passing: This refers to the act of sending a
message from one object to another. It involves
specifying the name of the object, the name of the
function (message) and the information to be send
 Example:
 Employee . Salary (name)
 Object Message Information
 This concept enables the building of systems that

directly model or simulate their real-world counter-


parts.
BENEFITS OF OOP

 Redundant code can be eliminated


 The use of existing classes can be extended
 Data hiding helps in building secure programs
 It is easy to divide up the tasks of a project that is based on
objects
 Possible to have multiple instances of an object to co-exist
without any interference
 The data-cantered design approach enables the capturing of more
details of a model in implementable form.
 Object-oriented programs can easily be upgraded from small to
large systems.
 The interface descriptions with external systems is made simple
 Programs can easily be made from the existing ones.

You might also like