A problem domain (pd) class represents a 'real world' concept such as sales, invoices, people, places and things, rather than technology concepts such as user interface windows, pages, panels and controls, database rows, tables, connections and transactions, and network services and messages. Often referred to as defining the business objects or business logic of the software, problem domain classes model the concepts, ideas and rules within our software that are left after stripping away the stuff specific to the technologies we are using. They form the heart of a piece of software.
Modeling in color is an object modeling technique. It helps identify and define appropriate, problem domain classes for a software component, application, or system.
Problem domain classes form the most important logical layer of the software in a conventional object-oriented software application, or system. In more component-based or service-oriented software, problem domain classes help drive the definition and organization of business services and components. They also help drive the design of the problem domain classes used in the internal implementation of a component or service.
Regardless of whether the software is conventional, component-based,
or service-oriented, nearly all modern software architectures require a
significant number of technology classes to support each problem domain
class. As shown in
figure 1:

Figure
1: A PD class can require a significant number of supporting technology
classes
While not every pd class requires so many supporting technology
classes, significant pd classes may require more because they appear in
multiple views,
participate in multiple services, and be persisted in different
ways at different times. The whole thing is further complicated by
the relationships and dependencies between pd classes, such as the
products within a sale for a customer, or the items in a delivery made
by a supplier. The average
number of supporting classes for a pd class
can easily reach a dozen or more. This is without considering any
related unit, integration and system test classes and scripts.
Despite best-practice encapsulation, changes to a pd class
frequently ripple
through the supporting classes.
Small refactorings (renaming an operation for example) are automated
within modern integrated development environments (IDE) such as Eclipse, NetBeans, Visual Studio
and XCode.
More significant changes (removing an attribute, changing a
relationship from one-to-one to one-to-many, making a relationship
bi-directional, for example) still typically require manual updates and
retesting of a number of classes, configuration files and required
supporting artifacts.
Some amount of change is inevitable, but any patterns or strategies that enable earlier identification of more robust problem domain classes are obviously worthwhile learning. This is precisely what the 'modeling in color' technique provides, especially for business and industrial I.T. components and systems.
First used on a major Java software development project in Singapore
in 1997 and building on his previous work on object-oriented analysis
and design patterns and strategies, Peter Coad, researched and refined
the technique over the
next couple of years. In 1999, Peter Coad, and
co-authors, Eric Lefebvre, and Jeff
De Luca, published an introduction to technique in their book,
Java Modeling in Color with UML.
Other acknowledged contributors to the technique and related FDD
process include Phil Bradley,
Jon Kern, Mark
Mayfield, David North, and myself.
The modeling in color patterns and strategies are built around the
idea of class archetypes.
In business systems, the same general kinds of significant problem
domain class keep appearing, no matter what the domain. For example, we
nearly always find classes that represent business
transactions or interactions of different types such as sales,
orders, rentals, bookings, scheduled events, deliveries, submissions,
approvals, inquiries, etc. Then we generally find classes that
model the parties, places, and things that participate in those
business transactions or interactions, the
people or organizations doing the buying, selling, ordering,
submitting, approving, etc. In addition, the products and services
being bought, sold, approved, etc., need to be represented, as do the
places like
shops, bank branches, websites, etc., where all this happens. These
general kinds of classes are not specific to a domain. It does not
matter whether the problem domain is banking, insurance, retail,
manufacturing, human resources, travel, transportation, or something
else, the same general kinds of classes keep on appearing. The
different kinds of class are independent of the domain. They are domain
neutral.
It is not just business systems where these kinds of class appear. In industrial systems we have classes modeling specific types of event and intervals of time such as changes in state of a sensor or switch, a period of time over which a measurement is taken, the length of time a piece of equipment is ramping up to a certain level of performance, and so on. Again, there are also typically, party, place, and thing classes representing the sensors and devices themselves, human operators supervising the equipment or process in question, and the locations of the various pieces of equipment, etc.
The similarities between all the classes of one of these
rough
categories are not close enough to be generalized into a useful
superclass or Java/C#-style interface. However, the similarities are
close
enough for them to help guide the choice and definition of problem
domain classes in
our designs. Modeling in color calls these rough categories, class
archetypes, the term archetype
supposedly representing a less rigid pattern and, therefore, being a
more appropriate term than stereotype.
Modeling in color recognizes four class archetypes and assigns each a
color.

Figure 2: Modeling in color defines
four class archetypes for problem domain classes
The four class archetypes as shown in figure 2 are:
Because classes of the same class
archetype model roughly the same
sort of thing, their objects generally need to remember similar sorts
of bits of information and perform similar sorts of tasks.
For example, objects of a Moment-Interval class generally remember the
date and time
they occurred and can tell you if they completed successfully or not.
Objects of a Role class typically need to remember some sort of
identifier they have been given that authorizes them to perform that
role, a pilot's license number, for example, and so on.
By examining numerous examples of each class archetype and generalizing slightly we can create a rough list of typical operations and attributes for each class archetype. Each attribute or operation in the list represents a typical kind of operation or attribute that we might expect to define for classes of that archetype (see Figure 3).

