CSSE2002 Cheatsheet
CSSE2002 Cheatsheet
bideal specifications
that are unacceptable
are
need to
athrowsnication's
/
explain params
car
,
should rule out all
but not
be written
,
(remember
preclude
using contracts
implementationsmod
those that
Aparam , return,
branch
white box
covera
sure
coverage
a
testing
Arequire [Precondition]
* another class .
* Densure [postcondition] Common
*/
path coverage
sharing access to the same
global data/
is traversed
We can find the precondition of a method
variables .
External
every possibility ,
'path' .
/** external
g
e .
. source
*
require ? Control
*
*/
fensure numbers [Iresult] ==
number one class is controlling what happens
public int index of (int[] numbers int number) E , sinanother ,
passing it info, e e
number 3
class only parts of
==
needs select ie
int result = 0:
Enumber 2
sharingofdatathroughmeanscases
== = numbers Cresult + 12] = number BB
numbers !== numbers [result-103 == number 3
if (number 2 0) E
5
==
both
Cohesion
Enumbers [result] == number 3
cases
post-condition .
to
satisfy ~
Selsed of inter-relatednessof focus
Enumbers [result-10] == number 3 degree
elements within module.
result =
result-10 : among
a
Enumbers [result] 3
good
== number
3 high cohesion
within
=
module
Enumbers [result] == number 3 elements a are
= elements
grouped arbitrarily
=
are
number 2 == 0 double negation of (number 2 ! 3) clear ,
a
meaningful relationship .
=
are
Mariantseviants
same or
along
,
with
loop condition.
,
mov
Principle
single specific functionality
based on a ,
or
task .
reader readline()
.
responsibility
be used
wherever instance of
a ss
type can
an a
superclass type is
expected.
e List Animal animals
.
.
g
= new
Arraylist() ; a class should never have more
it should have
reason to
change .
↑ i .
e .
it's behaviour can be extended
n
to support changing requirements
however it needs to be closed
, for
mus modification .
to the
preconditions of a child class must be i .
e .
no one can make
changes
weaker' the the parent class behaviour of class.
as it must not
or same as
, an
existing
reject any states the parent would Interface
allow Segregation Principle
interfaces should split
post conditions on the other hand must be larger be into
smaller
,
to classes
only
,
ones ensure
the same or
'stronger' they , can't allow
more
things to pass have methods of which are use to
only less.
them .
not concretions.
implements interface Espec ,
. if
class & an
e .
g
class A shouldis
Fatherthcusing
class ,
Na
boolean is
String Empty) Math
sqrt
.
strigstigowerClean
.
Math. pow
Stack
String. format ("blah ,
blah ,
%s" , "bah") ;
%
=string
%. 27 = float w/two d p. .
%= boolean
Stack
<Integer stacks = new Stack() :
ArrayLists
list
List
Integer = new
ArrayList() ;
list size()
.
list .
get()
list Set () .
list add () .
list Clear() .
list indexof((.
Set
new Hashset() ;
Set
<Integer) set =
set . add()
set remove() ,
set clear ()
set .
size()
set .
isEmpty()
set contains ()
.
Maps
Map(K V Map ,
= new HashMap() ;
Map put (k v .
,
map .
size()
Map clear)
.
Map .
is
Empty()
Map .
keyset()
map-values))