Java Reference
In-Depth Information
Table 5.9 Test program file
Line
Content
Destination location
1
None: is the number of instructions to read
17
2
100
OUTPUT 114
3
101
INPUT 111
4
102
LOADA 111
5
103
OUTPUT 115
6
104
INPUT 112
7
105
LOADB 112
8
106
ADD
9
107
STOREA 113
10
108
OUTPUT 116
11
109
OUTPUT 113
12
110
HALT
13
111
0
14
112
0
15
113
0
16
114
Insert first number:
17
115
Insert second number:
18
116
Result:
Modelling techniques . In this case study we introduced the notation of
state charts, that are used to describe finite state automata.
Development approach . During development we faced two features of the
system separately: first, the structural representation of computer archi-
tectures; second, the behaviour of the components and in particular of the CPU.
The finite state automata are a well-defined formalism that describe a
state-based behaviour. FSA can be translated into Java code that imple-
ments the required behaviour (see Sidebar 5.2).
Aggregation associations can be used to express a strong part
whole rela-
tionship between classes. Transferring most of the aggregation semantics
into the code results in better traceability and improved readability of the
code. The aggregate association idiom can be used to implement aggregation
associations in the most expressive way.
When a constant value is used in several places, either in a single class or
in multiple classes, there are problems of consistency and ease of update.
These issues, among others, are addressed by the constant member idiom.
-
Idiom
Aggregate association
Context
An aggregation association between two classes.
Problem
How to implement the association preserving the semantics of aggregation
and maximizing readability and ease of use.
Forces or tradeoffs
It must be navigable. The aggregation link remains unchanged for the
entire lifetime of the container. The syntax must be readable. It is easy to
forget to instantiate the components.
Search WWH ::




Custom Search