0% found this document useful (0 votes)
14 views25 pages

PROGRAMMING ALGORITHM 2

Uploaded by

meemerabubakar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views25 pages

PROGRAMMING ALGORITHM 2

Uploaded by

meemerabubakar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 25

PROGRAMMING &

ALGORITHM
CSC 237
BY
DR WALTER IBE
REVIEW

 Programming languages are languages through which we can instruct


the computer to carryout processes and tasks.

 A program is asset of codes that instructs the computer to carry out


some processes while programming is the act of writing programs.

 There are four levels of the programming language

 machine language, low level language, assembly language and high


level language.
REVIEW CONT
 There are various programming
methodologies: procedural programming >
object oriented programming> functional>
logic (declarative) >event driven >concurrent
programming.
 Types
of translators- Assembler, Interpreters
and Compilers.
 Programming environment consists of the
editor, translator and the linker/loader
 Language evaluation criteria are Readability,
Simplicity, Reliability, Expressivity and
Pedagogy
PROGRAMMING CONCEPTS

Program Development Cycle


Program Execution Stages
Principles of Good Programming
Style
Programming paradigms
Object-oriented modeling
Conclusion
Summary
OBJECTIVES

 Explain the five major steps involved in developing


an efficient program

 Outline the four stages involved in the execution of


a normal program

 Outline the principles of a good programming style.

 Understand programming paradigms


The Program Development Cycle
 Refers to the various stages involved in the
lifespan of a computer program from its origin until
completion or closure.
 The program development life cycle is a set of
steps or phases that are used to develop a
program in any programming language.
 Addresses 3 main attributes:
 Stakeholders of the program (i.e. organization)
 Benefits acquired from the program (the
deliverables)
 Rules governing the development of the program
lifecycle (i.e. expectation and documentations).
Major steps in Program
development

 Problem Analysis
 Design

 Coding

 Testing & Debugging


 Documentation
Explanations
 Problem Analysis: The programmer must be sure that he
understands the problem and how to solve it by stating a clear
statement of the problem. He must know the nature of the output
and the input.
 Design: The planning consists of the process of finding a logical
sequence of precise steps that solve the problem. Such a sequence
of steps is called an algorithm. The three popular methods used to
develop the logic plan are: flowcharts, Pseudo code, and a top-down
chart.
 Coding: Translation of the algorithm in stage two into a
programming language takes place here. The process of writing the
program is called coding.
 Testing and Debugging: Testing is the process of checking if the
program is working as expected and finding errors in the program,
and debugging is the process of correcting errors that are found
 Documentation: This is the final stage of program development. It
consists of organising all the material that describes the program.
The document at ion of the program is intended to allow another
Program Execution Stages

 The normal program execution consists of four(4) stages


 The Program (Source Code):
 The Compilation Process:
 The Object Code:
 The Output:
Program Development Chart
Explanation of Program
Development Stages
 The Program (Source Code): The coded instruction given to the computer in a
particular programming language in order to accomplish a given task. It must obey the
syntactic and semantic rules.

 The Compilation Process: The process of compilation involves reading the source
code, checking for errors in the source code and converting it to an executable
format(machine code) if no error is detected

 The Object Code: The object code is the result of the compilation process and it is
also called the target code. The object code is dependent on the programming
language chosen.
 Eg. JAVA (bytecode), Fortran (executable statement of the target machine), BASIC
(target machine language) etc

 The Output: The last stage is for the computer to give the result. The computer
executes the object code in order to present the desired output. It is important to note
that a valid or desired output might not be given if the logic of the program is not
Principles of a Good Programming
Style
 The following represent the major considerations in
writing good programs:-
 Naming Conventions:
 File Naming and Organization:
 Formatting and Indentation:
 Comments and Documentation:
 Classes:
 Functions:
 Using STL:
 Pointers and References:
 Minimizing Bugs by Testing:
Quality of a good programming
style
 1) Naming Conventions:
 It is very important to give meaningful names to all your constructs. A
name like get_Height() or get_avg_height()gives us much more
information than ctunde()
 Class name should start with an uppercase letter, e.g. class AddPrime
 Variable name should start with a lowercase letter, e.g. firstQuad;
 Functions should be named similar to variables.

 2) File Naming and Organization:


 Files should be organized into directories in a module-wise fashion
instead of having a monolithic structure where all source code files and
all header files are in a single directory. This should be part of the
design process.
Quality of a good programming
style
3) Formatting and Indentation: The lines within the code should be
clearly organized in a way that it will be easy to read and understand
even for the writer.
4) Comments and Documentation: Introducing comments and proper
explanations to the program will aid understanding, amendment and
extensibility of the code.
5) Classes: Ensure that all the classes in your application have a default
constructor, copy constructor and overloaded operator. Also ensure that
all the class data items are appropriately initialised in constructor and
assigned to each member of the class.
Quality of a good programming
style
6) Functions: A function should normally do only one job and do it well.
Make functions simple and small, around 35- 40 lines.
7) Using STL: Use Standard Template Library (STL) instead of creating
your own container data structures.
8) Pointers and References: Use references, especially if coding in C++,
encourages the use of references instead of pointers.
9) Minimizing Bugs by Testing: Tests help us not only in making sure that
what we have written is correct, but also in finding out if someone
breaks the code later.
Aspects of programming

 There are two fundamental aspects of programming: Objects and


Operations.
 The objects are entity that receive instructions to perform a particular
method or actions
 Operations are the events that direct the behavior of an object.
Programming paradigms

 A Programming paradigm is a method or style of programming that


defines a set of guideline, principles, techniques and patterns used to
format programming instructions or structure the code to solve
problems on a computer.
 The three main programming paradigms are:
 Imperative: Eg Procedural Programming(COBOL, ForTran)
 Functional: Eg Declarative Programming paradigm(Lisp, Scala,
Haskell, Erlang)
 Object-oriented:JAVA, C++, Ruby, Python etc
Imperative Programming Paradigm
 Imperative is programming approach that uses
statements to change a programs state by directly
commanding the computer step by step on how to
perform the tasks.
 There are 2 main categories Procedural languges and
OO languages
 To control the flow
 Sequence
 Iteration
 Selection
Functional Programming Paradigm
 Functional Programming Paradigm is a style of
programming which models computations as
the evaluation of expressions or functions.
 They are designed around the concept of
mathematical functions, manipulating data
using functions without changing its state
 Functions are the main entities
 Example: Scala, Haskell, Erlang, Clojure etc
Object Oriented Programming
 Paradigm
Is paradigm that relies the concept of objects
and classes to organise code in a modular and
reuseable way

 Model
the real world entities and relationship
between them using its key components like
 Object and Classes
 Encapsulation
 Inheritance
 Polymorphism
Object-oriented Modeling(OOM)
 Is a common approach to modeling
programs by using object-oriented paradigm
throughout the entire development life
cycle.
 This is the main technique used in modern
software engineering.
 The OOM typically divides programming life
cycle into two aspects:
 - Modeling of the dynamic behaviors like
processes and use cases
- Modeling the static structures like classes
and components
Advantages of using OOM
 Efficient
and effective communications
between the system and the real world

 Useful and stable abstractions that define


essential structures and behavior within the
system under development
CONCLUSION

 Now that you know you, should be


able to write a good program following
a good programming convention, apart
from learning the cycle of program
development.
Thank you
Assignment

You might also like