Home > Articles > Software Development & Management > UML

This chapter is from the book 16.18 Template Classes and Interfaces

16.18 Template Classes and Interfaces

Many languages (Java, C++, …) support templatized types, also known (with shades of variant meanings) as templates, parameterized types, and generics.[7] They are most commonly used for the element type of collection classes, such as the elements of lists and maps. For example, in Java, suppose that a Board software object holds a List (an interface for a kind of collection) of many Squares. And, the concrete class that implements the List interface is an ArrayList:

public class Board
{
private List<Square> squares = new ArrayList<Square>();
// …
}

Notice that the List interface and the ArrayList class (that implements the List interface) are parameterized with the element type Square. How to show template classes and interfaces in the UML? Figure 16.18 illustrates.

Figure 16.18 Templates in the UML.

  • + Share This
  • 🔖 Save To Your Account