A Refinement Algebra for ObjectOriented Programming - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

A Refinement Algebra for ObjectOriented Programming

Description:

are useful for reasoning about programs, deriving ... Federal University of Pernambuco. Recife, Brazil. Paulo Borba, Augusto Sampaio, M rcio Corn lio ... – PowerPoint PPT presentation

Number of Views:43
Avg rating:3.0/5.0
Slides: 23
Provided by: twikiC
Category:

less

Transcript and Presenter's Notes

Title: A Refinement Algebra for ObjectOriented Programming


1
A Refinement Algebra for Object-Oriented
Programming
Paulo Borba, Augusto Sampaio, Márcio Cornélio
  • Informatics Center
  • Federal University of Pernambuco
  • Recife, Brazil

2
Programming laws...
  • state properties about programming constructs
  • and
  • are useful for reasoning about programs, deriving
    refactorings, etc.

But is there a comprehensive set of nice laws
for OOP?
3
Change attribute visibility
class C extends D pri a T ads ops end
class C extends D pub a T ads ops end
cds,c
(?) B.a, for all B ? C, does not appear in cds,c
4
Relative completeness
  • Laws are used to define a normal form
    reduction process for ROOL programs
  • an empty class hierarchy except for Object, which
    contains only public attributes
  • the types of attributes and variables are
    primitive types or Object
  • eliminates methods, type casts, super, pri, pro

5
Normal form reduction process
6
Reduction process in brief
  • Rename methods and attributes
  • Move the code to the Object class
  • Introduce trivial casts
  • Eliminate super
  • Eliminate casts
  • Change all the declarations of object identifiers
    to type Object
  • Eliminate method calls and declarations

7
Move attribute to superclass
class B extends A ads ops end class C
extends B pub a T ads ops end
class B extends A pub a T ads
ops end class C extends B ads ops end
cds,c
(?) a is not declared by the subclasses of B in
cds (?) ...
8
Moving attributes up
9
Introduce trivial cast
If e C then
e
(C) e
cds,A
Useful for avoiding problems when moving up code
such as x self
10
Introduce method redefinition
class B extends A ads meth m pc end
ops end class C extends B ads ops end
class B extends A ads meth m pc end
ops end class C extends B ads meth m
super.m end ops end

(?) m is not declared in ops
11
Eliminating super
12
Move up redefined method
class B extends A ads meth m pds b end
ops end class C extends B ads meth m pds
b end ops end
class B extends A ads meth m pds if
(self is C) ? b self is C ? b end
ops end class C extends B ads ops end

13
Move up redefined method, provided
(?) private attributes and super do not
appear in b (?) super.m does not appear in
ops (?) b does not contain uncast occurrences
of self nor expressions in the form
((C)self).a for any private or protected
attribute a in ads (?) ...
14
Moving up redefined methods
15
Moving up methods
16
Change attribute type
class C extends D pub a T ads ops end
class C extends D pub a T ads ops end
cds,c
(?) T ? T and every occurrence of a in
non-assignable expressions of ops, cds and c
is cast with T or any subtype of T declared
in cds (?) ...
17
Changing types to Object
18
Eliminate non trivial cast
If le B, e B, C ? B and B ? B, then
e is C le e
le (C)e
cds,A
If e B, C ? B and m is declared in B or in any
of its superclasses in cds, then
e is C e.m(e)
((C)e).m(e)
cds,A
19
Eliminate method call
Let m be declared as pc. Then
e?null ? e?error pce/self (e)
e.m(e)
cds,A
(?) m is not redefined in cds (?) pc does not
contain references to super (?) all attributes in
pc are public
20
Eliminating methods
21
Conclusions
  • Comprehensive set of laws, but not enough to
    eliminate all OO constructs
  • Formal derivation of refactorings from the laws
  • Local changes
  • Separation of concerns
  • Increase or decrease OO qualities
  • Soundness of the laws do not rely on copy
    semantics and the renaming step

22
A Refinement Algebra for Object-Oriented
Programming
Paulo Borba, Augusto Sampaio, Márcio Cornélio
  • Informatics Center
  • Federal University of Pernambuco
  • Recife, Brazil
Write a Comment
User Comments (0)
About PowerShow.com