You are on page 1of 51

Chapter 3:

Planning Your Solution


Week 4 Day 1

Computer Science and IT | College of Computing | Hiba Al Senawi 1


The Week Agenda
Lecture One:
• Communicating with the Computer
• Organizing the Solution

Lecture Two:

• Introduction to UML (Unified Modeling Language)


• Using the Tools
• Testing the Solution & Coding the Solution
• Software Development Cycle

Computer Science and IT | College of Computing | Hiba Al Senawi 2


Objectives
List and describe the eight basic tools used in this book to aid in the development of a solution to a problem.

Use a problem analysis chart to consolidate data for a problem.

Use an interactivity chart to designate the modules to be used in the solution of a problem.

Use an IPO chart to designate the input, processing, module number, and output for a solution of a problem.

Use algorithms, flowcharts, and pseudocode to develop the instructions for each module in the solution of a
problem.

Describe the importance of internal and external documentation.

Describe the five diagrams used in UML.

Computer Science and IT | College of Computing | Hiba Al Senawi 3


Introduction
• Computers are good only as:
1. Good Hardware

2. Good Software

3. Good Users

Computer Science and IT | College of Computing | Hiba Al Senawi 4


Introduction
A set of
The
instruction
solution
s
Process
data in the
correct
sequence

The desired
results
Computer Science and IT | College of Computing | Hiba Al Senawi 5
Introduction
• Programmers have three resources that they need to optimize for
cost effectiveness:
1. computer memory
2. computer time
3. programmer time.

Computer Science and IT | College of Computing | Hiba Al Senawi 6


Communicating with the Computer
• Since the computer does not speak English as you do, you have to
learn its system of communication or language.

• For the computer to “understand’’ a message, its system of


communication requires instructions governed by specific rules.

Computer Science and IT | College of Computing | Hiba Al Senawi 7


Communicating with the Computer

instructions

If the instructions you


write are incorrect, the If the instructions are not
properly sequenced, the
computer will give an computer will, nevertheless,
error message, the wrong execute them in the order given,
answer, or no answer at and the result will be wrong.
all.
Computer Science and IT | College of Computing | Hiba Al Senawi 8
Communicating with the Computer
• The differences between instructions from one language and another
are in how they are set up (Syntax).

• Syntax refers to the rules governing the computer operating system,


the language, and the application.

• An error is called a bug.

• A bug must be found and corrected, a process called debugging.


Computer Science and IT | College of Computing | Hiba Al Senawi 9
Communicating with the Computer
• Many bugs are a result of syntax errors, but some are logic errors.

• You can find and correct most logic errors during the problem-solving
process.

• You will find and correct syntax errors when you enter your program
into the computer.

Computer Science and IT | College of Computing | Hiba Al Senawi 10


Organizing the Solution
1. problem analysis chart : shows a beginning analysis of the problem

2. structure chart or interactivity chart : shows the overall layout or structure of the solution.

3. IPO chart : shows the input, the processing, and the output.

4. Algorithms : show the sequence of instructions comprising the solution.

5. Flowcharts : graphic representations of the algorithms.

6. Pseudocode : represents a language like solution.

7. coupling diagram :shows the relationship between the modules and the data needed for the modules.

8. Data Dictionary : lists all date variable names and their definitions.

9. UML (Unified Modeling Language) : is a basic tool when using Object Oriented Programming structure.

Computer Science and IT | College of Computing | Hiba Al Senawi 11


Analyzing the Problem
• good way to analyze a problem is to separate it into four parts,
1. The given data

2. The required results

3. The processing that is required in the problem

4. A list of solution alternatives

Computer Science and IT | College of Computing | Hiba Al Senawi 12


Problem Analysis Chart

Computer Science and IT | College of Computing | Hiba Al Senawi 13


Example:
• Calculate the gross pay of an employee given the hours worked and the rate of pay. (The gross pay is
calculated by multiplying the hours worked by the rate of pay).

Computer Science and IT | College of Computing | Hiba Al Senawi 14


Developing the Interactivity Chart
• The next step in organizing your solution is to divide the processing
into subtasks called modules.

• and then to connect these modules together to show the interaction


of processing between the modules.

• There will be one module that controls the flow to most of the other
modules. This will be called the Control or Main module.

Computer Science and IT | College of Computing | Hiba Al Senawi 15


Developing the Interactivity Chart Modules in
a loop

modules are
in a decision.

Duplicate
modules

See Page 46 chapter #3

Computer Science and IT | College of Computing | Hiba Al Senawi 16


Example

Computer Science and IT | College of Computing | Hiba Al Senawi 17


Developing the IPO Chart
• The IPO (input-processing-output) chart extends and organizes the
information in the problem analysis chart.
• The IPO chart has four sections: the Input, the Processing, the Module
Reference, and the Output

