指导原则:责任驱动
Responsibility-Driven Design
l The most widely adopted approach to OO analysis.
– Based on “client / server” relationships.
There are 2 common interpretations of “client / server”:
l Used in distributed architectures where the server provides access to shared
resources (such as a database) and the clients provide the user interface.
l Used in the object-oriented vernacular where the server is an object that
provides services; this is the meaning we are using here.
Clients collaborate with servers.
– An object may be a client in one collaboration, and a server in another.
Servers are responsible for providing certain services.
l In general, an object is responsible for behaving in a certain, well-defined way.
设计流程:
Overview of the Design Process
l Look at a domain and identify the objects and classes
– Objects are often the first to be identified <<<识别对象
– Classes are found by grouping objects
l Identify the relationships between the objects and
between the classes
– Structural relationships
– Collaborative relationships
l Assign responsibilities
– Based on collaborative relationships
l Iterate, iterate, iterate, iterate, iterate, iterate, iterate, iterate, iterate,
l Begin by modeling the domain, not the solution!