Constraints

Scott W. Ambler
The Object Primer 3rd Edition: Agile Model Driven Development (AMDD) with UML 2 A constraint is a restriction on the degree of freedom you have in providing a solution. Constraints are effectively global requirements, such as limited development resources or a decision by senior management that restricts the way you develop a system. Constraints can be economic, political, technical, or environmental and pertain to your project resources, schedule, target environment, or to the system itself. Figure 1 presents several potential constraints for the university system. Constraints are documented in a similar manner to business rules and technical requirements.  

 

Figure 1. Constraints (summary form).

  • C24 The system will work on our existing technical infrastructure – no new technologies will be introduced.

  • C56 The system will only use the data contained in the existing corporate database.

  • C73 The system shall be available 99.99% of the time for any 24-hour period.

  • C76 All master’s degree programs must include the development of a thesis.

 

An interesting thing about Figure 1 is that it contains two constraints, C73 and C76, that could also be identified as a technical requirement and a business rule respectively.  Constraints can be a little confusing because of their overlap with business rules and technical requirements.  Don’t worry about it.  The important thing is that you’ve identified the requirement, if you happen to mis-categorize it as a constraint instead of a business rule that’s perfectly okay, the world isn’t going to end as a result (unless of course you’re working on a nuclear missile guidance system).  I wouldn’t identify the same requirement as both a business rule and a constraint, that would be busy work, but I wouldn’t waste any time arguing over whether something is a constraint or another type of requirement.

As with business rules, you identify constraints as you are developing other artifacts, such as your use case model and user interface.  

 

The Object Constraint Language (OCL)

One way to describe business rules, technical requirements, or constraints, is via the Object Constraint Language (OCL).  The OCL is a formal language similar to structured English to express side-effect-free constraints within UML models (Warner and Kleppe 1999). OCL can appear on any UML diagram or in the supporting documentation describing a diagram, such as business rule definitions. It can even be used on non-UML diagrams for that matter.  OCL can be used for a wide variety of purposes, including specifying the invariants of classes, preconditions and postconditions on operations, and constraints on operations. The reality is that a graphical model, such as a UML class diagram, isn’t sufficient for a precise and unambiguous specification. You must describe additional constraints about the objects in the model, constraints that are defined in your supplementary specification.

I rarely use OCL when I’m modeling.  First, few people know how to read OCL, let alone write it, so you’re restricting the audience of your models when you use it.  Second, it’s complex.  OCL statements are depicted on UML diagrams in the format “{constraint description},” where the constraint description may be in any format, including predicate calculus.  I personally find that free-form text is far more effective.   Third, if I want to describe rules in such a way that I can generate working software from them I’ll use a real programming language such as Java or C# to do it. 

The OCL was an interesting concept but it hasn’t been adopted by the industry.  Because it shows no signs of being adopted any time soon in my opinion it isn’t worth the effort to learn.

 

Source

This artifact description is excerpted from Chapter 7 of The Object Primer 3rd Edition: Agile Model Driven Development with UML 2.

 

Suggested Reading

The Object Primer 3rd Edition: Agile Model Driven Development (AMDD) with UML 2   The Object Primer 3rd Edition: Agile Model Driven Development with UML 2 is an important reference book for agile modelers, describing how to develop 35 types of agile models including all 13 UML 2 diagrams.  Furthermore, this book describes the techniques of the Full Lifecycle Object Oriented Testing (FLOOT) methodology to give you the fundamental testing skills which you require to succeed at agile software development.  The book also shows how to move from your agile models to source code (Java examples are provided) as well as how to succeed at implementation techniques such as refactoring and test-driven development (TDD).  The Object Primer also includes a chapter overviewing the critical database development techniques (database refactoring, object/relational mapping, legacy analysis, and database access coding) from my award-winning Agile Database Techniques book.
Agile Modeling   Agile Modeling: Effective Practices for Extreme Programming and the Unified Process is the seminal book describing how agile software developers approach modeling and documentation.  It describes principles and practices which you can tailor into your existing software process, such as XP, the Rational Unified Process (RUP), or the Agile Unified Process (AUP), to streamline your modeling and documentation efforts.  Modeling and documentation are important aspects of any software project, including agile projects, and this book describes in detail how to elicit requirements, architect, and then design your system in an agile manner.
Elements of UML 2.0 Style   The Elements of UML 2.0 Style describes a collection of standards, conventions, and guidelines for creating effective UML diagrams. They are based on sound, proven software engineering principles that lead to diagrams that are easier to understand and work with.  These conventions exist as a collection of simple, concise guidelines that if applied consistently, represent an important first step in increasing your productivity as a modeler.  This book is oriented towards intermediate to advanced UML modelers, although there are numerous examples throughout the book it would not be a good way to learn the UML (instead, consider The Object Primer).  The book is a brief 188 pages long and is conveniently pocket-sized so it's easy to carry around.

 

Translations

 

Let Me Help

I actively work with clients around the world to improve their information technology (IT) practices as both a mentor/coach and trainer.  A full description of what I do, and how to contact me, can be found here

 


Copyright © 2003-2006 Scott W. Ambler

Last updated: April 3, 2006
This site owned by
Ambysoft Inc.

Agile Data (AD)  |  Agile Unified Process (AUP)  |  Enterprise Unified Process (EUP)  |  My Writings