Figure 3: The four class archetypes each have typical attributes and operations
Few if any of the classes in a particular model will have examples of all the typical attributes and operations of their class archetypes. If a particular typical attribute or operation is not relevant for a specific class we simply do not define an equivalent attribute or operation for that class. For example, some Moment-Interval classes need the concept of relative priorities and will have the equivalent of a priority attribute. Other Moment-Interval classes do not.
Each typical attribute or operation of a class archetype may match multiple attributes or operations on a specific class. For example a Moment-Interval may need both a major and minor status attribute if it has a complex lifecycle.
The lists of typical attributes and operations are not exhaustive either. Our classes will attributes and operations that are not in the relevant archetypes list. For example a Party class modeling an individual person may contain a retention date indicating when data must be erased to comply with some legal requirement. No equivalent for this attribute exists in the Party, Place, Thing class archetype.
The typical attributes and operations of a class archetype are simply a list of suggestions for specific attributes and operations that we might need in our actual class definitions. They act as prompts and hints of things we should consider when creating or reviewing a class belonging to a particular class archetype.
Another way to think of this is that each operation or attribute of a class archetype acts as a reminder of a typical responsibility for classes of a particular class archetype. If we can identify the class archetypes of the classes in our problem domain, the lists of typical operations and attributes give us a check-list that can help us review or place responsibilities appropriately in our own models. For example, the first attribute in each of the class archetypes is some sort of identification or reference number. This reminds us that objects of classes belonging to any of the class archetypes have a responsibility to enable themselves to be matched to the real-world object that they represent. For example, a cash sale object will typically remember a receipt number as its reference number so that it can be matched to the particular transaction it models. Objects representing cashiers may be required to remember a user name to match them to their human counterparts when they login, and so on.
The fact that class archetypes have a name, a list of typical attributes, and a list of typical operations means we can represent class archetypes graphically in the Unified Modeling Language (UML). We simply reuse the same notation as we do for the specific classes that belong to the class archetypes, as shown in Figure 3.
To fulfill their responsibilities
objects frequently need to
collaborate with objects of the same or other classes. Therefore, many
of the typical responsibilities in class archetypes imply typical
associations with other classes and typical ways of interacting with
objects of other classes. These typical associations and typical
interactions of their objects enable us to combine class archetypes
into archetypal, problem-domain object models. These model archetypes
or domain neutral components act as general repeating patterns for our
analysis and design models.

Figure 4:
The four class archetypes link together into the basic model archetype

Figure 5:
The basic model archetype expands for
each flavor of Party, Place and Thing into a larger Domain Neutral
Component
Using the Domain Neutral Component (DNC) can really help speed up the building of our problem domain object models. Start by identifying one or more Moment-Interval classes in the particular problem domain of interest. Then for each of these in turn, overlay the DNC. Step through each item in the DNC turn replacing it with items specific to this particular problem domain or dropping it if there is no equivalent in this problem domain or it is simply not needed in model.
The DNC can also be very useful in
reviewing existing models. First, color in the model by assigning
archetypes to each
class. Then challenge and justify deviations and omissions from the
DNC. However, remember that the DNC is a pattern not a meta-model. A
meta-model defines a rigid set of rules for creating compliant models.
The DNC does not do this. It is much looser, a set of suggestions and
hints. Justifiable deviations from the pattern are allowed, expected,
and essential in many cases.
When they first encounter it, many
people, are a little skeptical
about how applicable the DNC is in practice. I certainly was.
There are two reasons I think that the DNC is much more applicable than
maybe first expected. Firstly, most business systems are centered on a
particular business event or activity or a flow of events and
activities in the form of a business process. The Moment-Intervals
model these business events and activities. For each business event and
activity there are typically different people or organizations involved
in different ways. The events and activities usually take place at some
location even if, these days, that location is somewhere in cyberspace.
Frequently business events and activities are about buying, selling,
assigning, and moving things. The Roles and Party, Place, Things
model the who, where and with what of the
business events and activities. The Descriptions model different sets
or categories of the Party, Place, Things involved in the events and
activities. In addition, the emphasis on the Moment-Intervals first,
followed by Roles, role players , and Descriptions helps counter a
tendency to center things around and concentrate too much on role
players as one might in more traditional Entity-Relationship
Diagramming
(ERD).
The second reason why I think that the DNC is much more applicable than maybe first expected is a line of thinking triggered by a discussion with an old colleague of mine from TogetherSoft and Borland, Karl Frank. When you step back and think about it for a while, you realize that the DNC is in essence a natural expansion of a UML association between Party, Place and Thing classes. The Moment-Intervals are similar in many ways to the idea of an association class and the Roles are a similar idea applied to the role names found on the ends of the association.
Over the years, I have incorporated a number of minor changes to the DNC in comparison to that presented in the Java Modeling in Color with UML book. Read more about these changes...
Although class and model archetypes can obviously be effective without color, it is the color coding that gives the technique its name. The color coding has proved so beneficial in practice that it is well worth the little extra effort required to use it.
The color makes it easier to learn and remember the class archetypes. It also makes the class archetypes easier to identify in a non-trivial UML class or sequence diagram. When you are new to object modeling or not frequently involved in object modeling, it can be very off putting when first presented with a complex diagram. The color makes it easier to engage with the diagram. This helps people such as a project's customers and end users contribute better in the modeling process. For example, they can easily identify and initially focus on pink Moment-Interval classes representing the business interactions they are interested in and work outwards from there.
Much of the benefit derived from using object-modeling techniques is in the ability to communicate complex analysis and design more easily (something that seemed frequently forgotten and lost in the long, detailed object modeling phases of the late 1990's and the subsequent design of the UML 2.x specification). The careful use of color dramatically increases that ability for UML class and sequence diagrams to communicate.
For those interested in why the use of color works so well, Color Coding Class Archetypes has a further discussion on the use of color, including what colors to use for each class archetype.
For most, it is enough to learn and remember that the four class archetypes are usually assigned the following colours: