0% found this document useful (0 votes)
44 views2 pages

CSSE2002 Cheatsheet

The document discusses software testing principles, specifically focusing on coverage, preconditions, postconditions, and cohesion in programming. It emphasizes the importance of ensuring that all branches of code are tested and that classes maintain high cohesion by being focused on specific functionalities. Additionally, it outlines design principles such as the Open-Closed Principle and Dependency Inversion Principle to promote better software architecture.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views2 pages

CSSE2002 Cheatsheet

The document discusses software testing principles, specifically focusing on coverage, preconditions, postconditions, and cohesion in programming. It emphasizes the importance of ensuring that all branches of code are tested and that classes maintain high cohesion by being focused on specific functionalities. Additionally, it outlines design principles such as the Open-Closed Principle and Dependency Inversion Principle to promote better software architecture.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Sunification coverage

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,

Levels (high to low (


part of
statement
G
making
once

branch
white box

covera

sure

coverage
a
testing

each line of code has been run at least

* [Desc of method behaviour]


.
Content ensures each branch of a conditional is tested
A class
directly manipulates data of
for both the true false case.
one

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' .

using the post condition.


sharing something imposed by an

/** 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

Enumber 2 == = numbers [0 + 12] number #B data structure but each


sharing
=

numbers! numbers [0-103


a

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
==

Enumbers [result + 12]


result = result + 12i
== number 3

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

return result ; ↑ closely related & contribute


3 Step #I starts here , collectively to a specific functionality .
we know post-condition is true
low cohesion = bad
at the .
end
:
Grequire b elements are less focused
unrelated purposes.
&
Enumber 2 = numbers [12] serve multiple
== 0 = numberB may
number % 2 ! 0
numbers [10] number 3
levels (low
high
=
to
= number % 2 == = numbers [12] = numberB
number % 2 ! 0 =) false 3 indexes cannot be
negative coinidental cohesion
number % 2 0 numbers [12] number o wo
=

= elements
grouped arbitrarily
=
are
number 2 == 0 double negation of (number 2 ! 3) clear ,
a
meaningful relationship .
=

=> numbers [12] number B number 2 03 temporal cohesion


= ==

&B numbers ! null pl numbers length L 13


need
elements
grouped because
they
.

are

to be executed at the time


during

Mariantseviants
same or

the same phase .


procedural cohesion
based
must be :
elements are
grouped on their
involvement in a specific sequence of actions

established/true after class constructor . or steps.


assumed as a precondition of each method. communicational cohesion
belements within module work
must be established after each method call . a
together to
Manipulate a shared data structure.
loop invariants must cohesion
assumed to hold
bei
sequential
before the loop . elements
be assumed
are
organised in a linear
may of the start of the where the output of element
loop body sequence one

along
,

with
loop condition.
,

becomes the input of the next .

must be established after the loop


is
body functional cohesion
executed .

elements within a module are


grouped

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

aimals adde Call than one

it should have
reason to
change .

for (Animal animal i one


: animals)E . e .

animal. eat(new Food()) ; responsibility.


3
Open-closedPrinciple
i
wheremus a class should be open for
extension .

↑ 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 .

Dependency Inversion Principle abstractions


entities should depend on

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((.

list . remove (index)


list contains ()
.

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 . get (key


map .
remove
(key)
map replace
(hey value
.

map .
size()
Map clear)
.

Map .
is
Empty()
Map .

keyset()
map-values))

You might also like