Parameterized Class

Several languages, most noticeably C++, have the notion of a parameterized clasys, or template.

This concept is most obviously useful for working with collections in a strongly typed language. This way, you can define behavior for sets in general by defining a template class Set.

     class Set <T> {
         void insert (T newElement);
         void remove (T anElement);

When you have done this, you can use the general definition to make set classes for more specific elements.

         Set <Employee> employeeSet;

You declare a parameterized class in the UML using the notation shown in Figure 6-18.

Figure 6-18. Parameterized Class

The T in the diagram ...

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.