Adaptive Object-Oriented Software The Demeter Method

silkthrilledSoftware and s/w Development

Nov 18, 2013 (3 years and 6 months ago)

46 views

Adaptive Object-Oriented
Software
The Demeter Method
Karl Lieberherr
College of Computer Science
Northeastern University Boston
Copyright (C) 1996 by Karl J. Lieberherr
All rights reserved by PWS Publishing Company
To order the book, send email to: info@pws.com
Put on the Web with permission by Mike Sugarman, PWS.To Ruth, Andrea and Eva
Produced with Acrobat 4.0.
Author’s email
lieber@ccs.neu.edu





























































































































































































































































































































































































































































































































































































































































































































































































book
~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~ ~~~~~~
software
~~~~~~
~~~~
and documentation
~~~~~~~~
~~~
theses
~~~~~~~~
~~~
papers
~~~~~
~~~~~
~~
FAQ
~~~
viewgraphs
~~
exams
sample applications
e−mail
world−wide web

























































































































































































































































































































































































































































































































































































































































































































































































































Adaptive Programming
Object−Oriented Programming
One Possible Implementation:
C++
Demeter Tools/C++
Legend:
make use of
is implemented by


















....















Adaptive
Program 1
One Customizer
Adaptive
Program 2
Adaptive
Program i















....











....

Customizer 1
One Adaptive
Program
Customizer 2
Customizer i































....























1
21
f3
2 42
f4
1
21
f1 f2










































Infinitely many class structures
Adaptive Program
satisfies
selects selects
denotes
selects
.
.
.
.
.
.
.
. .
. .
Family of programs





















































































































































































































Conglomerate
Ident
name
state
head
String
country
name
Company
Address
String city
location
turnover
street
officers
String
subsidiaries OfficerList
name
SubsidiaryList
title
Salary
Number
company
Officer
Subsidiary
salary
value
sharePercentage
Ordinary ShareHolding
WhollyOwned PartiallyOwned
stake
Number

























































































Conglomerate
void Conglomerate::computeSalary( int& totalSalary )
{
this−>head−>computeSalary( totalSalary );
head
}
void OfficerList::computeSalary( int& totalSalary )
{
Company
OfficerList_iterator nextOfficer( this );
void Company::computeSalary( int& totalSalary )
Officer* eachOfficer;
{
this−>officers−>computeSalary( totalSalary );
while( eachOfficer = nextOfficer() )
}
officers
eachOfficer−>computeSalary( totalSalary );
}
OfficerList
void Officer::computeSalary( int& totalSalary )
{
this−>salary−>computeSalary( totalSalary );
Salary
}
Officer salary
void Salary::computeSalary( int& totalSalary )
{
totalSalary = totalSalary + *(this−>get_value());
}
Ordinary ShareHolding


































Conglomerate
Ident
name
state
participants
country
CompanyList
Address
String city
location
street
subsidiaries
String
name
turnover
Company
officers
String
OfficerList
name
title
Salary
Number
Officer
salary
value

void Conglomerate::computeSalary( int& totalSalary )
{
Conglomerate
this−>participants−>computeSalary( totalSalary );
void CompanyList::computeSalary( int& totalSalary )
}
{
CompanyList_iterator nextCompany( *this );
participants
Company* eachCompany;
while( eachCompany = nextCompany() )
CompanyList
eachCompany−>computeSalary( totalSalary );
}
void Company::computeSalary( int& totalSalary )
{
Company void OfficerList::computeSalary( int& totalSalary )
this−>officers−>computeSalary( totalSalary );
{
}
CompanyList_iterator nextOfficer( *this );
officers
Company* eachOfficer;
while( eachOfficer = nextOfficer() )
OfficerList
eachOfficer−>computeSalary( totalSalary );
}
Officer
void Salary::computeSalary( int& totalSalary )
{
void Officer::computeSalary( int& totalSalary ) salary
totalSalary = totalSalary + *(this−>get_value());
{
}
this−>salary−>computeSalary( totalSalary );
}
Salary








































































































































































Text Village DemNumber
name
numberOfMuseums
inhabitantData
swimmingPools
neighbors
Settlement_List
Inhabitant_List SwimmingPool_List


































































Settlement
Village Town
universityData
name
numberOfMuseums University_List
Text
DemNumber
inhabitantData
swimmingPools neighbors
SwimmingPool_List Settlement_List
Inhabitant_List





























































































































































































































































Object
Pencil Sponge
waterWeight
weight
spongeMaterialWeight
Weight
val
DemNumber





















































































































































































































































































































































































































































































































































































































































































































































































Conglomerate Subsidiary_Empty
Subsidiary_NonEmpty
rest
first
name
head
subsidiaries
Subsidiary_List
Subsidiary
company
DemIdent
Company
officers
Officer_List
location
state country
name
turnover
WhollyOwned
PartiallyOwned
rest
stake
Officer_Empty
street
v
DemNumber
Officer_NonEmpty
city
title
Address
DemString Salary
salary
first
name
Officer
share_percentage
ShareHolding_Officer
Ordinary_Officer





































































































































































































































































































































































































































































































































































































































































Conglomerate
Subsidiary_NonEmpty
rest
first
head
subsidiaries
Subsidiary_List
Subsidiary
company
Company
officers
Officer_List
WhollyOwned
PartiallyOwned
rest
Officer_NonEmpty
Salary
salary
first
Officer
Ordinary_Officer ShareHolding_Officer


































































































































































Conglomerate
name
head
subsidiaries
Subsidiary_List
Subsidiary
company
DemIdent
Company
officers
Employee_List
location
employees
state country
turnover
name
WhollyOwned
PartiallyOwned
stake
Employee
street
name
salary
DemNumber
city title
Address
DemString Salary
share_percentage
v
DemReal
Ordinary_Employee ShareHolding_Employee
























































Conglomerate
head
subsidiaries
Subsidiary_List
Subsidiary
company
Company
officers
Employee_List
employees
WhollyOwned
PartiallyOwned
Employee
salary
Salary
Ordinary_Employee ShareHolding_Employee




















































































Conglomerate
head
Company
Officer_List
officers
rest
Salary
Officer_NonEmpty
salary
first
Officer
Ordinary_Officer ShareHolding_Officer

















































































































































































































































































































































































































































































































































































































































Adaptive software
behaviors
generic data model
specific data models
object−oriented programs













































































































































































Infinitely many class structures compatible with adaptive program C
Adaptive program C
compatible
defines selects selects
selects
.
.
.
.
.
.
.
.
.
. .
An infinite family of programs defined by adaptive program C


















class
structure
adaptive program
hooks

























































B
A
c














B
A
c
C