abstract
Book
title
->
string
subtitle
->
string
?
// subtitle does not have to be a child of the title because title is
// mandatory, although conceptually subtitle is a point about title as well
page
->
integer
// if we don't really care about individual pages, just the number
[
page
>= 2
]
or
format
// the choice between xor and or depends on the context. For example,
paper
// whether the book store has a single entry for a book with multiple
hardcover
?
// formats or whether there must be a separate entry with exactly one
electronic
// format at the time
kind
->
Kind
// can be modeled as an enumeration
enum
Kind =
textbook
|
manual
|
reference
|
fiction
|
nonfiction
|
other
GenerativeProgramming
:
Book
[
title
= "Generative Programming"
]
[
page
= 589
]
[
paper
]
[
electronic
]
// because the type of page is integer
[
no
hardcover
]
// the book is in both paper and electronic formats but not hardcover
[
kind
=
nonfiction
]
// because kind is a reference to Kind