--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/39bdaff4-6159-4261-a86c-3d62ab1fa802n%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/b4c091da-8cdc-d11b-1cd9-204bdb95e7c6%40gmail.com.
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/5a73017a-751c-3efd-14cd-611fc41ba2d2%40gmail.com.
-------- Original Message --------
Subject: Re: [eiffel-users] Conceptual meaning of undefine
From: Alexey Kanatov <alexey.v...@gmail.com>
Date: Tue, January 26, 2021 9:33 am
To: Eiffel Users <eiffel...@googlegroups.com>
Guys - please understand me right - my personal experience (being co-author of Visual Eiffel compiler implementing all feature adaptation mechanisms) and delivering lectures to students about systematic software design and development is one thing but another is talking to Java, C#, C++, JS, Python, Go ... guys (who are the majority) and trying to advocate good Eiffel manners is a very different thing. They just do not buy things that are obvious and natural to me. That is why I am looking for examples that can be valuable for such folks. Tnx, Alexey
On Tuesday, January 26, 2021 at 5:14:16 PM UTC+3 Alexey Kanatov wrote:
Hi Rosivaldo - I liked your example about some common class - " But you may have to undefine a feature even in single inheritance. For
example, suppose you have an effective class MY_SET, that implements the
concept of a set; you also have effective descendant classes, e.g.
SET_FAMILY and SUBSET_FAMILY, that are sets whose elements are sets
themselves. So you notice that your descendant classes have common
features that may be factored out to an ancestor class, but that
ancestor can not be MY_SET, because such features apply only to sets of
sets. You may then create a new *deferred* class, say, SET_OF_SETS, that
inherits from MY_SET and becomes the new parent of SET_FAMILY and
SUBSET_FAMILY. Since SET_OF_SETS is deferred, it may have to undefine
some features of MY_SET if such features *require* an effective class to
be valid. " - but the thing is that what you need is just to prevent object creation for SET_OF_SETS, undefining is just allows not to put redefine in SET_FAMILY and SUBSET_FAMILY. So, the natural solution is to break the relation between deferred class and the existence of deferred features within the class. Deferred class is the class for which we cannot (it has deferred features) or do not want to have objects created - that is all. So, this does not explain the need for undefining :-)
But you may have to undefine a feature even in single inheritance. For
example, suppose you have an effective class MY_SET, that implements the
concept of a set; you also have effective descendant classes, e.g.
SET_FAMILY and SUBSET_FAMILY, that are sets whose elements are sets
themselves. So you notice that your descendant classes have common
features that may be factored out to an ancestor class, but that
ancestor can not be MY_SET, because such features apply only to sets of
sets. You may then create a new *deferred* class, say, SET_OF_SETS, that
inherits from MY_SET and becomes the new parent of SET_FAMILY and
SUBSET_FAMILY. Since SET_OF_SETS is deferred, it may have to undefine
some features of MY_SET if such features *require* an effective class to
be valid.
Hope this helps.
Rosivaldo.
Em 25/01/2021 15:51, Alexey Kanatov escreveu:
> Dear all,
>
> Different people ask me about _the practical need_ of undefinition in
> case when we have effective class and after undefining of one of its
> features we come to a child class which will be deferred in such
> situation. So, conceptually we go down the inheritance hiearchy from the
> concrete class to some abstraction again. I was not able to find out a
> solid reason to provide some rationale for that - if one can help.
> Please. Alexey
>
> --
> You received this message because you are subscribed to the Google
> Groups "Eiffel Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to eiffel-users...@googlegroups.com
> <mailto:eiffel-users...@googlegroups.com>.
> To view this discussion on the web visit
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/eb2c980d-4a0a-4665-acfd-23bf16e3edb9n%40googlegroups.com.
I will try an example that I did some time ago.
We all know that every class inherit ANY. Also, we all know that ANY have some mechanism like `is_equal`, `copy`, `twin`, `out`, etc.
Some time ago, I was creating a library that used a lot of C pointers and I create an abstract class to represent every class of the library. I knew that every class had to redefine `copy` because using the one in ANY did not make any sense (because of the way the C pointers were used). But the way this method had to be redefined depends on the final effective class.
So, to force (and be certain not to forget) to redefine the `copy` methods in my classes, I undefined it in the abstract class.
Good day,
Louis M
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/d3bf08d4-c1cf-4579-badf-0851769abecdn%40googlegroups.com.
Dear Alexey,
Very simple. B restarts the abstraction chain from A in a clean(er) slate.
In the ideal refinement scheme, abstract concepts come first, then you refine repeatedly. Simplistic textbooks mention only this. (Suggestions for non-simplistic textbooks will be provided on request.) In practice, the design process is often not perfect; more yoyo. You alternatively think of good abstractions and good implementations but not always in that order.
There is an illuminating – old but still relevant – article by David Parnas entitled (approximate title from memory, I am writing this offline) “A rational design process, and how to fake it”. Every programmer should have read it. The title is clear enough: it’s OK if your design process is messy and tortuous, as long as you are able to reconstruct a coherent design ex post facto.
In the case at hand, sometimes you write a nice concrete class A only later to understand that it is just one implementation of a more general concept B. The generally commendable action at that point is to produce a deferred class B embodying the abstraction, put into it the essential features of A in deferred form, then rewrite A to inherit from B and effect the relevant features. But sometimes you cannot do this. A might be someone else’s class, and you do not have the authority to change it (and you certainly don’t want to clone it, the supreme crime in software development). Even if you could in principle change A, you might not want to, for example out of fear of creating incompatibilities if A is already used in lots of existing software. It would be a pity to restart the refinement chain from scratch. Instead you can start an upward segment of the yoyo, using undefinition to restore in B some or all of A’s lost virginity. Such process is less perfect than the one-directional refinement ideal, but can be a good tradeoff between abstraction, reusability and backward compatibility.
Although simple, this reasoning may be too subtle for your “single-inheritance minded” friends.
The main everyday application of undefinition does remain, as other writers have explained, a tool for multiple inheritance: inheriting two or more competing features in an effective (implemented) form from different parents, and undefining all but one, whose implementation from takes over for the new class and any subsequent refinement of it.
-- BM
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/d3bf08d4-c1cf-4579-badf-0851769abecdn%40googlegroups.com.
In 'one-father-two-mothers reproduction' (three-parent
babies, triple inheritance)
there is an additional undefinition pertaining to the mt
code of mother 1:
1/2 Fnc + 1/2 M1nc + 0 Fmt + 0 M1mt + 1 M2mt => 1
Baby_nc + 1 Baby_mt.
There are several techniques that achieve the last result.
One of these, pronuclear transfer, can be seen (approximately)
as single inheritance with undefinition + effecting:
1 Baby_nc + 0 Baby_mt + 1 M2mt => 1 Baby_nc + 1
Baby_mt.
Do not take this post too seriously :-)
Regards,
Karsten