Content Analysis
Object Oriented Design and Programming
Week 1
A B Emran Salahuddin (Sydney)
Manzur Ashraf (Melbourne)
Kent Institute Australia Pty. Ltd.
ABN 49 003 577 302 CRICOS Code: 00161E RTO Code: 90458 TEQSA Provider Number: PRV12051
Version 2 – 18th December 2015
1
SLIDE TITLE
Farrell, J. (2017) Programming Logic and Design, Comprehensive (9th ed.) Cengage Learning
2
2
Chapter 1
An Overview of Computers and
Programming
3
Programming Logic and Design, Ninth Edition
Objectives
In this chapter, you will learn about:
Computer systems
Simple program logic
The steps involved in the program development cycle
Pseudocode statements and flowchart symbols
Using a Sentinel Value to End a Program
Programming and user environments
The evolution of programming models
4
Programming Logic and Design, Ninth Edition
4
Understanding Computer Systems
Computer system
Combination of all the components required to process and store data using a computer
Hardware
Equipment associated with a computer
Software
Computer instructions that tells the hardware what to do
Programs
Instructions written by programmers
Programming
Writing software instructions
5
Programming Logic and Design Ninth Edition
5
Understanding Computer Systems (continued -1)
Application software such as word processing, spreadsheets, payroll and inventory, even games, app
System software such as operating systems like Windows, Linux, or UNIX, Google Android and Apple IOS
Computer hardware and software accomplish three major operations
Input
Data items such as text, numbers, images, and sound
Processing
Calculations and comparisons performed by the central processing unit (CPU)
6
Programming Logic and Design, Ninth Edition
6
Understanding Computer Systems (continued -2)
Output
Resulting information that is sent to a printer, a monitor, or storage devices after processing
A cloud based device is accessed through the Internet
Programming language
Used to write computer instructions called program code
Writing instructions is called coding the program
Examples
Visual Basic, C#, C++, or Java
Syntax
Rules governing word usage and punctuation
Mistakes in a language’s usage are syntax errors
7
Programming Logic and Design, Ninth Edition
7
Understanding Computer Systems (continued -3)
Computer memory
Computer’s temporary, internal storage – random access memory (RAM)
Volatile memory – lost when the power is off
Permanent storage devices
Nonvolatile memory
Compiler or interpreter
Translates source code into machine language (binary language) statements called object code
Checks for syntax errors
Program executes or runs
Input will be accepted, some processing will occur, and results will be output
8
Programming Logic and Design, Ninth Edition
8
Understanding Simple Program Logic
Programs with syntax errors cannot execute
Logical errors
Errors in program logic produce incorrect output
Logic of the computer program
Sequence of specific instructions in specific order
9
Programming Logic and Design, Ninth Edition
9
Understanding the Program Development Cycle
Program development cycle
Understand the problem
Plan the logic
Code the program
Use software (a compiler or interpreter) to translate the program into machine language
Test the program
Put the program into production
Maintain the program
10
Programming Logic and Design, Ninth Edition
10
Understanding the Program Development Cycle (continued -1)
11
Programming Logic and Design, Ninth Edition
11
Understanding the Problem
One of the most difficult aspects of programming
Users or end users
People for whom a program is written
Documentation
All supporting paperwork for a program
12
Programming Logic and Design, Ninth Edition
12
Planning the Logic
Plan the steps of the program and what they include
An algorithm is the sequence of steps or rules you follow to solve a problem
Most common planning tools
Flowcharts
Pseudocode
Desk-checking
Walking through a program’s logic on paper before you actually write the program
13
Programming Logic and Design, Ninth Edition
13
Coding the Program
Hundreds of programming languages available
Choose based on features
Similar in their basic capabilities
Coding is easier than the planning step
Experienced programmers can successfully combine logic planning and program coding in one step
14
Programming Logic and Design, Ninth Edition
14
Using Software to Translate the Program into Machine Language
Translator program
Compiler or interpreter
Changes the programmer’s English-like high-level programming language into the low-level machine language
Syntax error
Misuse of a language’s grammar rules
Programmer corrects listed syntax errors
Might need to recompile the code several times
15
Programming Logic and Design, Ninth Edition
15
Using Software to Translate the Program into Machine Language (continued -1)
16
Programming Logic and Design, Ninth Edition
16
Testing the Program
Logical error
Results when a syntactically correct statement, but the wrong one for the current context, is used
Test
Execute the program with some sample data to see whether the results are logically correct
Debugging is the process of finding and correcting program errors
Programs should be tested with many sets of data
17
Programming Logic and Design, Ninth Edition
17
Putting the Program into Production
Process depends on program’s purpose
May take several months
Conversion
The entire set of actions an organization must take to switch over to using a new program or set of programs
18
Programming Logic and Design, Ninth Edition
18
Maintaining the Program
Maintenance
Making changes after the program is put into production
Common first programming job
Maintaining previously written programs
Make changes to existing programs
Repeat the development cycle
19
Programming Logic and Design, Ninth Edition
19
Using Pseudocode Statements and Flowchart Symbols
Pseudocode
English-like representation of the logical steps it takes to solve a problem
Flowchart
Pictorial representation of the logical steps it takes to solve a problem
20
Programming Logic and Design, Ninth Edition
20
Writing Pseudocode
Pseudocode representation of a number-doubling problem
start
input myNumber
set myAnswer = myNumber * 2
output myAnswer
stop
21
Programming Logic and Design, Ninth Edition
21
Pseudocode Standards
Programs begin with the word start and end with the word stop; these two words are always aligned
Whenever a module name is used, it is followed by a set of parentheses
Modules begin with the module name and end with return. The module name and return are always aligned
Each program statement performs one action—for example, input, processing, or output
22
Programming Logic and Design, Ninth Edition
22
Pseudocode Standards (continued -1)
Program statements are indented a few spaces more than the word start or the module name
Each program statement appears on a single line if possible. When this is not possible, continuation lines are indented
Program statements begin with lowercase letters
No punctuation is used to end statements
23
Programming Logic and Design, Ninth Edition
23
Drawing Flowcharts
Create a flowchart
Draw geometric shapes that contain the individual statements
Connect shapes with arrows
Input symbol
Indicates input operation
Parallelogram
Processing symbol
Contains processing statements such as arithmetic
Rectangle
24
Programming Logic and Design, Ninth Edition
24
Drawing Flowcharts (continued -1)
Output symbol
Represents output statements
Parallelogram
Flowlines
Arrows that connect steps
Terminal symbols
Start/stop symbols
Shaped like a racetrack
Also called lozenges
25
Programming Logic and Design, Ninth Edition
25
Drawing Flowcharts (continued -2)
26
Programming Logic and Design, Ninth Edition
26
Repeating Instructions
Program in Figure 1-7 only works for one number
Not feasible to run the program over and over 10,000 times
Not feasible to add 10,000 lines of code to a program
Create a loop (repetition of a series of steps) instead
Avoid an infinite loop (repeating flow of logic that never ends)
27
Programming Logic and Design, Ninth Edition
27
Repeating Instructions (continued -1)
28
Programming Logic and Design, Ninth Edition
28
Repeating Instructions (continued -2)
29
Programming Logic and Design, Ninth Edition
29
Using a Sentinel Value to End a Program
Making a decision
Testing a value
Decision symbol
Diamond shape
Dummy value
Data-entry value that the user will never need
Sentinel value
eof (“end of file”)
Marker at the end of a file that automatically acts as a sentinel
30
Programming Logic and Design, Ninth Edition
30
Using a Sentinel Value to End a Program (continued -1)
31
Programming Logic and Design, Ninth Edition
31
Understanding Programming and User Environments
Understanding Programming Environments
Text Editor is used to create simple text files
Integrated development environment (IDE) provides an editor, compiler, and other programming tools
Microsoft Visual Studio IDE
Understanding User Environments
Command line is a location on your computer screen at which you type text entries to communicate with the computer’s operating system
A graphical user interface, or GUI (pronounced gooey), allows users to interact with a program in a graphical environment
32
Programming Logic and Design, Ninth Edition
32
Understanding Programming Environments
33
Programming Logic and Design, Ninth Edition
Java program in notepad
33
Understanding Programming Environments (continued -1)
34
Programming Logic and Design, Ninth Edition
Java program in IDE
34
Understanding User Environments
35
Programming Logic and Design, Ninth Edition
35
Understanding User Environments (continued -1)
36
Programming Logic and Design, Ninth Edition
36
Our Focus:
37
Programming Logic and Design, Ninth Edition
For a programming problem:
Design flowchart
Write pseudocode
Write programs using Java programming language in Eclipse IDE
37
Understanding the Evolution of Programming Models
People have been writing modern computer programs since the 1940s
Newer programming languages
Look much more like natural language
Are easier to use
Create self-contained modules or program segments that can be pieced together in a variety of ways
38
Programming Logic and Design, Ninth Edition
38
Understanding the Evolution of Programming Models (continued -1)
Major models or paradigms used by programmers
Procedural programming
Focuses on the procedures that programmers create
Object-oriented programming
Focuses on objects, or “things,” and describes their features (or attributes) and their behaviors
More details in later weeks
39
Programming Logic and Design, Ninth Edition
39
Summary
Hardware and software accomplish input, processing, and output
Logic must be developed correctly
Logical errors are much more difficult to locate than syntax errors
Use flowcharts and pseudocode to plan the logic
Avoid infinite loops by testing for a sentinel value
Use a text editor or an IDE to enter your program statements
40
Programming Logic and Design, Ninth Edition
40
What to do next:
Quickly revise whatever was discussed in today’s class.
Clear your doubts if any.
Finish tutorial workshops in tutorial timing.
Install java runtime environment and eclipse for java developers on your laptops. (We will use this next week)
41
Programming Logic and Design, Ninth Edition
kent.edu.au Kent Institute Australia Pty. Ltd. ABN 49 003 577 302 ● CRICOS Code: 00161E ● RTO Code: 90458 ● TEQSA Provider Number: PRV12051
42
42