<< §4.2.(a) Method composition | ↑ Table of Contents ↑ | §4.2.(c) Replacing composition >> |
§4.2.(b) Additive composition
The before
and after
modifiers have the
effect of adding a call to the role method at the beginning or end
of the base method, resp.
In this case no data are transferred from the role to the base,
so if the role method has a result, this will always be ignored.
Example code (Callin):
1 | team class Company { |
2 | protected class Employee playedBy Person { |
3 | public void recalculateIncome() { ... } |
4 | recalculateIncome <- after haveBirthday; // callin binding |
5 | } |
6 | } |
<< §4.2.(a) Method composition | ↑ Table of Contents ↑ | §4.2.(c) Replacing composition >> |
Line 4 declares a callin binding for the role method
recalculateIncome()
defined in line 3. In combination with the role binding in line 2 this has the following effect:Person.haveBirthday
the methodCompany.recalculateIncome
is called.