UNIT II STATIC UML DIAGRAMS KONGUNADU COLLEGE OF ENGINEERING AND TECHNOLOGY (AUTONOMOUS)
UNIT II STATIC UML DIAGRAMS Class Diagram - Elaboration - Planning the Next iteration. Domain Model - Finding Conceptual and Description Classes - Associations - Attributes - Domain model refinement - Finding conceptual class Hierarchies - Aggregation and Composition. System Sequence Diagrams - Relationship between SSDs and Use Cases - System Events and Operations.
Class Diagrams Class diagrams represents the static view of an application Class diagram is not only used for visualizing, describing, and documenting different aspects of a system It is also for constructing executable code of the software application
How to draw a class diagram The name of the class diagram should be meaningful to describe the aspect of the system . Class should be clearly identified Each class, minimum number of properties should be specified At the end of the drawing it should be understandable to the developer
Conceptual We take the concepts in the domain under study and represent in diagrams These concepts will relate to the classes that implement them A conceptual model should be drawn with little implementation. Also it is considered language independent.
Specification Here we look at the interface of the software but not its implementation. A type can have many classes that implement it and a classes that implement it an a class implement many types.
Implementation Here we have classes and we later to implement. This is the most often used perspective but in many cases the specification perspective is better than implementation.
Elaboration Build the core architecture, Resolve the high-risk elements, Define most requirements, Estimate the overall schedule and resources.
Elaboration Elaboration is the initial series of iterations during which, on a normal project. 1.The core, risky software architecture is programmed and tested 2.The majority of requirements are discovered and stabilized 3.The major risks are mitigated
Elaboration often consists of two or more iterations; – Each iteration is recommended to be 2-6 weeks Elaboration is not a design phase the models are fully developed in preparation for implementation The code and design are production quality (a production subset of the final system).
Start programming early Adaptively design, implement, and test the core and risky parts of the architecture Realistic tests early Adapt according to the feedback of users Key Ideas of Elaboration
Domain model The most important and classic model in OO analysis. A visual representation of conceptual classes or real situation objects in a domain. Domain modeling is a technique used to understand the project problem description and to translate the requirements of that project into software components of a solution . The software components are commonly implemented in an object oriented programming language
Contd … The domain model illustrates conceptual classes or vocabulary in the domain. Informally: a conceptual class is an idea, thing, or object. Formally: a conceptual class may be considered in terms of its symbol, intension, and extension. Symbol- words or images representing a conceptual class Intension- the definition of a conceptual class Extension - the set of examples to which the conceptual class applies
Domain model should probably avoid : Software artifacts like window or database Methods and responsibilities
A domain model is illustrated with a set of class diagrams(in which no operations are defined) It may show: Domain objects or conceptual classes Associations between conceptual classes Attributes of conceptual classes
Find the conceptual classes Draw them as classes in UML class diagrams Add association and attributes Creation of domain model
The three strategies to find conceptual classes 1)Reuse or modify existing models Inventory Finance Health 2) Use a category list (business category) – Eg . POS 3) Identity noun phrases - Textual description of a domain FINDING CONCEPTUAL CLASSES
Use a category list (business category)
Example : Process Sale Main success scenario (or Basic Flow) 1) Customer arrives at a POS checkout with goods 2) Cashier starts a new sale 3) Cashier enters item identifier 4) System records SaleLineItem Presents item description, price and running total Price calculated from a set price rules. 5) System presents total with taxes and asks for payment 6) Cashier tells customer the total and asks for payment 7) Customer pays and system handles payment FINDING CONCEPTUAL CLASSES
A description class is a class that contains information that describes something Example : Product Description is a description class that records Picture Price Text description Finding Description Classes
Find the conceptual classes Draw them as classes in UML class diagrams Add association and attributes Creation of domain model
An association is defined as “ Semantic relationship between two or more classifiers that involve connections among their instances ”. It is a relationship between two objects Association
Relationships: 3 Kinds Window open() close() ConsoleWindow DialogBox Control Event association dependency generalization
31 Associations may include have the following: Association name Role names Multiplicity Navigability Association name navigability multiplicity role name navigability multiplicity * *
UML has a notation for multiplicity: 1 one and only one 0 .. 1 zero or one M .. N from M to N * zero or more 1..* one or more
Associations Professor Course teaches relationship name direction indicator: how to read relation name teacher class role names Multiplicity defines the number of objects associated with an instance of the association. Default of 1; Zero or more (*); n..m; range from n to m inclusive 1..* * Represent conceptual relationships between classes
At this level of class design this is know as an association and these come in three types − A one to one association where one object of a class has a link to one other object of a class − A one to many association, where one object of a class has links with many objects of a particular class − A many to many association, where many objects of one class have links with many objects of a particular class. Associations more frequently occur between objects of different classes, but also occur between different objects of the same class
Association Relationships If two classes in a model need to communicate with each other, there must be link between them. An association denotes that link. Instructor Student
Association Relationships (Cont’d) We can indicate the multiplicity of an association by adding multiplicity adornments to the line denoting the association. The example indicates that a Student has one or more Instructors : Instructor Student 1..*
Association Relationships (Cont’d) The example indicates that every Instructor has one or more Students : Instructor Student 1..*
Association Relationships (Cont’d) We can also indicate the behavior of an object in an association ( i.e., the role of an object) using rolenames . Instructor Student 1..* 1..* learns from teaches
Class Attribute Object Attribute Value What is an Attribute? CourseOffering number startTime endTime :CourseOffering number = 101 startTime = 900 endTime = 1100 :CourseOffering number = 104 startTime = 1300 endTime = 1500
The different types of attributes Single valued attributes Multi valued attributes Compound /Composite attributes Simple / Atomic attributes Stored attributes Derived attributes Complex attributes Key attributes Non key attributes Required attributes Optional/ null value attributes
Difference between Attribute and Association From conceptual perspective, there is no difference between attribute and association. Example: dateReceived [0….1]: Date The difference occurs at the specification and implementation levels.
Class Operation What is an Operation? CourseOffering addStudent deleteStudent getStartTime getEndTime The processes carried out but a class are called operations .
The full notation… Student + name: string [1] = “Ram” { readOnly } + registeredIn : Course [*] + register (c: Course) + isRegistered (c: Course) : Boolean Name of the class Visibility: +, -, # Attribute name Operation name Parameters Return value Attribute type Multiplicity Default value Other Properties
Derived attributes Attributes is derived from some other information A derived attribute is an attribute whose value is calculated ( derived ) from other attributes . The derived attribute need not be physically stored within the database; instead, it can be derived by using an algorithm.
Example:
Data type attribute in domain model: Number Booleans Characters Date String
Case Study : Monopoly game
DOMAIN MODEL REFINEMENT In the domain model refinement the fundamental concepts are ( i ) Generalization (ii) Specialization and (iii) Conceptual class hierarchies
Finding conceptual class hierarchies Generalization has to be understand to identify conceptual super and subclass A conceptual super class is more general or hold within the subclass
Venn Diagram of set relationships
Aggregation and composition Aggregation is a form of association. A hollow diamond is attached to the end of the path to indicate aggregation Composition is denoted as solid diamond at the end of the path. Composition is also called as part whole relationship
Benefits of composition Composition is very useful in design than analysis. It assists in identification of creator using GRASP. Operations like copy, delete apply to parts.
Relationship between sequence diagrams and use case System Sequence Diagram (SSD) shows systems events for one scenario of a use case. The SSD is generated from inspection of a use case. SSDs are derived from use cases. While naming the system events, use the abstract level of representation rather than physical input device.
Relationship between sequence diagrams and use case
Relationship between sequence diagrams and use case Always start the system event with a verb like • add • enter • end • make
SSDs are highly useful • To understand the interface • Collaborations of existing systems • To document the architecture. Their purpose is to 1) Identify details of system events 2)Clarify major operations the system is designed to handle 3) Write system operation contracts
WHEN TO USE CLASS DIAGRAMS A class diagram describes the types of objects in the system and the various kinds of static relationship that exist among them. The class diagrams show the attributes and operations of a class and the constraints that apply to the way objects are connected.
Perspectives There are three different perspectives; we use in drawing class diagrams. They are • Conceptual • Specification • Implementation
Perspectives There are three different perspectives; we use in drawing class diagrams. They are • Conceptual • Specification • Implementation