Re: weak contract



Responding to Johansson...

I'm reading in a paper and it says.

If all these questions stem from the same paper, then I am beginning to suspect that the author was making some assumptions about the audience (e.g., they had taken his course).



Use weak contract for - end user comminication (end users) * cases where the end user may interfere * user interfaces

To me a "weak contract" is one that that has less stringent conditions.

{0 <= i <= 65535} is a weak contract on a 16-bit machine.

{i = 47 | 92} is a strong contract on a 16-bit machine.

I don't see where that has much relevance to the UI per se because...


and some more here that I don't mention

Now to my question:

Assume you have an operation named foo(String name, int articleNr, int count)
that is called from an end user. If we assume that the precondition for this foo is
pre: name != NULL articleNr >0 count > 0
then is would be possible to use strong contract for the end user before executing operation foo.
So why do they say use weak contract for end user comminication (end users)
* cases where the end user may interfere
* user interfaces

I would regard your example as a fairly weak contract compared to common business circumstances. For example, commonly the name has to at least match certain patterns (e.g., all alpha, maximum length) and articleNr is probably limited to some maximum number (e.g., the number of articles in the DB). However, the notion of strong vs. weak is relative and seems to depend on the nature of the condition rather than context.


So my best guess is that the author is aiming at a somewhat different situation where one is deciding where to enforce contracts. The point being that for data entry one might want more generic conditions (e.g., text patterns) that are easier to validate on-the-fly while deferring specific constraints that depend up business context (e.g., the name exists in the DB) until a context where the business semantics is known (i.e., another subsystem that abstracts those business rules and policies).

//Tony




--

*************
There is nothing wrong with me that could
not be cured by a capful of Drano.

H. S. Lahman
hsl@xxxxxxxxxxxxxxxxx
Pathfinder Solutions  -- Put MDA to Work
http://www.pathfindermda.com
blog: http://pathfinderpeople.blogs.com/hslahman
(888)OOA-PATH



.