R2017 OOAD Unit-2
R2017 OOAD Unit-2
DEPARTMENT OF CSE
CS8592 - OBJECT ORIENTED ANALYSIS AND DESIGN
CLASS DIAGRAM
Introduction
The UML includes class diagrams to illustrate classes, interfaces, and their
associations. They are used for static object modeling.
Used for static object modeling . It is used to depict the classes within a
model.
It describes responsibilities of the system , it is used in forward and reverse
engineering
Keywords used along with class name are { abstract , interface, actor}
The class diagram can be used to visualize a domain model. we also need a unique
term to clarify when the class diagram is used in a software or design perspective. A
common modeling term for this purpose is design class diagram (DCD).
UML class diagrams in two perspectives
Domain Model
1 Attributes
2 Operations & Methods
3 Relationship between classes
Syntax:
Examples:
-classOrStaticAttribute:int
+ publicAttribute : string
- privateAttribute
assumedPrivateAttribute
isIntializedAttribute : Bool = true
aCollection:VeggieBurger [*]
attributeMayLegallyBeNull : String[0..1]
finalConstantattribute : int = 5 { readonly}
/derivedAttribute
Guideline: Use the attribute text notation for data type objects and the association line
notation for others.
Operations : One of the compartments of the UML class box shows the signatures
of operations . Assume the version that includes a return type. Operations are
usually assumed public if no visibility is shown. both expressions are possible
A. Association
B. Generalization & specialization
C. Composition and aggregation
D. Dependency
E. Interface realization
Example
For example, a single instance of a class can be associated with "many" (zero
or more, indicated by the *) Item instances.
In the above example person is the generalized class and specialized classes are
student and professor
Ex2:
In the above example payment is the generalized class and specialized classes are
cash payment , credit payment and check payment .
1) an instance of the part (such as a Square) belongs to only one composite instance
(such as one Board) at a time,
2) the part must always belong to a composite (no free-floating Fingers)
3) the composite is responsible for the creation and deletion of its parts either by
itself creating/deleting the parts, or by collaborating with other objects.
D) Dependency
A general dependency relationship indicates that a client element (of any kind,
including classes, packages, use cases, and so on) has knowledge of another
supplier element and that a change in the supplier could affect the client.
E) Interface realization
In the above example , Clock is the server program implementing Timer interface
giving Timer as the provided interface, window is the client program with Timer
Qualified Association
A qualified association has a qualifier that is used to select an object (or objects) from a
larger set of related objects, based upon the qualifier key
Association Class
An association class allows you treat an association itself as a class, and model it
with attributes, operations, and other features. For example, if a Company employs
many Persons, modeled with an Employs association, you can model the association
itself as the Employment class, with attributes such as startDate.
ELABORATION
Elaboration is the initial series of iterations during which, on a normal project:
These criteria are used to rank work across iterations. Use cases or use case
scenarios are ranked for implementation early iterations implement high ranking
scenarios. The ranking is done before iteration-1, but then again before iteration-2,
and so forth, as new requirements and new insights influence the order.
For example:
Rank Requirement (Use Case or Feature) Comment
High Process Sale Scores high on all rankings.
Logging Pervasive. Hard to add late.
… …
Medium Maintain Users Affects security sub domain.
… …
Low … …
DOMAIN MODEL
Domain Models
The figure shows a partial domain model drawn with UML class diagram
notation. It illustrates that the conceptual classes of Payment and Sale are significant
in this domain, that a Payment is related to a Sale in a way that is meaningful to
note, and that a Sale has a date and time, information attributes we care about.
Applying the UML class diagram notation for a domain model yields a
conceptual perspective model. Identifying a rich set of conceptual classes is at the
heart of OO analysis.
Definition
In the UP, the term "Domain Model" means a representation of real-situation
conceptual classes, not of software objects. The term does not mean a set of
diagrams describing software classes, the domain layer of a software architecture, or
software objects with responsibilities.
A domain model shows real –situation conceptual classes, not software classes
.
Meaning 2 :"the domain layer of software objects." That is, the layer of software
objects below the presentation or UI layer that is composed of domain objects
software objects that represent things in the problem domain space with related
"business logic" or "domain logic" methods.
FlightDescription
Guideline: Descriptions are often in a catalog. ProductCatalog
FlightCatalog
containers of things (physical or information) Store, Bin Board Airplane
AirTrafficControl
records of finance, work, contracts, legal matters Receipt, Ledger
MaintenanceLog
financial instruments Cash, Check, LineOfCredit
TicketCredit
schedules, manuals, documents that are regularly DailyPriceChangeList
referred to in order to perform work
RepairSchedule
Guideline
Linguistic analysis has become more sophisticated; it also goes by the name natural
language modeling. for example, The current scenario of the Process Sale use case
can be used.
Underlined words are nouns. The next level of scrutiny derives class names.
From the category list and noun phrase analysis, a list is generated of
candidate conceptual classes for the domain. There is no such thing as a "correct"
list. It is a somewhat arbitrary collection of abstractions and domain vocabulary
Guidelines
1. Agile Modeling Sketching a Class Diagram : The sketching style in the UML
class diagram is to keep the bottom and right sides of the class boxes open. This
makes it easier to grow the classes as we discover new elements.
3. Report Objects - Include 'Receipt' in the Model? Receipt is a term in the POS
domain. But it's only a report of a sale and payment, and thus duplicate
information.
5. How to Model the Unreal World? Some software systems are for domains that
find very little analogy in natural or business domains; software for
In the real world, a store is not considered a number or text the term suggests
a legal entity, an organization, and something that occupies space. Therefore, Store
should be a conceptual class.
Motivation: Why Use 'Description' Classes? The need for description classes is
common in many domain models. The need for description classes is common in
sales, product, and service domains. It is also common in manufacturing, which
requires a description of a manufactured thing that is distinct from the thing itself
Figure. Descriptions about other things. The * means a multiplicity of "many." It
indicates that one Product Description may describe many (*) Items.
If the only record of what airport a flight goes to is in the Flight software
instances, which represent specific flights for a particular date and time, then there
is no longer a record of what flight routes the airline has The problem can be solved,
both from a purely conceptual perspective in a domain model and from a software
perspective in the software designs, with a FlightDescription that describes a flight
and its route, even when a particular flight is not scheduled in following figure
Note that the prior example is about a service (a flight) rather than a good.
Descriptions of services or service plans are commonly needed.
For example,
Multiplicity values.
Multiple associations.
Category Examples
A is a transaction related to another CashPaymentSale CancellationReservation
transaction B
A is a line item of a transaction B SalesLineItemSale
SeatAirplane
A is physically or logically contained in/on B RegisterStore, ItemShelf
SquareBoard PassengerAirplane
A is a description for B ProductDescriptionItem FlightDescriptionFlight
PilotAirline
A is an organizational subunit of B DepartmentStore MaintenanceAirline
A uses or manages or owns B CashierRegister PlayerPiece PilotAirplane
A is next to B SalesLineItemSalesLineItem
SquareSquare CityCity
Case Study: NextGen POS : The domain model in Figure shows a set of
conceptual classes and associations that are candidates for our POS domain model.
The associations are primarily derived from the "need-to-remember" criteria of
these iteration requirements, and the Common Association List. For example:
More Notation
Most attribute types should be what are often thought of as "primitive" data
types, such as numbers and Booleans. For example, the current Register attribute in
the Cashier class in Figure is undesirable because its type is meant to be a Register,
which is not a simple data type (such as Number or String).
Guideline : The attributes in a domain model should preferably be data types. Very
common data types include: Boolean, Date (or DateTime), Number, Character,
String (Text), Time. Other common types include: Address, Color, Geometrics
(Point, Rectangle), Phone Number, Social Security Number, Universal Product
Code (UPC), SKU, ZIP or postal codes, enumerated types
Data Types
Represent what may initially be considered a number or string as a new data type
class in the domain model if:
Applying these guidelines to the POS domain model attributes yields the following
analysis:
Should the ItemID class be shown as a separate class in a domain model?. Since
ItemID is a data type (unique identity of instances is not used for equality testing), it
may be shown only in the attribute compartment of the class box, as shown in above
Figure. On the other hand, if ItemID is a new type with its own attributes and
associations, showing it as a conceptual class in its own box may be informative.
Modeling quantities.
See following Fig. The attributes chosen reflect the information requirements for
this iteration the Process Sale cash-only scenarios of this iteration. For example:
price To calculate the sales total, and show the line item price.
Sale dateTime A receipt normally shows date and time of sale, and this is
useful for sales analysis.
SalesLineItem quantity To record the quantity entered, when there is more than one
item in a line item sale (for example, five packages of tofu).
Store address, name The receipt requires the name and address of the store.
Concepts Category List : This Table shows some concepts being considered in
this iteration.
Category Examples
physical or tangible objects CreditCard, Check
Transactions CashPayment, CreditPayment,
CheckPayment
other computer or electro-mechanical CreditAuthorizationService,
systems external to our system CheckAuthorizationService
abstract noun concepts
Organizations CreditAuthorizationService,
CheckAuthorizationService
records of finance, work, contracts, legal AccountsReceivable
matters
Generalization
The concepts CashPayment, CreditPayment, and CheckPayment are all very
similar. In this situation, it is possible (and useful) to organize them (as in following
Figure) into a generalization-specialization class hierarchy (or simply class
hierarchy) in which the super class Payment represents a more general concept,
and the subclasses more specialized ones.
Subclass conformance.
Based on the above criteria, it is not compelling to partition Customer into the
subclasses MaleCustomer and FemaleCustomer because they have no additional
attributes or associations, are not operated on (treated) differently, and do not
behave differently in ways that are of interest . This table shows some examples of
class partitions from the domain of payments and other areas, using these criteria
Guideline : Identify abstract classes and illustrate them with an italicized name in
the Domain Model, or use the {abstract} keyword.
The following domain requirements set the stage for association classes:
Placing merchantID in Store is incorrect because a Store can have more than one
value for merchantID. The same is true with placing it in AuthorizationService (see
Figure).
For example:
A Person may have many phone numbers. Place phone number in another
class, such as PhoneNumber or ContactInformation, and associate many of
these to Person.
This leads to the notion of an association class, in which we can add features
to the association itself. ServiceContract may be modeled as an association class
related to the association between Store and AuthorizationService.
An association class
For example, when a cashier enters an item's ID, the cashier is requesting
the POS system to record that item's sale (the enterItem event). That event initiates
an operation upon the system. The use case text implies the enterItem event, and the
SSD makes it concrete and explicit.
Guideline : Draw an SSD for a main success scenario of each use case, and
frequent or complex alternative scenarios.
Therefore, it is useful to know what, precisely, are the external input events
the system events. They are an important part of analyzing system behavior.
SSDs are derived from use cases; they show one scenario.
Thus "enterItem" is better than "scan" (that is, laser scan) because it captures
the intent of the operation while remaining abstract and noncommittal with respect
to design choices about what interface is used to capture the system event.
The Play Monopoly Game use case is simple, as is the main scenario. The
observing person initializes with the number of players, and then requests the
simulation of play, watching a trace of the output until there is a winner.
Process:
Draw SSDs only for the scenarios chosen for the next iteration. Don't create
SSDs for all scenarios, unless you are using an estimation technique that requires
identification of all system operations.
Class diagram is also considered as the foundation for component and deployment
diagrams. Class diagrams are not only used to visualize the static view of the system
Class diagram clearly shows the mapping with object-oriented languages such as
Java, C++, etc. From practical experience, class diagram is generally used for
construction purpose.