Lecture 25 - Revision
Home >
Lectures
> Lecture25
Objectives
- To give an overview of the work covered in this subject
1. Overview
This is a good time to review the aims and objectives of the subject:
Aims
- To introduce students to analysing,
designing, constructing and documenting solutions to programming problems
- To familiarize students with commonly
used operating systems and tools used in program development
Objectives
Students should be able to:
- Analyse a problem and construct a
logical solution suitable for implementation as a computer program
- Represent a solution to a problem in
pseudo code
- Use appropriate programming tools to
develop solutions to programming problems
- Produce a correctly coded solution to
a problem specification
- Apply the 3 basic programming
constructs of sequence, selection and iteration
- Internally document a program with
appropriate comments
- Develop external documentation for a
programming problem
- Specify and execute test plans for
programming problems
- Use standard Unix commands for: file
management; printing, account management; compilation, …
- Be aware of the nature and usage of
Unix from a programmer's viewpoint
Topics
The main topics covered in this subject were:
- Introduction to Programming Environment
- Introduction to the Computer Networks at La Trobe Bendigo
- Problem solving and algorithm design
- Programming and design documentation
- Programming in Visual Basic
- The UNIX Operating System
- Programming in Java
- Programming Tools: ftp, winzip
2. Introduction to Programming Environment (lecture 1)
3. Networks at La Trobe Bendigo & Operating Systems (lectures 1 & 2)
Networks
- Computer networks allow resources to be shared.
- Networks have two types of computers: Servers and Workstations
- Servers are fast and store data centrally
- Workstations are PCs or UNIX workstations (or Macs...) that can do
processing locally, but usually store data on the server
- The PC Network is a IBM compatible PC network. Servers on the network
use Windows Sever 2003 as the Network Operating System. Workstations (PCs) use MS
Windows XP Pro.
Operating Systems
- The two main categories of software are Application Software and System
Software
- System Software includes BIOS and Operating Systems
- Operating Systems provide the basic functionality of a system
- The two main types of Operating Systems (OS) are command and
graphical based
- UNIX is an example of a command based OS and Windows XP is an example of
a graphically based OS
- Windows has three types of file systems: FAT, FAT32 and NTFS. NTFS is the
most sophisticated
- Windows XP is a single user OS that is considerably more
sophisticated than its predecessors
- Windows Server and Windows XP provide security for your account
4. Steps in Program Development (lecture 3)
- Programs are need for problems that are: complex; repetitive; store data;
involve communications etc
- Writing a program is not always the best solution to a problem. There are
a number of alternatives, including: manual systems and using existing
packages
- Building construction and software construction are similar.
- Planning is essential.
- Specifications are vital
- A disciplined approach pays off
- Finding problems early saves $$$
- The basic operations of a computer are: get data; output data;
calculations; store data; retrieve data; decide between alternative
instructions; and repeat instructions
- Steps in program development are: Understand the Problem; Specify a High
Level Solution; Outline the Solution; Develop the Algorithm; Test the
Algorithm; Write the Program; Test the Program; Debug the Program; and
Maintain the Program
- It is essential that a problem is understood before attempting a solution
- Defining Diagrams give an overview of the problem, they broadly
state what is to be used (inputs) and what is to be done (processing) to solve
the problem and the results (outputs).
5. Pseudo Code (lectures 4 & 5)
- An algorithm is a series of steps to accomplish a task
- Pseudo Code is a commonly used method to express an algorithm
- Advantages of pseudo code:
- Reduced complexity
- Increased flexibility (language independent)
- Ease of understanding
- A Data Dictionary is used to clarify the use of data in an algorithm
- A Desk Check is a manual check of an algorithm
- Some important statements used in pseudo code are: Assignment (=), Input
and Display
- The arithmetic operators are: (), *, /, +, -
- Operator precedence refers to the order that operators are evaluated
in an expression
6. An Introduction to Visual Basic (lecture 6)
- Visual Basic in Access XP (2002) was used in this subject
- Visual Basic is often referred to as VB
- Comments help the reader understand the program
- Variables have a name and a value. Referring to the name allows the value
to be obtained. Values can be stored in variables using = or InputBox. The
value held in a variable can be changed while the program is running
- The main data types we will be using in VB are Long (for integers), Double
(for floating point numbers) and String
- The operators used in calculations are: (), *, /, +, -
- = is used to store a value in the variable on the left of the ='s
- InputBox is used to input a value
- Debug.Print is used to display value(s)
- We will be treating a module in Access/VB as a program
- Access/VB has an Integrated Development Environment (IDE) which includes
an editor for writing programs and a compiler
- Syntax Errors are errors due to the incorrect use of a language
7. Selection (lectures 7 - 10)
- Only using sequence - performing instructions from top to bottom
one after the other does not allow us to tackle real world problems
- Selection - conditionally executing instructions based on some conditions
- Problems that have alternatives actions or optional actions suggest the
presence of Selection.
- IF ... ELSE ... ENDIF is used in Pseudo Code to model selection
- If ... Else ... End If are used in Basic for selection
- Comparison operators are used in conditions to compare things. The
operators are: =, <>, <, <=, >, >=
- Some problems require multi-way selection
- Nested-IFs are IF statements inside IF statements
- Nested IFs can be used for multi-way selection
- Compound conditions consist of simple conditions combined with NOT, AND,
OR
- NOT negates a condition
- AND is True if both operands are True otherwise it is False
- OR is True if both or either operands are True, otherwise it is False
- Compound conditions may involve multiple variables
- Care needs to be taken to ensure that there aren't gaps in the
logic. All possible cases in the problem and paths through the logic
need to be examined
- In some cases it is not appropriate to use nested IFs
- Boolean variables hold one of the values: True or False
8. Miscellaneous (lecture 10)
- Debug.Print can print multiple literal values and/or variables.
- Semicolons and commas are used in Debug.Print to control where the values
are printed
- Indentation and Whitespace are blanks (spaces and/or blank lines) that are
used to make code easier to read
- The value of good variable names cannot be underestimated
- A Syntax error results from the incorrect use of the language - the code
does not follow the rules of the language. Syntax errors are detected by the
Complier.
- Logic errors occur when the program is running and are caused by mistakes
in the logic - the code does not do what was intended and/or required
- Run-time errors occur when a statement attempts an illegal operation.
These can can be difficult to detect. Sometimes run-time errors can be
avoided.
9. Repetition (lectures 11 - 14)
- Repetition is also known as looping or iteration
- Repetition involves repeating instructions (statements) zero or more times
- There are 3 main types of loops:
- fixed number of repetitions
- variable number of repetitions, but known before entering the loop at
run-time
- unknown number of repetitions when entering the loop at run-time
- A FOR loop is a simple type of counting loop
- Signs of repetition in a problem are terms such as repeat, for, while
or the use of plurals such as students or customers or
repeated patterns in data
- While loops are more flexible than FOR loops, allowing the loop to be
exited when the condition becomes false, rather than after a predefined number
or repetitions.
- While loops are repeated while the condition is True
- Sentinel values are special input values that are used to indicate the end
of input in a loop
- Infinite loops are loops that once entered, continue for ever
- Loops are often used for totalling, counting and averaging of numbers
- Validation is used to ensure that a value is correct
- Validation simplifies processing by (a) centralising the code to check a
value and (b) allowing the programmer ton assume that the value is correct
elsewhere in the program
- IF, FOR and WHILE are control structures. They may be nested (place inside
one another).
- Displaying tables of values often involves incrementing one value in a
loop, from which the rest of the values on the same line in the table can be calculated
10. Subroutines (lecture 16)
- Sub-dividing a program into sub-programs allows for
- Reduced complexity,
- Permits work to be shared amongst developers
- Allows for re-use of code.
- In Basic sub-programs are known as Subroutines or Functions
- When a subroutine is called the code specified for the subroutine
is executed, then when the subroutine exits (finishes), control returns
to the line after where it was called
- Subroutines may be called as many times as necessary
- In Pseudo code subroutine declarations begin with the subroutine name,
followed by the subroutine code, and end with EXIT. To call (execute) a
subroutine the name of the subroutine followed by brackets is used.
- In Basic subroutines begin with Sub, followed by the subroutine
code, and end with End Sub. To call (execute) a subroutine the name of
the subroutine is used.
- Local variables are only known in the subroutine they are declared in.
Their value is lost when the subroutine exits
- Global variables can be used throughout a program. Their value is lost
when the program ends
- Functions are a special type of subroutine that return a single value
- Basic has many built-in functions e.g. Sqr, Round, Len
11. Programming Revision
- Programmers build up a mental toolkit of problem types and solutions.
This toolkit is gained through experience and study, and continues to grow
throughout a programmers career.
- When solving new problems programmers draw on this toolkit to recognise
problem types that they have encountered before and modify previous solutions
to solve the problem at hand.
- The problem types studied in this subject are applicable to many
programming problems.
- Programming Constructs
- Sequence
- Sequence involves executing a number of instructions one after the other in
order from
top to bottom.
- Selection
- Selection is used when different instructions are to be executed depending on the result
of a condition. In this subject we have used the IF statement to implement
selection.
- Repetition
- Repeating something zero or more times
Typical Uses
Sequence
Typical uses:
- User input of values
- Displaying literal values (e.g. 23 or "Hello World") or variables (e.g.
the values stored in custName or custNumber)
- Initializing values (e.g. count = 0)
- Calculating, incrementing (adding 1), decrementing (subtracting one),
totalling
- Calling a subroutine
Selection
Typical uses:
- Under a certain circumstance instructions are to be performed, otherwise
nothing special is to be done (An IF, without an ELSE) e.g.
- Calculate the average value if values have been input (count > 0)
- Keep the smallest number input so far
- Determine if a number is negative
- A set of instructions are to be performed if a condition is true,
otherwise (the condition is false) another set of instructions are to be
performed.
- Characteristics: One of two different sets of instructions is to be performed
depending on the result of a single condition.
- Example: Display whether there is space left on a disk, if there isn't any
space, display that, otherwise display how much space is left.
- A nested IF structure.
- Characteristics: A dependency between two variables. The value of an unknown
variable (dependent variable) can be determined solely based on the value of
another variable of known value (independent variable)
- Examples:
- Range of values. e.g. Determine the cost per megajoule of gas
(rate) for a customer.
- Discrete values. e.g. Calculate the penalty applicable on car
insurance depending on the risk associated with the insurance
- Compound condition.
Repetition
Typical uses:
- The loop is always executed the same number of times e.g.
- Displaying a table of values
- The loop is executed a variable number of times depending on a variable value
that is known before the loop is executed e.g.
- Displaying a repeated series of characters
- Displaying a table of values
- Inputting a series of numbers (and doing something with them)
- The loop is executed a variable number of times that is only known when
the user indicates they have finished. e.g. looping until a sentinel value is
input by the user e.g.
- Inputting a series of numbers until a user types a sentinel value
- Inputting numbers and performing some calculations on them
- Totalling, counting and averaging e.g.
- Totaling sales
- Calculating average rainfall
- Counting words in a document
- Validation e.g.
- Validating Yes/No response by a user
- Validating the school year 0 (prep) through to year 12
- Validating a month number
- Validating a menu item
12. Unix (lectures 17 - 23)
Introduction
- redgum: a Server is mainly for student use
- ironbark: Server used for staff accounts and IT Department web pages
- workstations: IBM Compatibles running Linux in the UNIX lab
- hopper: A PC running UNIX that is used to store students files
- Unix
- is Multi-User
- has individual user accounts:
- is command driven
- has a Hierarchical File System
Unix File System
- Unix uses a Hierarchical File System
- There is a special root directory where it all starts (/)
- Files are referred to by their pathnames
-
A file can be referred to by its full or absolute pathname.
Absolute files names start with a /
- Files can be referred to by relative pathnames. Relative file names
must NOT start with a /
- Unix supports only one directory tree
- Files from one computer are mounted (by the system administrator)
onto the file system of another computer using NFS (the Network File System)
Unix Commands
Working with Files
- ls
- cat, less, more
- cp
- mv
- rm
- lpr
- chmod
Working with Directories
Editors
Special Directories
Wildcards
Redirection of Input/Output
Java Programming
Users and Processes
Miscellaneous
Other Topics
- Using nedit
- Aliases
- .login, .cshrc
13. Java (lectures 21 & 22)
General
- Java is an object oriented language
- Java source code file are text files
- Compilation produces a java byte code file which can be executed using the
Java Virtual Machine
- Java may be run on different types of computers using the Java Virtual
Machine (JVM)
- Java programs are compiled using the javac command and executed
using the java command
The Language
- Java is case sensitive
- {} are used to group statements
- // are used for comments to end of line
- Simple statements are terminated with a ;
- Data types are: int, double and String
- User input is done using JOptionPane.showInputDialog. This inputs a
string. If the values input represent numbers they must be converted to
numbers using Integer.parseInt or Double.parseDouble as
appropriate
- Display is done using System.out.println
- Arithmetic operators: (), *, /, %, +, -
- / results in integer division if the values on both sides of the operator
are integers, otherwise floating point division is performed
- & is used for concatenating strings
14. Tools (lecture 24)
File Transfer
- Used to transfer files between different computers
- ftp - stands for File Transfer Protocol
- Requires a host computer running special software to act as a ftp
server
- Users on a computer running client ftp software can connect to the host
computer if they have an account or by anonymous ftp (if available)
- Files are transferred as ASCII or binary. Text file are normally
transferred as ASCII, others as binary
- PCs, Unix and Macs have different end of line characters in text files
requiring conversion when transferring between these different types of
computers
Software
- ftp
- A command line program for transferring files
- Available on a variety of computers
- ws_ftp
- Uses a Graphical User Interface
- Available on PCs
- Easier to use than command line ftp programs
File Compression
- Compression programs are used to reduce the space taken up by files
Software
- winzip
- Graphical user interface. Available on PCs
- zip/unzip
- Command line programs on Unix
Further Reading
- Lectures and Tutorials 1 to 24
- Guides: Basic, Data Dictionary, Defining Diagram, Desk Check, Java, Pseudo Code, Unix
- Robertson, L. A. (2003) Simple Program Design: A Step-by-Step Approach.
4th ed. Melbourne: Thomson.
- Taylor, D. (2001) Sams Teach Yourself UNIX in 24 Hours. 3rd ed.
Indianapolis, Indiana: Sams
Previous Lecture | Lecture Index |
Next Lecture |
Tutorial
Last modified
09-May-2005 by Tim Whitfort.
Copyright © 2003-2005
Tim Whitfort