O'Reilly logo

Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and the Unified Process, Second Edition by Craig Larman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

16.7. Creator

Assign class B the responsibility to create an instance of class A if one or more of the following is true:

  • B aggregates A objects.

  • B contains A objects.

  • B records instances of A objects.

  • B closely uses A objects.

  • B has the initializing data that will be passed to A when it is created (thus B is an Expert with respect to creating A).

Solution

B is a creator of A objects.

If more than one option applies, prefer a class B which aggregates or contains class A.

Who should be responsible for creating a new instance of some class?

Problem

The creation of objects is one of the most common activities in an object-oriented system. Consequently, it is useful to have a general principle for the assignment of creation responsibilities. Assigned ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required