Win, win, win.

by Colin Adams (modified: 2007 Apr 12)

Many people have said that they dislike having to export a routine just so that it can be used as an agent in a pre-condition. The objection is that if the routine does not naturally belong to the ADT, then it should not be exported to ANY. Well, this is a valid point, although there are already routines in ANY that do not belong in the ADT of most classes. Such as generating_type.

Anyway, using an inline agent to get round this problem is a far greater abuse, as the pre-condition can no longer be checked (except by relying on that bane of good software engineering - cut-and-paste. Just imagine what it would be like to cross a bridge built by civil engineers using cut-and-paste!).

Fortunately, I have a proposal to avoid both problems.

Simply prefix the exported client list (usually just ANY) with the keyword "agent". This says that features in this feature clause are exported to the clients listed only when called as agents. As such, they are not part of the ADT, yet thay can still be called (but only as agents) in a pre-condition.

Furthermore, the usual case can be abbreviated to {agent}, to mean the same as {agent ANY}.

A nice win-win-win situation.

  • Martin Seiler (10 years ago 13/4/2007)

    wiki wiki web

    Hey Colin,

    Did you know that we have developer wiki:

    Some of your ideas would really fit good in there.

    -- mTn-_-|

    • Colin Adams (10 years ago 13/4/2007)


      I know about it, and have contributed at least one page, and several comments. But I thought this was better as a blog entry.

      Colin Adams