Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
37 views

Lesson2-Program Design Development

The document discusses concepts related to programming and software design. It covers topics like software design approaches, top-down and bottom-up design, types of program errors including syntax, logical and semantic errors, and program design tools such as pseudo codes, flowcharts and algorithms. Examples of algorithms, flowcharts and pseudo code are also provided to illustrate various concepts.

Uploaded by

Jumbo Jet
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Lesson2-Program Design Development

The document discusses concepts related to programming and software design. It covers topics like software design approaches, top-down and bottom-up design, types of program errors including syntax, logical and semantic errors, and program design tools such as pseudo codes, flowcharts and algorithms. Examples of algorithms, flowcharts and pseudo code are also provided to illustrate various concepts.

Uploaded by

Jumbo Jet
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

DBT 1201 PROGRAMMING CONCEPTS

Peter Mackenzie petnjau@gmail.com


CHAPTER TWO:
PROGRAM DESIGN & DEVELOPMENT
SOFTWARE DESIGN

 Software design is a process to conceptualize the


software requirements into software implementation.
 Software design takes the user requirements as
challenges and tries to find optimum solution.
 While the software is being conceptualized, a plan is
chalked out to find the best possible design for
implementing the intended solution.
SOFTWARE DESIGN APPROACHES

 There are two generic approaches for software


designing:
1. Top Down Design
2. Bottom Up Design
TOP DOWN DESIGN
 We know that a system is composed of more than one sub-
systems and it contains a number of components.
 Further, these sub-systems and components may have their on
set of sub-system and components and creates hierarchical
structure in the system.
 Top-down design takes the whole software system as one
entity and then decomposes it to achieve more than one sub-
system or component based on some characteristics.
 Each sub-system or component is then treated as a system and
decomposed further.
 This process keeps on running until the lowest level of system
in the top-down hierarchy is achieved.
CONT.….

 Top-down design starts with a generalized model of


system and keeps on defining the more specific part of
it.
 When all components are combined the whole system
comes into existence.
 Top-down design is more suitable when the software
solution needs to be designed from scratch and
specific details are unknown.
BOTTOM UP DESIGN
 The bottom up design model starts with most
specific and basic components.
 It proceeds with composing higher level of
components by using basic or lower level
components.
 It keeps creating higher level components until the
desired system is not evolved as one single
component.
 With each higher level, the amount of abstraction
is increased.
CONT.…..

 Bottom-up strategy is more suitable when a


system needs to be created from some existing
system, where the basic primitives can be used
in the newer system.
 Both, top-down and bottom-up approaches are
not practical individually. Instead, a good
combination of both is used.
TYPES OF PROGRAM ERRORS
 Program errors are also referred to as program
bugs.
 The are three types of program errors:
1. Syntax Error
2. Logical Error
3. Semantic Error
SYNTAX ERRORS
 Syntax errors: errors due to the fact that the syntax of
the language is not respected.
 Syntax errors represent grammar errors in the use of the
programming language.
 Common examples are:
1. Misspelled variable and function names
2. Missing semicolons
3. Unmatched parentheses, square brackets, and curly braces
4. Using a variable that has not been declared
5. Incorrect format in selection and loop statements
SYNTAX ERRORS
 Let us see examples of syntax errors
SEMANTIC ERRORS
 Semantic errors: errors due to an improper use of
program statements.
 Example 1: Use of a non-initialized variable:
int i;
i++; // the variable i is not initialized
 Example 2: Type incompatibility:
int a = "hello"; // the types String and int are not compatible
LOGICAL ERRORS

 Logical errors: errors due to the fact that the


specification is not respected.
PROGRAM DESIGN TOOLS

 The various ways of presenting a problem


solution design.
 Some common ways include:-
1. Pseudo codes
2. Flow charts
3. Jacksons structure diagrams (JDS)
4. Algorithms
ALGORITHMS
 algorithm – It is a finite set of steps that must be followed
to solve any problem .
 Algorithm is generally developed before the actual coding is
done.
 An algorithm is a representation of a solution to a problem.
 It is written using English like language so that it is easily
understandable even by non-programmers.
 Sometimes algorithms are written using pseudo codes, i.e. a
language similar to the programming language to be used.
CONT…

 An algorithm is procedure consisting of a finite set of


