When to Use Package Diagrams and Collaborations

Packages are a vital tool for large projects. Use packages whenever a class diagram that encompasses the whole system is no longer legible on a single letter-size (or A4) sheet of paper.

Packages are particularly useful for testing. Although I do write some tests on a class-by-class basis, I prefer to do my unit testing on a package-by-package basis. Each package should have one or more test classes that test the behavior of the package.

I find collaborations useful whenever you want to refer to a particular interaction. Parameterized collaborations are useful when you have several similar collaborations in your system.

Get UML Distilled: A Brief Guide to the Standard Object Modeling Language, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.