Information Technology Reference
In-Depth Information
In an OO design there are mainly three kinds of refinement: Delegation of
functionality or responsibilities , attribute encapsulation ,and class decomposition .
Delegation of Functionality. Assume that C and C 1 are classes in Classes ,
C 1 o is an attribute of C and T x is an attribute of C 1 .Let m ()
} be a
method of C that directly accesses and/or modifies attribute x of C 1 . Then, if all
other variables in the method c areaccessiblein C 1 ,wehave Classes Classes 1 ,
where Classes 1 is obtained from Classes by changing m () {c ( o.x ,o.x ) } to m () {o.n () }
in class C and adding a fresh method n () {c [ x /o.x ,x/o.x ] } . This is also called the
expert pattern of responsibility assignment .
This rule and other refinement rules can prove big-step refinement rules, such
as the following expert pattern , that will be repeatedly used in the design of
the system.
c ( o.x ,o.x )
{
Theorem 4 (Expert Pattern). Given a list of class declarations Classes and
its navigation paths r 1 .....r f .x (denoted by le ), {a 11 .....a 1 k 1 .x 1 ,...,a 1 .....a k .x } ,
and
{
b 11 .....b 1 j 1 .y 1 ,...,b t 1 .....a tj t .y t }
starting from class C ,let m () be a method
of C specified as
C :: m () {
c ( a 11 .....a 1 k 1 .x 1 ,...,a 1 .....a k .x )
∧ le = e ( b 11 .....b 1 s 1 .y 1 ,...,b ts 1 .....b ts t .y t ) }
Then Classes can be refined by redefining m () in C and defining the following
fresh methods in the corresponding classes:
C :: check () {return = c ( a 11 .get π a 11 x 1 () ,...,a 1 .get π a 1 x ()) }
m () { if check () then r 1 .do-m π r 1 ( b 11 .get π b 11 y 1 () ,...,b s 1 .get π b s 1 y s ()) }
T ( a ij ):: get π a ij x i () {return = a ij +1 .get π a ij +1 x i () } ( i :1 .., j :1 ..k i 1)
T ( a ik i ):: get π a ik i x i () {return = x i } ( i :1 .. )
T ( r i )::
do-m π r i ( d 11 ,...,d s 1 ) {r i +1 .do-m π r i +1 ( d 11 ,...,d s 1 ) }
i :1 ..f − 1
T ( r f ):: do-m π r f ( d 11 ,...,d s 1 ) {x = e ( d 11 ,...,d s 1 ) }
T ( b ij ):: get π b ij y i ()
return = b ij +1 .get π b ij +1 y i ()
{
}
( i :1 ..t, j :1 ..s i
1)
T ( b is i ):: get π b is i y i () {return = y i } ( i :1 ..t )
where T ( a ) isthetypenameofattribute a and π v i denotes the remainder of the
corresponding navigation path v starting at position j.
This pattern informally represents the fact that a computation is realized by
obtaining the data that distributed in different objects via association links and
then delegating the computation tasks to the target object whose state is re-
quired to change.
If the paths {a 11 .....a 1 k 1 .x 1 ,...,a 1 .....a k .x } have a common prefix, say
up to a 1 j ,thenclass C can directly delegate the responsibility of getting the
x -attributes and checking the condition to T ( a ij ) via the path a 11 ....,a ij and
then follow the above rule from T ( a ij ) . The same rule can be applied to the
b -navigation paths.
Search WWH ::




Custom Search