



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The importance of software specifications in programming language technologies and paradigms. It explains how specifications act as a contract between users and providers, helping to write and maintain code. The document also covers the differences between formal and informal specifications and their advantages and disadvantages.
Typology: Study notes
1 / 6
This page cannot be seen from the preview
Don't miss anything!




3
(^) Javadoc
: extract a standalone
specification from the code and embedded comments
than current node
5
static
(^) int (^) find(int[]
(^) d,int
(^) x)
(^) d is sorted, and some element of the array
(^) d is equal to
x, then find() returns the index of
(^) x ……
(^) d .length,
(^) d [i-1] < (^) d [i]
and there exists j, 0 <= j <
(^) d .length, such that
(^) d [j] == (^) x )
implies find(d,x) = j ……
Note: These specs assume array has no duplicates
7
// // postcondition:// precondition: the array d is sorted returnValue >= 0 && d[returnValue] == x
or (returnValue == -1 && x does not occur in d)
static int find(int d[], int x);
13
Integrates documentation into source code as comments
Will generate an external specification
public class MyClass { / Javadoc Comment for this class / /* Javadoc Comment for field**
(^) text
(^) */
/ Javadoc Comment for methodString text;**
(^) setText
@param t Javadoc comment for parameter
(^) t
public void setText(String t) {...}/*
}
**/**** (^) Given
(^) a (^) sorted
(^) array, returns the
(^) index
into (^) the array of
(^) the (^) given
(^) element,
otherwise
(^) returning -1.
@param d
(^) array
(^) to search in,
(^) assumed
(^) sorted
@param x
(^) the element
(^) to search
(^) for
@returns
(^) i (^) >= (^0) (^) when
(^) d[i]
(^) == (^) x, and
(^) -1 when
x does (^) not occur in
(^) d
public/*
(^) static int
(^) find(int d[],
(^) int (^) x) (^) {
…
}
15
17
(^) Class diagrams
(^) show the static relationship between
classes
Object diagrams
(^) represent the state of a program as
series of related objects
Interaction diagrams
(^) illustrate execution of the
program as an interaction among related objects
19