# Exercise - Alternative Ways of Modeling

Since the model is always developed with a particular purpose in mind, there is no single best solution. Below we present some alternatives, which are equally valid because the exercise was not completely constrained, i.e., it did not describe the context in which the model is to be used.

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

However, we cannot have other -> string in the enumeration.

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
// because kind is a reference to Kind

Module Statistics: | All clafers: 17 | Abstract: 2 | Concrete: 15 | Reference: 4 | Constraints: 7 | Goals: 0 | Global scope: 1..* | Can skip name resolver: no |