https://dev.eiffel.com/index.php?title=Named_Inheritance&feed=atom&action=history
Named Inheritance - Revision history
2024-03-29T14:58:36Z
Revision history for this page on the wiki
MediaWiki 1.24.1
https://dev.eiffel.com/index.php?title=Named_Inheritance&diff=11732&oldid=prev
Clemahieu at 23:16, 1 November 2008
2008-11-01T23:16:34Z
<p></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 23:16, 1 November 2008</td>
</tr><tr><td colspan="2" class="diff-lineno">Line 178:</td>
<td colspan="2" class="diff-lineno">Line 178:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>two: B</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>two: B</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>do</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>do</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>create <del class="diffchange diffchange-inline">A</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>create <ins class="diffchange diffchange-inline">obj</ins></div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>one := <del class="diffchange diffchange-inline">a</del>.one</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>one := <ins class="diffchange diffchange-inline">obj</ins>.one</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>two := <del class="diffchange diffchange-inline">a</del>.two</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>two := <ins class="diffchange diffchange-inline">obj</ins>.two</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>end</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>end</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>end</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>end</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div></e></div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div></e></div></td></tr>
</table>
Clemahieu
https://dev.eiffel.com/index.php?title=Named_Inheritance&diff=11731&oldid=prev
Clemahieu at 19:55, 31 October 2008
2008-10-31T19:55:51Z
<p></p>
<p><b>New page</b></p><div>[[Category:ECMA]]<br />
{{Research}}<br />
<br />
Motivation:<br />
*Remove the need for adapter classes.<br />
*Reconcile the relatively loose conventions around agents in to the more strict conventions of inheritance.<br />
<br />
Similarity between adapter classes and agents<br />
----<br />
Take the starting classes A and B:<br />
<e><br />
class A<br />
feature<br />
process_1<br />
do<br />
-- Operate on value_1<br />
end<br />
value_1: INTEGER<br />
test_1: BOOLEAN<br />
process_2<br />
do<br />
-- Different operation on value_2<br />
end<br />
value_2: INTEGER<br />
test_2: BOOLEAN<br />
end<br />
</e><br />
<br />
<e><br />
deferred class B<br />
feature<br />
process<br />
deferred<br />
end<br />
value: INTEGER<br />
deferred<br />
end<br />
test: BOOLEAN<br />
deferred<br />
end<br />
end<br />
</e><br />
<br />
And adapters C and D:<br />
<e><br />
class C<br />
inherit<br />
B<br />
feature<br />
make (sourceA: A)<br />
do<br />
source := sourceA<br />
end<br />
source: A<br />
process<br />
do<br />
source.process_1<br />
end<br />
value: INTEGER<br />
do<br />
result := source.process_1<br />
end<br />
test: INTEGER<br />
do<br />
result := source.test_1<br />
end<br />
end<br />
</e><br />
<e><br />
class D<br />
inherit<br />
B<br />
feature<br />
make (sourceA: A)<br />
do<br />
source := sourceA<br />
end<br />
source: A<br />
process<br />
do<br />
source.process_2<br />
end<br />
value: INTEGER<br />
do<br />
result := source.value_2<br />
end<br />
test: BOOLEAN<br />
do<br />
result := source.test_2<br />
end<br />
end<br />
</e><br />
<br />
Using these adapters, if A wanted to provide clients access to itself in 2 different ways through B, the following features could be added to A:<br />
<e><br />
class A<br />
--Same features as above--<br />
feature<br />
one: B<br />
do<br />
result := create {C}.make (current)<br />
end<br />
two: B<br />
do<br />
result := create {D}.make (current)<br />
end<br />
end<br />
</e><br />
<br />
Another way A could provide access to itself similar to B is by use of agents:<br />
<e><br />
class A<br />
--Same features as above--<br />
feature<br />
one: TUPLE [process: PROCEDURE [ANY, []], value: FUNCTION[ANY, [], INTEGER], test: FUNCTION[ANY, [], BOOLEAN]]<br />
do<br />
result.process := agent process_1<br />
result.value := agent value_1<br />
result.test := agent test_1<br />
end<br />
two: TUPLE [process: PROCEDURE [ANY, []], value: FUNCTION[ANY, [], INTEGER], test: FUNCTION[ANY, [], BOOLEAN]]<br />
do<br />
result.process := agent process_2<br />
result.value := agent value_2<br />
result.test := agent test_2<br />
end<br />
end<br />
</e><br />
<br />
Disadvantages of adapters:<br />
*Requires 1 new class for every way a class wishes to provide facilities to clients.<br />
<br />
Disadvantages of agents:<br />
*Requires a new, though already implemented, language construct `agents'.<br />
*Strongly typed contracts related to agents are not defined.<br />
<br />
Implementation of A using named inheritance:<br />
----<br />
<e><br />
class A<br />
inherit<br />
one: B<br />
rename<br />
process as process_1,<br />
value as value_1,<br />
test as test_1<br />
end<br />
two: B<br />
rename<br />
process as process_2,<br />
value as value_2,<br />
test as test_2<br />
end<br />
feature<br />
process_1<br />
do<br />
-- Operate on value_1<br />
end<br />
value_1: INTEGER<br />
test_1: BOOLEAN<br />
process_2<br />
do<br />
-- Different operation on value_2<br />
end<br />
value_2: INTEGER<br />
test_2: BOOLEAN<br />
end<br />
</e><br />
<br />
A client of A could make use of the named inheritance functionality as such:<br />
<e><br />
class APPLICATION<br />
feature<br />
make<br />
local<br />
obj: A<br />
one: B<br />
two: B<br />
do<br />
create A<br />
one := a.one<br />
two := a.two<br />
end<br />
end<br />
</e></div>
Clemahieu