Ooad Unit 1 Notes
Ooad Unit 1 Notes
DIAGRAMS
Introduction to OOAD with OO Basics – Unified Process – UML diagrams – Use Case –Case study –
the Next Gen POS system, Inception -Use case Modelling – Relating Use cases – include, extend and
generalization – When to use Use-cases
OBJECTS
Knowing an object oriented language is a necessary but insufficient to create object systems.
Knowing how to “thing in objects” is critical.
The proverb “owing a hammer doesn’t make one an architect” is especially true with respect to object
technology.
Analysis: “build the right thing”
– Analysis focuses on user requirements (functional or non-functional)
Design: “build the thing right”
– Design focuses on how to provide the required functionality.
Object-Oriented Analysis
An investigation of the problem (rather than how a solution is defined) . During OO analysis, there is an
emphasis on finding and describing the objects (or concepts) in the problem domain
Analysis
Usually performed by a systems analyst.
– This is a person whose job it is to find out what an organization (or person) needs in terms of a
software system.
Analysis looks at the software as a black box of functionality.
– An analyst will never care about the internals of the system, merely how a user would interact
with it from the outside.
Design
Usually performed by an architect or designer
– An architect looks at overall system structure (at a high level)
For example, an architect on a distributed system might decide how the software
components will be distributed. An architect also looks at modularity, and non-functional
requirements (such as performance and scalability)
A designer looks at system structure (at lower levels)
A designer will look at the classes that make up a module, and how they will interact to
perform some function of the system
Design Patterns
Patterns are themes that recur in many types of software systems
– It is common for software systems (even those whose purpose is quite different) will share some
common challenges. Often, the solution for the problem in one context can also be used in
another context. Thus, the designs (and even implementations) can often be reused from other
software systems
Object-Oriented Design
Emphasizes a conceptual solution that fulfills the requirements.
Need to define software objects and how they collaborate to meet the requirements.
For example, in the Library Information System, a Book software object may have a title
attribute and a getChapter method. What are the methods needed to process the attributes?
Designs are implemented in a programming language. In the example, we will have a Book class
in Java.
From Design to Implementation
Analysis
Design Construction
investigation
logical solution code
of the problem
Of course, design (solution to requirements) ‘assumes’ a robust requirements analysis has taken place.
Use Cases are often used to capture stories of requirements and are often views as ‘constituting’ the
functional requirements, but NOT the software quality factors (non-functional requirements). Use Cases
are not specifically designed to be object-oriented, but rather are meant to capture how an application
will be used. Many methods for capturing requirements. We will concentrate on Use Cases.
Our Approach:
We need a Requirements Analysis approach with OOA/OOD need to be practiced in a framework of a
development process. We will adopt an agile approach (light weight, flexible) in the context of the
Unified Process, which can be used as a sample iterative development process. Within this process, the
principles can be discussed.
Also, have a general idea about use cases – what they are designed
to do and what they are not designed to do.
P
la
ne
v
is
ualiz
atio
nof
d
oma
inc
onc
ept ta
ilN
umb
er d
oma inconc
ept
publicclasPlan e
{
r
ep r
es entationina
n pr
iva teStr
ingta
ilN
umb
er
;
obje
c t-
orie
n te
d
pr
o gr
a m min glan
gua
ge pub
licL
is
tge
tF
lig
htH
is
to
ry
(){
...}
}
A Short Example
Dicey: In which a program simulates a player tossing two dice.
Define Use Cases
– these are user scenarios, stories, goals
Define a Domain Model
– this is a description of the domain from the point of view of the objects involved
– identify the concepts, attributes and associations
– result is called the domain model
Partial (Conceptual) Domain Model
P
lay
er D
ie
1 R
ols 2
n
ame fa
ceVa
lue
1 2
P
lay
s
1
D
ic
eGa
m e
1 In
clu
des
It is not description of the software, it is a visualization of the concepts or mental models of a real world
domain.
play()
rol()
fv1:=getFaceValue()
rol()
fv2:=getFaceValue()
Defining Classes
• The preceding is a dynamic view of collaborating classes.
• The following is a static view of collaborating classes; more often called a class diagram.
• Differs from the domain model, with similarities.
• Follows the sequence diagram in the order of things.
Partial design class diagram
D
ic
eGa
me D
ie
d
ie
1:D
ie 1 2f
a c
eVa
lu
e:in
t
d
ie
2:D
ie
get
F a
ceV
alu
e(
):in
t
p
la
y(
) r
ol()
Bridging the Gap
RealWorld
Entity-Relationship Relational
Model Data Model
RealWorld
Database
What is UML?
The Unified Modeling Language is a visual language for specifying, construction and
documenting the artifacts of systems. (OMG) . A lot more than we ever need to know including lots of
software for drawing pictures .
How to Apply UML?
As a sketch: informal, hand-drawn documents, used for exploration
As a blueprint: detailed design documents, developed by tools that either forward- or reverse engineer
code.
– forward: tool takes a picture and produces executable code (mostly stubs).
– reverse: tool takes executable code and draws a picture.
As a Programming Language: Tools produce complete executables.
As a Agile Programming: UML as a sketch.
S pecific
ationo r
Implem entatio
n
D
ic
eGa
m e D
ie
Pers pective
d
ie1:D
ie 2 fa
ceV
alu
e:in
t (d
esig
nc lassd iagra
m )
d
ie2:D
ie
getF
a c
eVa
lue
():in
t Raw U MLclassdiagram
p
lay
() ro
l() n
otationusedtovisualiz
e
s
oftw a
reelements.
Any complex system is best understood by making some kind of diagrams or pictures. These
diagrams have a better impact on our understanding. We prepare UML diagrams to understand a system
in better and simple way. A single diagram is not enough to cover all aspects of the system. So UML
defines various kinds of diagrams to cover most of the aspects of a system. We can also create our own
set of diagrams to meet our requirements. Diagrams are generally made in an incremental and iterative
way.
Categories of Diagrams
There are two broad categories of diagrams and then are again divided into sub-categories:
• Structural Diagrams
• Behavioral Diagrams
Structural Diagrams
The structural diagrams represent the static aspect of the system. These static aspects represent
those parts of a diagram which forms the main structure and therefore stable. These static parts are
represents by classes, interfaces, objects, components and nodes.
The four structural diagrams are:
• Class diagram
• Object diagram
• Component diagram
• Deployment diagram
Class Diagram
Class diagrams are the most common diagrams used in UML. Class diagram consists of classes,
interfaces, associations and collaboration. Class diagrams basically represent the object oriented view of
a system which is static in nature. Active class is used in a class diagram to represent the concurrency of
the system. Class diagram represents the object orientation of a system. So it is generally used for
development purpose. This is the most widely used diagram at the time of system construction.
Object Diagram
Object diagrams can be described as an instance of class diagram. So these diagrams are more
close to real life scenarios where we implement a system. Object diagrams are a set of objects and their
relationships just like class diagrams and also represent the static view of the system. The usage of
object diagrams is similar to class diagrams but they are used to build prototype of a system from
practical perspective.
Component diagrams
Component diagrams represent a set of components and their relationships. These components
consist of classes, interfaces or collaborations. So Component diagrams represent the implementation
view of a system. During design phase software artifacts (classes, interfaces etc) of a system are
arranged in different groups depending upon their relationship. Now these groups are known as
components. Finally, component diagrams are used to visualize the implementation.
Deployment Diagram
Deployment diagrams are a set of nodes and their relationships. These nodes are physical entities
where the components are deployed. Deployment diagrams are used for visualizing deployment view of
a system. This is generally used by the deployment team.
Behavioral Diagrams
Any system can have two aspects, static and dynamic. So a model is considered as complete
when both the aspects are covered fully. Behavioral diagrams basically capture the dynamic aspect of a
system. Dynamic aspect can be further described as the changing/moving parts of a system. UML has
the following five types of behavioral diagrams:
• Use case diagram
• Sequence diagram
• Collaboration diagram
• State chart diagram
• Activity diagram
Use case Diagram
Use case diagrams are a set of use cases, actors and their relationships. They represent the use
case view of a system. A use case represents a particular functionality of a system. So use case diagram
is used to describe the relationships among the functionalities and their internal/external controllers.
These controllers are known as actors.
Sequence Diagram
A sequence diagram is an interaction diagram. From the name it is clear that the diagram deals
with some sequences, which are the sequence of messages flowing from one object to another.
Interaction among the components of a system is very important from implementation and execution
perspective. Sequence diagram is used to visualize the sequence of calls in a system to perform a
specific functionality.
Collaboration Diagram
Collaboration diagram is another form of interaction diagram. It represents the structural
organization of a system and the messages sent/received. Structural organization consists of objects and
links. The purpose of collaboration diagram is similar to sequence diagram. But the specific purpose of
collaboration diagram is to visualize the organization of objects and their interaction.
State chart Diagram
Any real time system is expected to be reacted by some kind of internal/external events. These
events are responsible for state change of the system. State chart diagram is used to represent the event
driven state change of a system. It basically describes the state change of a class, interface etc.
Activity Diagram
Activity diagram describes the flow of control in a system. So it consists of activities and links.
The flow can be sequential, concurrent or branched. Activities are nothing but the functions of a system.
Numbers of activity diagrams are prepared to capture the entire flow in a system. Activity diagrams are
used to visualize the flow of controls in a system. This is prepared to have an idea of how the system
will work when executed.
Different phases of unified process.
Iterations
▪ Each phase has iterations. Each having the purpose of producing a demonstrable
piece of software. The duration of iteration may vary from two weeks or less up to six
months.
Resource Histogram
Unified Process best practices
• Get high risk and high value first
• Constant user feedback and engagement
• Early cohesive core architecture
• Test early, often, and realistically
• Apply use cases where needed
• Do some visual modeling with UML
• Manage requirements
• Manage change requests and configuration
Inception
Inception – Activities
Formulate the scope of the project. Needs of every stakeholder, scope, boundary
conditions and acceptance criteria established. Plan and prepare the business case.
Define risk mitigation strategy, develop an initial project plan and identify known cost, schedule,
and profitability trade-offs. Synthesize candidate architecture. Candidate architecture is
picked from various potential architectures Prepare the project environment.
Elaboration - Activities
Validate the architecture. Baseline the architecture. To provide a stable basis for the bulk of the
design and implementation effort in the construction phase.
Construction
The Construction phase is a manufacturing process. It emphasizes managing resources and
controlling operations to optimize costs, schedules and quality. This phase is broken into several
iterations.
Transition
The transition phase is the phase where the product is put in the hands of its end users. It
involves issues of marketing, packaging, installing, configuring, supporting the user-community,
making corrections, etc.
Transition – Activities
Test the product deliverable in a customer environment. Fine tune the product based upon
customer feedback Deliver the final product to the end user .Finalize end-user support material
Advantages of RUP
The RUP puts an emphasis on addressing very early high risks areas. It does not assume a
fixed set of firm requirements at the inception of the project, but allows to refine the requirements
as the project evolves. It does not put either a strong focus on documents The main focus remains
the software product itself, and its quality.
Drawbacks of RUP
RUP is not considered particularly “agile”. It fails to provide any clear implementation
guidelines. RUP leaves the tailoring to the user entirely.
Use-Case Model
Business Model
Domain Model
Objects, attributes, associations
VISION
SUPPLEMENTARY
Requirements SPECIFICATION
Interaction Diagrams
Design
Use case
• Main success scenario (or basic flow):
1. The Customer arrives at a POS checkout with items to purchase.
2. cashier starts new sale
3. Cashier enters item identifier
4. System records sale line item and presents item description, price and running total.
Cashier repeats step 3-4 until indicates done.
5. System presents total with taxes calculated.
6. Cashier tells customer the total, and asks for payment.
7. Customer pays and system handles payment.
8. System logs completed sale and send sale and payment info to the external accounting system
and inventory system.( to update inventory)
9. System presents receipt.
10. Customer leaves with receipt and goods.
• Extensions (or alternative flows):
➢ If invalid identifier entered. Indicate error.
➢ If customer didn’t have enough cash, cancel sales transaction.
➢ Customer paying by debit card … invalid pin
➢ Printer out of paper.
• Special requirements: Touch screen UI, …
• Technology and Data Variations List:
➢ Identifier entered by bar code scanner,…
• Open issues: What are the tax law variations?...
Things that are in Use Cases
• Create a written document for each Use Case
– Clearly define intent of the Use Case
– Define Main Success Scenario (Happy Path)
– Define any alternate action paths
– Use format of Stimulus: Response
– Each specification must be testable
– Write from actor’s perspective, in actor’s vocabulary
• Each use case should have a name that indicates what value (or goal) is achieved by the actor's
interaction with the system
• Here are some good questions to help you adhere to this rule:
– Why would the actor initiate this interaction with the system?
What goal does the actor have in mind when undertaking these actions?
What value is achieved and for which actor?
CRUD
• Examples of bad use case names with the acronym CRUD. (All are procedural and reveal nothing
about the actor’s intentions.)
• C - actor Creates data
• R - actor Retrieves data
• U - actor Updates data
• D - actor Deletes data
Identify Actors
• We cannot understand a system until we know who will use it
– Direct users
– Users responsible to operate and maintain it
– External systems used by the system
– External systems that interact with the system
Types of Actors
• Primary Actor
– Has goals to be fulfilled by system
• Supporting Actor
– Provides service to the system
• Offstage Actor
– Interested in the behavior, but no contribution
• In diagrams, Primary actors go on the left and others on the right.
Define Actors
• Actors should not be analyzed or described in detail unless the application domain demands it.
• Template for definition:
– Name
– Definition
• Example for an ATM application:
Customer: Owner of an account who manages account by depositing and withdrawing funds
Working with Use Cases
• Determine the actors that will interact with the system
• Examine the actors and document their needs
• For each separate need, create a use case
• During Analysis, extend use cases with interaction diagrams
Preconditions
• Anything that must always be true before beginning a scenario is a precondition.
• Preconditions are assumed to be true, not tested within the Use Case itself.
• Ignore obvious preconditions such as the power being turned on. Only document items necessary
to understand the Use Case.
Success Guarantees
• Success Guarantees (or Post conditions) state what must be true if the Use Case is completed
successfully.
• This may include the main success scenario and some alternative paths. For example, if the happy
path is a cash sale, a credit sale might also be regarded a success.
• Stakeholders should agree on the guarantee.
Scenarios
• The Main Success Scenario, or “happy path” is the expected primary use of the system, without
problems or exceptions.
Alternative Scenarios or Extensions are used to document other common paths through the system
and error handling or exceptions
Documenting Extensions
• Use same format as Happy Path
• Document actions that vary from ideal path
• Include error conditions
• Number each alternate, and start with the condition:
3A. Condition: If [actor] performs [action] the system …
• If subsequent steps are the same as the happy path, identify and label as (same)
• Steps not included in alternate course are assumed not to be performed.
Special Requirements
If a non-functional requirement , quality attribute, or constraint affects a use case directly, describe
it as a special requirement
Technology and Data Variations List
• Often there are technical differences in how things are done even though what is done is the same.
These things can be described in the Technology and Data Variations List.
• For example, if a card reader cannot read the magnetic stripe on a credit card, the cashier might be
able to enter it on the keyboard.
Technology
• The distinction between an essential (black box) use case that leaves out technology and a real
(white box) use case that includes technology is fundamental.
• For example, in an Automated Teller Machine, an essential use case can mention identification or
validation, but only a real use case can mention a key pad or card reader.
Post conditions
• Post conditions (or success guarantees) state what always must be true for a use case to succeed.
Avoid the obvious, but clearly document any that are not obvious. This is one of the most
important parts of a use case.
Conditions and Branching
Stick to the “Happy Path,” “Sunny Day Scenario,” Typical Flow, or Basic Flow (all names for the
same basic idea) in the main section and defer all conditional sections and branching to the
extensions or alternate flows
• A use case diagram identifies transactions between actors and a system as individual use cases
Actor
• An actor is an idealized user of a system
Non-human Actor
Inventory system
Non human actors are usually not primary users, and thus are usually shown on the right, not the left
Use Case
• A use case is a coherent unit of externally visible functionality provided by a system and expressed by a
sequence of messages
• Additional behavior can be shown with parent-child, extend and include use cases
• An association is the communication path between an actor and the use case that it participates in
• It does not have an arrow, and is normally read from left to right
• Here, the association is between a Modeler and the Create Model use case
• Association
• Extend
• Generalization
• Uses
• Include
Extend Relationship
• Extend puts additional behavior in a use case that does not know about it.
• Generalization is a relationship between a general use case and a more specific use case that inherits and
extends features to it
• It is shown as a solid line with a closed arrow point
• Here, the payment process is modified for cash and charge cards
Uses Relationship
• When a use case uses another process, the relationship can be shown with the uses relationship
• This is shown as a solid line with a closed arrow point and the <<uses>> keyword
• Here different system processes can use the logon use case
Include Relationship