Computer Science and IT | College of Computing | Hiba Al Senawi 18


Example

Computer Science and IT | College of Computing | Hiba Al Senawi 19


Writing the Algorithms

• After using the structure chart and the IPO chart

• The next step in organizing a solution is for the programmer to


develop sets of instructions for the computer, called algorithms.

Computer Science and IT | College of Computing | Hiba Al Senawi 20


Drawing the Flowcharts
• From the algorithms the programmer develops the flowcharts,
graphic representations of the algorithms.

• The algorithms and the flowcharts are the final steps in organizing a
solution.

Computer Science and IT | College of Computing | Hiba Al Senawi 21


Flowchart Symbol

Flowlines Processing

Terminators Input / output

Process Module
Decision

See page 50, Ch#3


Figure 3.9 Flowchart
Automatic-Counter Symbols
Loop Off-Page Connectors
On-Page Connectors

Computer Science and IT | College of Computing | Hiba Al Senawi 22


Examples of Algorithms and Flowcharts

Computer Science and IT | College of Computing | Hiba Al Senawi 23


Computer Science and IT | College of Computing | Hiba Al Senawi 24
Rules for Drawing Flowcharts
1. You should write the instructions inside the blocks

2. Makes the flowchart an annotated flowchart.

3. A flowchart always starts at the top of the page and flows to the bottom

4. Use a computer program, or a template and a straightedge, to draw the flowchart.

5. Make the blocks big enough to write instructions so they can be easily read

6. Put the module number and name from the interactivity chart

7. Have plenty of paper on hand since the final copy of the flowchart normally will not be the first draft.

8. Use a pencil with a large eraser

Computer Science and IT | College of Computing | Hiba Al Senawi 25


Pseudocode
• Pseudocode is similar to the algorithm without the numbers and
somewhat condensed.

• The pseudocode for the Payroll problem is given on the right hand
side of the flowcharts.

Computer Science and IT | College of Computing | Hiba Al Senawi 26


Pseudocode example

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


Print "passed"

else
Print "failed"

Computer Science and IT | College of Computing | Hiba Al Senawi 27


Internal and External Documentation
• Internal documentation consists of remarks written with the
instructions to explain what is being done in the program.

• External documentation is made up of the manuals or help menus


written about the solution.

Computer Science and IT | College of Computing | Hiba Al Senawi 28


Homework #1

• Solve problem #6, chapter#3 page 64.

• Submit your answers through the Moodle.

• Due date : Wednesday - September 30 , 2021

Draw an algorithm, develop a flowchart and pseudocode for a solution to


find the smallest of two numbers.

Computer Science and IT | College of Computing | Hiba Al Senawi 29


Thank you!
Coming Lecture Introduction to UML (Unified Modeling Language)
Using the Tools
Testing the Solution & Coding the Solution
Chap. 3 Sec. 2 Software Development Cycle

Computer Science and IT | College of Computing | Hiba Al Senawi 30


Chapter 3:
Planning Your Solution
Week 4 Day 2

Computer Science and IT | College of Computing | Hiba Al Senawi 31


Introduction to UML (Unified Modeling
Language)
• Unified Modeling Language (UML) is used to create a logical model of your
solution.

• It uses various diagrams to describe the entire system

• These diagrams help produce a model of the problem and lead to a better
understanding of the requirements of a problem.

• UML is increasingly being used in the programming industry to design and


communicate a solution to a problem.
Computer Science and IT | College of Computing | Hiba Al Senawi 32
Introduction to UML (Unified Modeling
Language)
• The five diagrams defined are :

1. use case diagrams : describe how a system functions from the user’s standpoint
2. class diagrams : describe how a class functions. Basically, they describe the data structure of the solution.

3. sequence diagrams : graphically present the interactivity between objects


4. state chart diagrams : describes what happens to a given value of an object as it proceeds through the
system.
• activity diagrams: describes the flow of activities. This type of diagram is similar to a data flow chart. It
specifies what happens and when.

Computer Science and IT | College of Computing | Hiba Al Senawi 33


UML

Use case diagrams Class Diagrams

Computer Science and IT | College of Computing | Hiba Al Senawi 34


Use case Example

Computer Science and IT | College of Computing | Hiba Al Senawi 35


Example

Computer Science and IT | College of Computing | Hiba Al Senawi 36


UML

sequence diagrams state chart diagrams

Computer Science and IT | College of Computing | Hiba Al Senawi 37


UML
activity diagrams.

Computer Science and IT | College of Computing | Hiba Al Senawi 38


The coupling diagram
The coupling diagram defines the data that gets transferred from one module to another module.
The coupling diagram of the problem above is shown below:

Computer Science and IT | College of Computing | Hiba Al Senawi 39


