Anda di halaman 1dari 2

• Introduction

• Conceptual Analysis v Design


• Notation
• Adding Methods
• Type information
• Associations
! • Example

Reading: chapter 16, Applying UML and Patterns (3/e), Craig Larman

260CT_lect10 @Dr Hong Guo & Coventry University 1 260CT_lect10 @Dr Hong Guo & Coventry University 2

• Class diagrams contain software definitions


In contrast with the conceptual domain model, a design
class diagram shows definitions for software entities • Classes can be identified from the domain model, Use Cases
(fully dressed), and/or interaction diagrams
rather than real world concepts.
– Including the methods

Also referred to in UML simply as a class diagram • Some concepts will not be present in the design
– Actors, may be included in later cycles
The Notation is basically the same as for the
Domain (Conceptual) Model. Design Class Diagrams are usually created in parallel with
interaction diagrams (e.g. Sequence Diagrams,
Collaboration Diagrams)
260CT_lect10 @Dr Hong Guo & Coventry University 3 260CT_lect10 @Dr Hong Guo & Coventry University 4

ClassName
attribute
Analyze use cases (fully dressed) and/or interaction diagrams for attribute: type
classes ATTRIBUTE : type = initial value
• Draw them in a class diagram /derivedAttribute
Duplicate the attributes from the associated concepts in the domain - privateAttribute
model. + publicAttribute
# protectedAttribute
• Attributes are usually assumed private if no visibility is given class attribute
Add method names by cross-referencing to interaction diagrams method1()
Add type information to attributes & methods method2(parameter list ) : return type
abstractMethod()
Add directional associations between classes to support attribute + publicMethod()
visibility - privateMethod()
Add dependency relationship lines # protectedMethod()
class method()
260CT_lect10 @Dr Hong Guo & Coventry University 5 260CT_lect10 @Dr Hong Guo & Coventry University 6

1
The methods of each class are identified from the use cases or If using a CASE tool with code generation
from the collaboration diagrams
• All type details are required but not necessarily
• Can be automatically generated by CASE tool shown
Some methods can be omitted
• Create methods, e.g. constructor methods in Java or C++
• Attribute accessor & mutator functions For Software Developers
Methods on multiobjects (i.e. a collection class) • Exhaustive detail may affect noise-to-value ratio
• Interpret as a message to the container
• Containers add noise with little new information … so
usually excluded

260CT_lect10 @Dr Hong Guo & Coventry University 7 260CT_lect10 @Dr Hong Guo & Coventry University 8

Using the navigability


Associations on a Design Class Diagram are derived from the • Design Model … software perspective arrow to indicate
Domain Model and/or collaboration diagrams − show navigation arrow & role name Student has a reference
− often exclude the association name to one Project instance
Use arrowheads to indicate navigability
Navigability indicates attribute visibility from a source to a target object
class Student Project
1
id : int code : String
Rolename only at the target end implies the attribute name in myProject
implementation … …
Example:
• Domain Model … conceptual perspective • To be clear, the Student has two public class Student {
− show association name & multiplicity but avoid navigation arrow & attributes: private int id;
role name Student private Project myProject;
public void setProject(Project p) {
Student Project id : int
1 Allocated-to 1 myProject = p;
code : String myProject : Project }
id : int
… …
}
260CT_lect10 @Dr Hong Guo & Coventry University 9 260CT_lect10 @Dr Hong Guo & Coventry University 10

Room Student
• A dependency relationship indicates
- number : String - id : int
that one element has knowledge of - myProject : Project
another element. + getNumber() : String public class Student {
private int id; …
• In class diagrams this means 1 venue + setProject(Project p)
private Project myProject;
− Parameter visibility + notePresentation(Presentation p)
public void setProject(Project p) {
− Global visibility Presentation myProject = p;
− Locally declared visibility - time : DateTime }
Example: the Student has parameter - venue : Room public void notePresentation( Presentation p) {
visibility to Presentation, the method … Room r = p.getRoom() ; //r is a local variable
noteP… invokes getNumber on a Room System.out.println(“Room: ” + r.getNumber() );
1 speaker
System.out.println(“Time: ” + p.getTime() );
Student
Project }
- id : int 1 … Objects communicate
… - code : String }
via sending messages…
+ notePresentation(Presentation) myProject …
260CT_lect10 @Dr Hong Guo & Coventry University 11 260CT_lect10 @Dr Hong Guo & Coventry University 12

Anda mungkin juga menyukai