Chapter 10. The Object Constraint Language
This chapter introduces the UML's Object
Constraint
Language (OCL), a sublanguage of the UML that allows for capturing
constraints or rules and attaching them to model elements, which then
must satisfy the constraints for the model to be considered correct
(also known as well formed). I discuss how to
express rules as expressions and how to attach those rules to model
elements as properties. As the OCL is a complete language in its own
right, this chapter does not discuss every aspect of the OCL, as that
would require a whole different book. Instead, this chapter focuses
on simply introducing you to the OCL. For further information beyond
this chapter, please see Appendix A for references
to notable resources on the World Wide Web and various books that
further discuss the OCL.
For example of how the OCL might be used, recall that in Chapter 9 I discussed how a model is erroneous if a
project's start date succeeds its end date. I
pointed out that a project's start date must precede
its end date. In Chapter 9, I captured this and
other rules using natural human language, but we can use the OCL to
more formally capture such rules. Capturing such rules more formally
is valuable, because we can begin to automate the checking of the
correctness of UML models.
|