Show Menu
Cheatography

Java Program design and analysis Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Programmer or engineer

engineer = analytic mindset, oversee the whole software develo­pment cycle
programmer = implement and debug

Water fall model

program specif­ication
project descri­pti­on/­req­uir­ements
program design
plan to solve the problems listed, no code at all, language indepe­ndent
implem­ent­ation
coding in java
testing and debug
testing case(end point, in range, out of range, special value/­inv­alid)
 
compil­er(java checked Except­ion­)/r­unt­ime­(java unchec­ked­,er­ror­)/b­usiness logic errors(in corrected results)
 
robust­nes­s:deal bad input ( input correct ->c­orrect answer, invalid input ->no crash/­err­or/­exc­eption
mainte­nance
upgrade, new featur­es,­doc­ument for new comers
infinite loop is a run time error because it will eventually eat up all memory.
divided by zero for int(ru­ntime exception) and float (infinite, when output is known)
platform dependency and efficiency not belong to robust­ness.

object oriented program design

identify classes -- noun
identify behavior --verb
find relation between classes
write API for each class ( pubic method header)
implement methods

identify classes

lower level component
Connect4 board, game rule
collection of lower level components
players
control class
controller ( setup player and board)
GUI
Display
 

identify behavior

all verbs
match behavior with class carefully and logically
This could be in test
encaps­ula­tion, only expose what necessary
find suitable data structure( fields, proper­ties)

implem­enting methods

procedural abstra­cti­on/­ste­pwise refinment
helper methods (repeated code, smaller method body,easy read)
inform­ation hiding
instance variable and helper method to be private
stub method
for test, input and return correctly
algorithm
step by step procedure to solve problem. understand the algorithm before coding
 
logically correc­tne­ss,CPU time, memory needed­,easier to mainta­in/­und­erstand

determine relati­onships between classes

inheri­tance
is-a
compos­ition
has-a
UML Model
rectan­gular
<<a­bst­rac­t>>­<<i­nte­rfa­ce>>
up arrow
is a
up arrow + dotted line
interface is a
down arrow
has a
use is-a and has-a to test if class design is ok or not.

implem­enting classes

bottom up
indepe­ndent class -->­lower lever first -->­major components
top down
main class ->step wise refinement and add detail classes
design is usually top down, implem­ent­ation usu bottom up is easier.

program analysis

assertion
precon­dition( what's is true before a method­,loop, block run - input), post condition (the status after the run - output)
efficiency
cpu time, memory
best case; worst case;a­verage case

Vocabulary summary

software develo­pment
writing a program
object­-or­iented program
uses intera­cting object
program specif­ication
descri­ption of a task
program implem­ent­ation
the code
test data
input to test a program
program mainte­nance
keep program working and up to date
top down develo­pment
implement main class first, subsidiary classes later
bottom up develo­pment
implement lowest level classes, indepe­ndent class first
driver class
used to test other class, contains main()
inheri­tance relati­onship
is a relati­onship between classes
compos­ition relati­onship
has a relati­onship between classes
inheri­tance hirarchy
inheri­tance relati­onship shown in a tree like structure
UML diagram
tree like repres­ent­ation of relations between classes
data structure
java construt for storing data
encaps­ulation
combining data field and method in a class
inform­ation hiding
use private to restrict access
step wise refinement
breaking methods into smaller methods
procedural abstra­ction
use helper method
algorithm
step by step process to solve a problem
stub method
dummy method called by another method being tested
debugging
fixing errors
robust program
screens out bad input
compile time error
usu a xyntax error; prevent from compiling
syntax error
bad language usage
runtime error
occurs during eecution
exception
run time error thrown by java method
logic error
program runs but does the wrong things
indepe­ndent class
donot use other classes of the program in its code