In this part . . .
In this part, we get to make several lists of stuff that help you model with UML while still being fun, informative, and useful — such as common UML pitfalls and mistakes to avoid, Web sites full of additional UML information to surf, UML tools that make pretty pictures easy to draw, and a selection of the best UML diagrams — complete with instructions on when to use them.
In This Chapter
Avoiding diagram pitfalls
Checking for problems
We’ve been teaching modeling for the analysis and design of systems for more than a
We see developers create some classes with attributes but no operations, and other classes that have no attributes— only operations. (We don’t know about you, but every object-oriented class we ever met had both attributes and operations.)
The developers making this mistake are really thinking about data structures and the functions that act on the data. They translate that idea into the object-oriented world by using the steps much like the following:
|
Blunder 1: |
Equate data structure only with class attributes. |
|
Blunder 2: |
Equate a function that manipulates data structures only with class operations. |
|
Blunder 3: |
Create one instance of the class with operations. |
|
Blunder 4: |
Create one instance of the class with attributes. |
|
Blunder 5: |
Use the class with the operations to change the values of the class with attributes. |
Warning Do not follow the five steps we’ve just outlined (but you knew that). They lead to splitting up attributes and operations. Big mistake.
Tip
Make your classes whole by
Figure 21-1 shows classes with attributes and classes with operations—separately (and confusingly). The
Vehicle
class works with the
Truck
class. The
Tools
class is similar to the
ToolKit
class. The
Person
class is another
Figure 21-1:
Example of a split-classes mistake.
Figure 21-2:
Example of classes made whole.
We’ve
Some developers produce only class diagrams because that’s what
Other developers seem compelled to use every single UML diagram whether they need to or not. Some people
Tip Every UML diagram has a purpose and value, but not every diagram is necessary on every project. Your project is unique; some—but not all—UML diagrams will help you get the job done. If your project involves maintaining an existing system (for example), then some class diagrams, a couple of sequence diagrams, and a deployment diagram may be all you need. However, if you build real-time embedded systems, you need state diagrams along with sequence diagrams (because you want the team to understand timing issues), and some class diagrams. Every project is different.
Check out Chapter 24, where we list ten useful diagrams to get you started. Our aim here is to avoid getting stuck on just one diagram—but also to spare you the confusion of trying to use all the possible UML diagrams.