unambiguous rules (instructions) which specify a finite
sequence of operations that provides the solution to a
problem, or to a specific class of problems for any
allowable set of input quantities (if there are inputs).
 In other word, an algorithm is a step-by-step
procedure to solve a given problem
ADVANTAGES OF ALGORITHMS
 Writing algorithm for solving a problem offers these
advantages −
1. Promotes effective communication between team members
2. Enables analysis of problem at hand
3. Acts as blueprint for coding
4. Assists in debugging
5. Becomes part of software documentation for future
reference during maintenance phase
CHARACTERISTICS OF GOOD ALGORITHM

 These are the characteristics of a


good and correct algorithm −
1. Has a set of inputs
2. Steps are uniquely defined
3. Has finite number of steps
4. Produces desired output
EXAMPLE ALGORITHMS

 Let us first take an example of a real-life situation for creating


algorithm. Here is the algorithm for going to the market to
purchase a pen.
CONT.…
 Step 4 in this algorithm is in itself a complete task and separate
algorithm can be written for it.
 Let us now create an algorithm to check whether a number is
positive or negative.
FLOWCHART
 Flowchart is a diagrammatic representation of
sequence of logical steps of a program.
 Flowchart is a pictorial representation depicting the
flow of steps in a program, people in an organization,
or pages in a presentation.
 Flowcharts use simple geometric shapes to depict
processes and arrows to show relationships and
process/data flow.
FLOWCHART SYMBOLS
GUIDELINES FOR DEVELOPING FLOWCHARTS
 These are some points to keep in mind while developing a
flowchart −
1. Flowchart can have only one start and one stop symbol
2. On-page connectors are referenced using numbers
3. Off-page connectors are referenced using alphabets
4. General flow of processes is top to bottom or left to
right
5. Arrows should not cross each other
EXAMPLE FLOWCHARTS
 Here is the flowchart for going to the market to purchase a pen.
CONT.….
 Here is a flowchart to calculate the average of two numbers.
FOR MORE INFORMATION ABOUT FLOWCHARTING
SOFTWARE, CHECK THE FOLLOWING WEB SITES:

1. CorelFlow http://www.corel.com

2. Inspiration http://www.inspiration.com

3. Lotus Notes http://www.lotus.com

4. Microsoft Project : http://www.microsoft.com

5. Primavera Project Planner: http://www.primavera.com

6. Process Charter http://www.scitor.com

7. SmartDraw http://www.smartdraw.com

8. TeamFlow http://www.teamflow.com

9. Visio http://www.microsoft.com/office/
EXAMPLES OF ALGORITHMS AND FLOWCHARTS

 Example 1.
 Design an algorithm and the corresponding
flowchart for adding the test scores as given
below:
26, 49, 98, 87, 62, 75
A) ALGORITHM
THE CORRESPONDING FLOWCHART IS AS
FOLLOWS:
CONT..
PSEUDO CODE

 Pseudocode is an artificial and informal language that


helps programmers develop algorithms.
 Pseudocode is a "text-based" detail (algorithmic)
design tool.
 Pseudo code is a detailed yet readable description of
what a computer program or algorithm must do,
expressed in a formally-styled natural language
rather than in a programming language.
CONT.….

 Pseudo code is sometimes used as a detailed step in


the process of developing a program.
 It allows designers or lead programmers to express
the design in great detail and provides programmers a
detailed template for the next step of writing code in
a specific programming language.
 Because pseudo code is detailed yet readable, it can
be inspected by the team of designers and
programmers as a way to ensure that actual
programming is likely to match design specifications.
THE RULES OF PSEUDO CODE

 All statements showing "dependency" are to be indented.


 These include while, do, for, if, switch.
 Examples below will illustrate this notion.
THE RULES OF PSEUDO CODE
1. Consists of natural language-like statements that precisely
describe the steps of an algorithm or program
2. Statements describe actions
3. Focuses on the logic of the algorithm or program
4. Avoids language-specific elements
5. Written at a level so that the desired programming code can
be generated almost automatically from each statement
6. Steps are numbered. Subordinate numbers and/or indentation
are used for dependent statements in selection and repetition
structure
EXAMPLE

If student's grade is greater than or equal to 60


Print "passed“
else
Print "failed“
End if
EXAMPLE 2

You might also like