33.7. Handling Payments with Polymorphism and Do It Myself

One of the common ways to apply polymorphism (and Information Expert) is in the context of what Peter Coad calls the “Do It Myself” strategy or pattern [Coad95]. That is:

Do It Myself

“I (a software object) do those things that are normally done to the actual object that I'm an abstraction of.” [Coad95]

This is the classic object-oriented design style: Circle objects draw themselves, Square objects draw themselves, Text objects spell-check themselves, and so forth.

Notice that a Text object spell-checking itself is an example of Information Expert: The object that has the information related to the work does it (a Dictionary is also a candidate, by Expert).

Do It Myself and Information ...

Get Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and the Unified Process, 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.