Programming Basics and Error Handling
Requirements Phase
Help the customer determine what he/she wants!
- Sometimes have to help the customer!
- Document it, including
- – I/O requirements
- – Hardware requirements
- – Speed (throughput) requirements
- – Software requirements
- – Functionality desired
For our class
- Are directions understood and followed?
- -what the program is supposed to do
- -input/output requirements
- -formatting required
- -correct name for program
- Is it handed in on the due date?
Design Phase
1.High Level Design
- Based on Req/Spec Document!
- Design overall logic
- Break up project into classes (ie,
- subprojects) that can be
- individually coded, tested, and
- integrated. Try to use existing Java classes or make subclasses.
2.Detailed Design
- Design each individual module or class
- Should have correct functionality and interfaces, but implementation is “hidden” (does not affect anything else)
For our class
- Is there overall logic to the program?
- (Work out on paper, flow chart?)
- Are data structures correct?
- Is it partitioned into classes correctly?
- Are global variables used rarely, if at all?
- Is information and functionality “hidden” – not external but rather localized to classes as much as possible with well-defined assess through methods?
- Are constants used so that ranges can
- be easily changed?
- Are loops used in the right places?
- Are system functions used when appropriate?
Implementation (Coding)
Based on Detailed Design Documents!
- Coding…
- Have code reviews
For our class
- Are loops called, terminated correctly?
- Are there any obvious bottlenecks?
Testing Phase
Does it do what the customer wants?
- (Validation)
- Does it do what it is supposed to?
- (Verification)
- “Black Box” Testing –
- just input –> output
- “White Box” Testing – look at internal
- code
- Unit Testing – for module individually
- Integration Testing – do they work
- Together?
- System Testing – Test everything together in real environment
For our class
- Does it work with the sample input that
- was handed out?
- Does it work with additional input?
- Does it work with “border cases?”
- – null input
- – large amounts of data
- – handle errors as specified
- – handle decision points
Maintenance Phase
Is the program maintainable for the purposes of:
- – fixing bugs
- – making future enhancements as
- requirements change
- – optimizing
- – porting to another platform
- – resuming all or part of it in another project
For our class
- Are there adequate comments?
- Are the names (for methods, classes,
- instances, constants, variables,
- types) meaningful?
- Is “hard-coding” minimized
- Is it indented so it is easily understandable?
- Is white space used to break it up into “sections”?
Syntax error
- Statement without a ;
- Spell keyword wrong (main, static,…)
- Use a variable without declaring it
- Get a value without initializing it
- put a double into an int
Logic error
- Use + when you meant –
- Expect decimal places from int/int
- Set wrong variable
- Wrong logic for loops, if-elses
- Many, many possibilities…
Run-time error (“exception”)
- open a file – but file not there this time
- divide – but denom. is 0 this time
- find 6th char in string – but it only has 5 chars this time.
- Change String to int – but can’t because the String is “45yeui” this time.
