2.1 FundamentalProgrammingConcepts
2.1 FundamentalProgrammingConcepts
Programming Techniques
Accenture
Accenture2007
2007All
AllRights
RightsReserved
Reserved
Course Approach
Learn by Doing
Hands-on programming
Activity-based Learning
Activities are designed to be difficult but doable
Activities have time limits to encourage wise use of
your time
Activities will force you to research on the required
knowledge
Resource-rich Environment
Use available resources (i.e., online/offline materials,
human resources, etc)
Encourage research and learning on your own
Accenture 2007 All Rights Reserved
USTGlobal
USTGlobal
USTGlobal
Contents
Algorithm
Benefits
of Algorithm
Approaches to Algorithm
Efficiency of Algorithm
Structure of Algorithm
Flowchart
Benefits of Flowchart
Concept of Testing
Unit Testing
Accenture 2007 All Rights Reserved
USTGlobal
Objective
At the end of this section, you should be able to:
Describe and understand the need of
algorithms
Measure the efficiency of Algorithms
Understand the advantages & disadvantages
of Flowcharts
Work with Flowcharts
Describe the concepts of testing
Implement Unit Testing
Accenture 2007 All Rights Reserved
USTGlobal
What is an Algorithm
is detailed sequence of actions to
perform or accomplish some task
An Algorithm is a solution to a problem that is
independent of any programming language.
Algorithm
An algorithm is:
Benefits of Algorithm
An
USTGlobal
Analyzing An
Algorithm
There
Hybrid approach
Combination of Empirical and theoretical
USTGlobal
approach
Algorithm
Complexities
Complexities
Few
Space Complexities
Is the amount of memory it needs to run to completion
Accenture 2007 All Rights Reserved
USTGlobal
10
Structure of an
Algorithm
Algorithm
Begin
Step
Control
Comments
Variables
Input / Output
Exit
USTGlobal
11
Begin
Input num1,num2
Sum=num1+num2
Print Sum is= ,Sum
End
End of Algorithm
Accenture 2007 All Rights Reserved
Input is used to
perform read values to
num1 & num2
print is used to
print the output
(result)
USTGlobal
12
Algorithm concepts
There
Sequential
Modules are executed in some sequence/ in a linear
fashion
Multi Alternative
Having a multiple conditions to qualify any test
Iterational
Looping statements
Repeat step m thru n ,N times
USTGlobal
13
1.
2.
3.
4.
5.
6.
Begin
Print Enter Marks of 3 subjects
Input Marks1, Marks2, Marks3
AVG = (Marks1+Marks2+Marks3) / 3
Output Average Marks =, AVG
End
Implementation of
Sequential
Algorithm Method
Accenture 2007 All Rights Reserved
Output:
14
Begin
Print Enter Marks of 3 subjects
Input Marks1, Marks2, Marks3
Avg = (marks1+marks2+marks3)/3
If (Avg >= 50) Then Print Passed
End
Implementation of
single Alternative
algorithm
Accenture 2007 All Rights Reserved
Output:
15
Example:
1.
2.
3.
4.
5.
Begin
Print Enter Marks of 3 subjects
Input marks1, marks2,marks3
Avg=marks1+marks2+marks3)/3
If (Avg >= 50) Then
Print Passed
Else
Print Failed
End
Implementation of
Multiple
Alternative
algorithm
Accenture
2007 All Rights Reserved
Output:
16
Implementation
of Iteration
Algorithm
17
Flowcharts
is a graphic representation of the logic
or steps in a program or system
The flowchart can be defined as a diagram of the
problem solving steps in a process
A flowchart is a schematic representation of a
Flowchart
process.
USTGlobal
18
Flowchart depictions
Each symbol depicts a
Start End points
process
The start point, end points, Processing Logic
inputs, outputs, etc are
represented by a graphical Input/Output
image
Any flow chart should
Decisions
have
Start in the beginning
Connectors
End to the end of the
flow chart
Flow Line
Depending on the
Loops
requirement, rest of the
Accenture 2007symbols
All Rights Reserved
are used
USTGlobal
19
Flowchart Example 1
Example of Flow chart to read marks of three subjects. Find the average scored
by the student, and print Pass if the score is more than 50 otherwise print Fail
for N number of Students
Start
Enter m1,m2,m3
Avg=m1+m2+m3/3
Avg>50
Fail
pass
end
Accenture 2007 All Rights Reserved
USTGlobal
20
Disadvantage
Communication
Complex logic
Effective analysis
Proper documentation
Efficient Coding
Proper Debugging
Accenture 2007 All Rights Reserved
USTGlobal
21
Testing
is a process used to help identify the
correctness, completeness and quality of
developed computer software.
Testing is the process of running a system with
the intention of finding errors
It enhances the integrity of a system by detecting
deviations in design and errors in the system.
It aims at detecting error-prone areas, which helps
in the prevention of errors in a system.
Testing also adds value to the product by
conforming to the user requirements.
It is Oriented to 'detection'
Testing
USTGlobal
22
Unit Testing
A
Unit
It
The
Most
USTGlobal
23
Unit Testing
Entry criteria:
After completion of each class/method, unit
testing should be done.
Exit criteria:
Functionality is achieved
All requirements tested & verified
Result:
No Incorrect data, or data recorded in the wrong
field, account or database
No side-effects or bugs remain vis--vis
functionality
No errors in calculations, formulas or rounding
No
data
corruption errors
Accenture 2007
All Rights
Reserved
USTGlobal
24
Test Cases
case is a set of test inputs, execution
conditions, and expected results developed for a
particular objective, such as to exercise a particular
program path or to verify compliance with a specific
requirement
Test
Test
Test
9.
Begin
Print Enter number of students
Input N
Repeat step 4 thru step 8, N TIMES
Print Enter Marks of 3 subjects
Input marks1, marks2, marks3
Avg = (marks1+marks2+marks3)/3
If (Avg >= 50) Then
Enter number of Students 2
Print Passed
Enter Marks of 3 subjects
Else
30 40 50
Print Failed
Failed
End-if
Enter Marks of 3 subjects
End
60 60 70
Passed
USTGlobal
26
Example-test cases
Step
Number
Action /
Description
Input Data
Expected Result
1.001
Enter character
Character : X
Invalid input
1.002
Enter negative
number
Number : X
Negative input
1.003
Enter a special
character
1.004
Enter number
Number : X
Correct Input,
should continue the
next stage
USTGlobal
27
Key Points
is detailed sequence of actions to
perform to accomplish some task
Algorithms facilitates easy development of
programs
Algorithm
Testing
USTGlobal
28
USTGlobal
29
Contents
Programming
Programming
Life Cycle
Types of Programming Design
Top-Down Approach
Bottom-Up Approach
Linear Programming
Structured Programming
USTGlobal
30
Objectives
At the end of this section, you should be able
to:
Understand what is programming
Work with program life cycle
Understand Different Types of Programming
Design
Top-Down Approach
Bottom-Up Approach
Linear Programming
Structured Programming
USTGlobal
31
Programming
A
The
Computer
USTGlobal
32
HOW
Analysis
& Design
DO IT
Build
TEST
Testing
Deploy
&
Maintai
n
USTGlobal
USE
33
Types of Programming
Design Approach are
USTGlobal
34
USTGlobal
35
Bottom Up Design
USTGlobal
36
Linear Programming
USTGlobal
37
Structured Programming
The
It
There
USTGlobal
38
Pseudo code
Source Code +
Test Script
Compilation
Compilation
Object code
Linking
Linking
Libraries
Debugging
Debugging //
Testing
Testing
Executable
File
USTGlobal
39
Gathering
Plan
USTGlobal
40
USTGlobal
41
USTGlobal
42
Key Points
A
USTGlobal
43
Questions and
Comments
?
?
?
USTGlobal
44