The data dictionary
• The data dictionary helps to record data on items.
• It discusses which module accesses which all variables and also discusses their scope and lifetime.
• Data dictionary also calculates the data type of each of the variables.
• The data dictionary of the problem is as shown below:

Computer Science and IT | College of Computing | Hiba Al Senawi 40


Using the Tools
• The problem-solving tools used in this book are the problem analysis
chart, the structure chart or interactivity chart, the IPO chart, the
algorithm, and the flowchart.

• There is much duplication in these tools.

• Because of this duplication, you will find that after the first few weeks
you will drop the use of some of these tools.

Computer Science and IT | College of Computing | Hiba Al Senawi 41


Using the Tools
• for the first few problems, you should use all of the tools. In this way you will know which
ones help you the most. You should end up using at least four of the eight tools:
• The PAC
• The IPO Chart
• The Coupling Diagram
• The Data Dictionary
• The Algorithm
• The Flowchart
• The Pseudocode
• UML

Computer Science and IT | College of Computing | Hiba Al Senawi 42


Testing the Solution
• When a solution is complete, it is important to test it to make sure it
meets the requirements of the user, and to check for errors in logic or
in the setup of the expressions and equations.

• To test a solution, the programmer selects test data, a set of values


for the input data, and works them through every step in the solution.

• It is important to select test data carefully, so the correctness of the


results can be checked with as much accuracy as possible.

Computer Science and IT | College of Computing | Hiba Al Senawi 43


Coding the Solution
• Once you have completed the steps described so far, you have
finished analyzing the problem and organizing the solution. This book
stops with testing the solution.

• The next step is writing the solution of the problem into a computer
language—that is, coding the solution.

• You will learn to code solutions when you take language courses.

Computer Science and IT | College of Computing | Hiba Al Senawi 44


Coding the Solution
• If the programmer follows the proper steps in developing the
solution, there should be few logic errors in the program, and the
testing and coding should go quickly.

• Most bugs will be syntax errors or will stem from a misunderstanding


of the original problem.

Computer Science and IT | College of Computing | Hiba Al Senawi 45


Software Development Cycle

1. The analysis of the problem , the PAC is used in this step.

2. The design of the solution, The IPO chart, the interactivity chart, the coupling
diagram, and the data dictionary are used in this step.

3. The development of the solution., the development of the code includes the use
of algorithms, flowcharts, pseudocode, UML and the code in the desired
computer language.
Computer Science and IT | College of Computing | Hiba Al Senawi 46
Software Development Cycle
4. The implementation of the solution. At this point the program is
ready for use. This includes marketing, training, and final testing.

5. Maintenance and review of the solution. After the program is in general use, it
must be maintained and reviewed often.

Computer Science and IT | College of Computing | Hiba Al Senawi 47


Summary
• The efficiency of the computer relies on the effectiveness of the programmer or the user.
• The programmer must write solutions that are clear, organized, and correct.
• A solution is a sequence of instructions for solving a problem.
• A program is a solution after it has been coded into a computer language.
• Data are stored internally in memory locations according to variable names and externally on a magnetic disk.
• External data are stored in sections called files, which are divided into records, which are further divided into fields.
• The file must be opened before accessing the data and closed when the user has finished with it.
• The steps in organizing the solution to a problem start with problem analysis, a process whereby you separate a problem
into four parts, including given data, required results, processing needs of the problem, and solution alternatives.
• The problem analysis chart is an aid to completing this first step.
• Second, the interactivity chart is developed showing the breakdown of the whole problem into subtasks called modules.
• The coupling diagram indicates how the data flows from one module to another.

Computer Science and IT | College of Computing | Hiba Al Senawi 48


Summary
• Second, the interactivity chart is developed showing the breakdown of the whole problem into subtasks called
modules.
• The coupling diagram indicates how the data flows from one module to another.
• The IPO chart is the third step; it shows the input, the processing, and the output.
• The algorithms are developed fourth, showing in detail the sequence of instructions in the solution.
• from the algorithms the programmer draws the flowcharts, showing graphic representations of the algorithms.
• Last is the development of the pseudocode.
• After completing these steps, the programmer can test, code, and implement the solution.
• UML is also a problem-solving tool mainly used in object oriented programming.
• UML will be revisited in the chapters on Object Oriented Programming.

Computer Science and IT | College of Computing | Hiba Al Senawi 49


Homework #2

• Solve problem #1 and problem #2, chapter#3 page 63

• Submit your answers through the Moodle.

• Due date : Monday - September 30 , 2021

Computer Science and IT | College of Computing | Hiba Al Senawi 50


Thank you!
Coming Lecture
Chapter #4: An Introduction
Chap. 4 Sec. 1 to Programming Structure

Computer Science and IT | College of Computing | Hiba Al Senawi 51

You might also like