Re: [CLOS] Ensuring a method exists



Ken Tilton <kentilton@xxxxxxxxx> writes:

Of course the big question no one will ask is why you want to do
this. Sounds like bad design. But you are not alone, we get people
wanting to do this almost as often as we get people trying to fix the
parens.

I'm not so certain that this kind of thing is necessarily bad design.
I think that CLOS's generic functions and class inheritance provide
good ways of adding functionality ("extending", if you will) by
subclassing; what I think is harder to express in vanilla CLOS is
removal of invariants, or generalization of functionality.

To take a concrete example, consider implementing a data structure
such as an R-tree, which has a relatively complex set of invariants
that you might want to assert are true at various points in the
protocol. Then you implement a variant, such as the R*-tree, which
obeys the same protocol, and indeed shares much of the implementation,
but has slightly different (but overlapping) invariants. How do you
model that, with just CLOS? Probably what you do is define some kind
of abstract base class and make R-trees and R*-trees inherit from that
base class, but now you can't share the methods that actually should
be shared: instead you have to implement the methods separately,
admittedly maybe with a call to the same function. So sometimes I
think it makes sense to want to treat direct instances and general
instances of a class differently: it allows you to express things in a
way that is closer to the application space (which is what we're
aiming for, right?)

I believe this is the kind of thing that beta's inner() was invented
to help in modelling; there are various claims around that it helps
with extensible GUI hierarchies (see e.g. Goldberg, Findler and Flatt,
"Super and Inner -- Together at Last!").

Christophe
.



Relevant Pages

  • Re: [CLOS] Ensuring a method exists
    ... I'm not so certain that this kind of thing is necessarily bad design. ... removal of invariants, or generalization of functionality. ... model that, with just CLOS? ...
    (comp.lang.lisp)
  • Re: Language improvement: Add scope to class member fields
    ... every small subset of functionality into seperate classes. ... MyMethodwould check this flag first within a lock and only run the method ... currently stands there is no protection. ... Allowing classes to become more complex is not a terrific design goal, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Did I write a good (efficient) program?
    ... The priniples of object-oriented design do not include ... the use of inheritance to overcome inadequate or faulty ... modifying a base class may be ... principles to those of the paradigm. ...
    (comp.lang.cobol)
  • Re: news of the week
    ... And as market leader, that company does not have the time to listen to ... When I designs a website, I constantly have to think about why ... didn't design the website for me. ... offers the same functionality, yet. ...
    (rec.games.computer.ultima.dragons)
  • Late Show Fashion #2510
    ... "I have little interest in design. ... I hate placemats that ... Okay all good design is based upon functionality. ... aesthetics, functionality, and comfort. ...
    (alt.fan.letterman)