01 - EGC3173 - EGC3113 - Programming Principles
01 - EGC3173 - EGC3113 - Programming Principles
1
Chapter Outline
Section 1
1. Unit analysis
2. Classification of Software
Section 2
3. Software Development Procedure
Section 3
4. Algorithms
5. Programming Languages
2
1. Unit Analysis
3
Unit Analysis
4
Unit Analysis
• Converting the length to m, the rectangle’s area is calculated as
1𝑚
𝐴𝑟𝑒𝑎 = 2 𝑐𝑚 × 3 𝑚 = 0.06 𝑚2
100 𝑐𝑚
5
Unit Analysis
• Performing a unit analysis:
– Include only the units and conversion factors in an equation.
– Cancel out corresponding units in the numerator and denominator.
1𝑚
𝐴𝑟𝑒𝑎 = 2 𝑐𝑚 × 3 𝑚 = 0.06 𝑚2
100 𝑐𝑚
Or
100 𝑐𝑚
𝐴𝑟𝑒𝑎 = 2 𝑐𝑚 × 3 𝑚 = 600 𝑐𝑚2
1𝑚
6
Conversion Factor
• Another example of conversion factor: 1 day = 24 hours.
• As a conversion factor, this equality can be written as either of the following
factions:
1 𝑑𝑎𝑦 24 ℎ𝑜𝑢𝑟𝑠
or
24 ℎ𝑜𝑢𝑟𝑠 1 𝑑𝑎𝑦
7
Unit Systems
8
Unit Systems
• Apply one conversion factor at a time and cancel units as you go along
to avoid multiplying or dividing by the wrong conversion factor.
• If the final unit does not yield the correct resulting unit, then the
resulting numerical answer must be incorrect.
10
2. Classification of Software
11
Classification of Software
12
Application Software
13
Operating System
• Operating system: The set of system programs used to operate and
control a computer
– Also called OS
14
3. Software Development Procedure
15
Software Development
16
Software Development
• Software development procedure: Helps developers understand the
problem to be solved and create an effective, appropriate software
solution
• Software engineering:
– Concerned with creating readable, efficient, reliable, and maintainable programs
and systems
– Uses software development procedure to achieve this goal
17
Software Development
18
Phase I: Development and Design
• Program requirement: Request for a program or a statement of a
problem
• After a program requirement is received, Phase I begins:
• Phase I consists of four steps:
– Analysis
– Design
– Coding
– Testing
19
Phase I: Development and Design
20
Phase I: Step 1
22
Phase I: Step 2
23
Phase I: Step 2
24
Phase I: Step 2
• Step 2: Develop a
Solution (Example)
– An inventory tracking
system with further
refinements.
25
Phase I: Step 3
26
Phase I: Step 3
• Step 3: Code the Solution
– Sequence: Defines the order in which instructions are executed
Instruction
Instruction
Instruction
27
Phase I: Step 3
• Step 3: Code the Solution
– Selection: Allows a choice between different operations, based on
some condition
yes condition no
Instructions A Instructions B
28
Phase I: Step 3
• Step 3: Code the Solution
– Iteration: Allows the same operation to yes
be repeated based on some condition condition
no
• Also called looping or repetition
Instructions
Instructions
29
Phase I: Step 3
• Step 3: Code the Solution
– Invocation: Involves invoking a set of statements when needed
Task 1
Instruction
Task 2 Instruction
Instruction
Task 3
30
Phase I: Step 4
31
Phase I: Step 4
• Step 4: Test and Correct the Program
– Table 1.3 lists the comparative amount of effort typically expended on each
development and design step in large commercial programming projects
“It’s impossible to write a successful program for a problem that’s not fully understood.”
32
Phase II: Documentation
33
Phase III: Maintenance
• Maintenance includes:
– Ongoing correction of newly discovered bugs
– Revisions to meet changing user needs
– Addition of new features
• Usually the longest phase
• May be the primary source of revenue
• Good documentation vital for effective maintenance
34
Backup
35
4. Algorithms
36
Algorithms
37
Algorithms: Case Study – Method 1
Case Study: How many ways can you approach the problem of calculating
the sum of all whole numbers from 1 through 100?
38
Algorithms: Case Study – Method 2
Case Study: How many ways can you approach the problem of calculating
the sum of all whole numbers from 1 through 100?
39
Algorithms: Case Study – Method 3
Case Study: How many ways can you approach the problem of calculating
the sum of all whole numbers from 1 through 100?
40
Algorithms: Case Study – Algorithm
Case Study: How many ways can you approach the problem of calculating
the sum of all whole numbers from 1 through 100?
Algorithm:
Set n equal to 100
Set a equal to 1
Set b equal to 100
Calculate n*(a+b)/2 and store the result in sum
Display the sum
41
Algorithms
Pseudocode Flowchart
• English-like phrases used to describe • Diagrams with symbols
steps in an algorithm
42
Flowchart Symbols
43
Example: Flowchart
Example:
Calculating the average of three
numbers. Figure 1.8
1. Input the three numbers into Flowchart for
the computer’s memory calculating the
2. Calculate the average by average of
adding the numbers and three numbers
dividing the sum by three
3. Display the average
44
5. Programing Languages
45
Level of Programming Languages
46
Machine Language
• Machine language programs: only programs that can actually be used
to operate a computer
– Also referred to as executable programs (executables)
– Consists of a sequence of instructions composed of binary numbers
– Contains two parts: an instruction and an address
– Example: R-type MIPS instructions
47
Assembly Language
• Assembly language programs: Substitute word-like symbols, such as
ADD, SUB, and MUL, for binary opcodes
– Use decimal numbers and labels for memory addresses
• Example: ADD 1, 2
48
Low- and High-Level Languages
• Low-level languages: Languages that use instructions tied directly to
one type of computer
– Examples: machine language, assembly language
• High-level languages: Instructions resemble written languages, such as
English
– Can be run on a variety of computer types
– Examples: Visual Basic, C, C++, Java
49
Low- and High-Level Languages
50
Procedural and Object Orientations
51
Summary
52
Common Programming Errors
53
Concerns?
54
012-4579063
55