Hi Folks, Do you have a notable declarative expression that you can share? An XML Schema is a model; specifically, a data model. When you create an XML Schema, you are “data modeling.” A key skill for modeling (both data modeling and software modeling) is the ability to think and express declaratively. Below are two problems and their declarative expressions.
Problem #1 Declaratively express this constraint:
A set of nodes must form ring (cyclic) topology. The following graphic shows a set of nodes with a ring topology: Assume each node has a
succ field, identifying its neighbor. How would you declaratively constrain the nodes to a ring topology? Scroll down to see the answer …
Problem #2 Declaratively express the change in this pile of items:
Scroll down to see the answer … …
Answer to Problem #1 Here is a declarative description of constraining nodes to form a ring topology:
All nodes must be reachable from any node Here is how the constraint is expressed in the modeling language called Alloy:
all n: Node | Node in n.^succ For each Node n, the entire set of nodes must be in the set of nodes reachable by n.
The caret symbol denotes the set of nodes reachable from
n. Give a set of nodes, plus the above constraint expression, to a constraint satisfaction (SAT) tool and the SAT tool will decide if the nodes satisfy the constraint (i.e., the SAT tool will tell
you if the nodes are in a ring structure).
Answer to Problem #2 Here is a declarative description of the change in the pile:
The pile after is equal to the pile before, Here is how the constraint is expressed using the Alloy language:
before, after: Time | pile.after = pile.before - item Important: That expression is
not a recipe/algorithm/procedure for how to remove an item from the pile. Rather, it is a
description of the pile after by comparing it to the pile before.
/Roger |