Where Are The Objects?Source: comp.objectDate: 04-Apr-98
Problem: How do you find the objects for an object oriented design? Start with a domain model (the objects from the problem domain) and elaborate it? Start with a static model (class diagrams) and then use it to implement use cases? Start with a dynamic model (collaboration/interaction diagrams) and then find classes that support it?
Robert C. Martin wrote: Neither class diagrams nor collaboration diagrams take precedence. It does not matter which ones you start with. The important thing is that you should avoid doing too much of one kind, without balancing them with the other kind. Class diagrams cannot stand alone. Neither can collaboration diagrams. They reinforce each other, and need to be developed concurrently with each other. Failure to develop these diagrams concurrently will result in dynamic models that cannot be supported statically, or static models that cannot be implemented dynamically. Moreover, you will be heavily vested in the models that you have created, and will find it difficult to change them.
[About starting by creating a domain model, and elaborating it to a
design:] Designs based strictly upon the domain model will probably wind up being too concrete; and too tied to the details of the domain. When we design we try to find the overreaching abstractions that make such details irrelevant. In so doing, we create a design that is valid for the class of domains, of which our domain model is just a single instance.
[And in another post:]
Patrick Logan provided an example of how basing a design on the domain model may break code: For example, many years ago I joined a company that produced software for designing electronics. At the time I joined the industry was moving from gate level design (ANDs and ORs) to hardware description languages that allow abstract data types. All of the existing software was designed specifically for representing digital bits, i.e. 1s and 0s. Even though many of the software modules could have been applied to abstract values, they could not because they were too domain dependent. This may be an extreme example. Many years earlier, it would have been difficult to anticipate the need for abstraction, not to mention justify the cost of building it into the system. But it serves to illustrate what happens over and over again in all domains: details change, even details that appear to be "central" to the domain. More Info: Robert C. Martin wrote a series of articles about this subject in the C++ Report:
(This article presents CRC cards, which are a good technique for finding objects: "Design with the cards tends to progress from knowns to unknowns, as opposed to top-down or bottom up.")
|