PROJECT REPORT ON “TEAM ROLE”

Download Report

Transcript PROJECT REPORT ON “TEAM ROLE”

SOFTWARE DESIGN
RAJIKA TANDON
CIS 453 - Software Specification & Design
Instructor: Dr. E. Sibert
DESIGN
The design of a system is essentially a blueprint or a plan for a solution for the
system.

Here we consider a system to be a set of modules with clearly defined behavior
which interact with each other in a defined manner to produce some behavior or
services for its environment.

 The design process for software systems often has two levels. At the first level the
focus is on deciding which modules are needed for the system, the specifications of
these modules, and how the modules should be interconnected.
This is what may be called the module design or the high-level design.
 In the second level, the internal design of the modules, or how the specifications of
the module can be satisfied, is decided. This design level is often called detailed
design or logic design.
Detailed design essentially expands the system design to contain a more detailed
description of the processing logic and data structures so that the design is sufficiently
complete for coding.
Object model?

An object model defines the structural relationships and
dynamic interaction between a group of related objects.

An object diagram represents a specific collection of objects,
with specific attribute values and relationships.

Therefore it looks like a snapshot of an O-O system at some instant
in time.
Outline







Object modeling
Class vs instance diagrams
Attributes
Operations and methods
Links and associations
Examples of associations
Two special associations
 Aggregation
 Inheritance
Definition: Object Modeling



Main goal: Find the important abstractions
Steps during object modeling
 1. Class identification
 Based on the fundamental assumption that we can find
abstractions
 2. Find the attributes
 3. Find the methods
 4. Find the associations between classes
Order of steps
 Goal: get the desired abstractions
 Order of steps secondary, only a heuristic
 Iteration is important
What happens if we find the wrong abstractions?
 Iterate and correct the model
Class Identification




Identify the boundaries of the system
Identify the important entities in the system
Class identification is crucial to object-oriented modeling
Basic assumption:
 1. We can find the classes for a new software system
(Forward Engineering)
 2. We can identify the classes in an existing system
(Reverse Engineering)
Pieces of an Object Model




Classes
Associations (Relations)
 Part of- Hierarchy (Aggregation)
 Kind of-Hierarchy (Generalization)
Attributes
 Detection of attributes
 Application specific
 Attributes in one system can be classes in another system
 Turning attributes to classes
Methods
 Detection of methods
 Generic methods: General world knowledge, design patterns
 Domain Methods: Dynamic model, Functional model
Object vs Class



Object (instance): Exactly one thing
A class describes a group of objects with similar properties
Object diagram: A graphic notation for modeling objects, classes
and their relationships ("associations"):
 Class diagram: Template for describing many instances of
data. A class diagram describes object classes.
Object class: group of objects with similar properties (attributes),
common behavior(operations), common relationships to other
objects)
Useful for taxonomies, patters, schemata...

Instance diagram: A particular set of objects relating to each other.
Useful for discussing scenarios, test cases and examples
Class and Instance Diagrams
Inspector
joe:
Inspector
mary:
Inspector
Class Diagram
anonymous:
Inspector
Instance Diagram
Common uses of object diagrams are:
1.
to illustrate the system state at a high level of abstraction,
before and after some action (e.g. instruction execution)
i.e. dynamic modeling !!
2.
to analyze the structure of recursive data types (classes) by
unfolding a class diagram.
Attributes – A data value held by the objects in
a class.
Inspector
name:string
age: integer
joe:Inspector
name = “Joe”
age = 24
mary: Inspector
name = “Mary”
age = 18
Operation, Signature or Method? What when?
( Feature –A generic word for either attribute /operation)



Operation: A function or
transformation applied to objects in
a class. All objects in a class share
the same operations (Analysis
Phase)
Signature: Number & types of
arguments, type of result value. All
methods of a class have the same
signature (Object Design Phase)
Method: Implementation of an
operation for a class
(Implementation Phase)
Polymorphic operation: The same
operation applies to many different
classes.
Workorder
File_name: String
Size_in_bytes: integer
Last_update: date
Stickies: array[max]
print()
delete()
open()
close()
write()
read()
Links and Associations

Links and associations establish relationships among objects
and classes.

Link:
 A (physical/conceptual) connection between two object
instances. A link is like a tuple.
 A link is an instance of an association

Association:
 An association describes a set of links like a class describes
a set of objects.
 Basically a bidirectional mapping.
 One-to-one, many-to-one, one-to-many.
Notation for multiplicity:





1
0
+1
M- N
one and only one
zero or one
one or more
from M to N
greater than or equal to zero
exactly 1
0 or 1 (optional)
>=1
M to N
> = 0 (many)
1-to-1 and 1-to-many Associations
Hascapital
Country
name:String
City
name:String
One-to-one association
StickyNote
Workorder
x: Integer
y: Integer
z: Integer
schedule()
One-to-many association
Object Instance Diagram
Example for 1-to-many
:Sticky
:WorkOrder
x,y,z=(-1,0,5)
:Sticky
x,y,z=(1,10,1)
:Sticky
x,y,z=(10,1,2)
Many-to-Many Associations
Mechanics
Work on
Plane
Ternary and n-ary relations are represented
using the diamond as before, e.g.
Object_1 :
Class_1
Object_2 :
Class_2
Object_3 :
Class_3
We can use object diagrams to understand
recursively defined classes. For example,
the class diagram
Binary_Tree
0,1
0 .. 2
T1 : Binary
Tree
T2 : Binary
Tree
T3 : Binary
Tree
T4 : Binary
Tree
T5 : Binary
Tree
Do associations have direction?

A association between two classes is by default a bi-directional mapping.
B
A

If you want to make A a client, and B a server, you can make the association
unidirectional. The arrowhead points to the server role:
 Class A can access class B and class B can access class A
 Both classes play the agent role.
Name of association
A
accesses
Name Direction
B
Association Direction
Class A ( the “client”) accesses class B (“the server”). B is also called navigable.
Relation R between classes X and Y is:
n-to-… if for every object y :Y there are
n distinct objects x1 ,…, xn : X with
xi R y for i = 1 ,…, n
…-to-m if for every object x :X there are
m distinct objects y1 ,…, ym : Y with
x R yi for i = 1 ,…, m
Roles




A role name is the name that uniquely identifies one end of an
association.
A role name is written next to the association line near the
class that plays the role.
When do you use role names?
 Necessary for associations between two objects of the
same class
 Also useful to distinguish between two associations
between the same pair of classes
When do you not use role names?
 If there is only a single association between a pair of
distinct classes, the names of the classes serve as good
role names
Example of Role
Problem Statement : A person assumes the role of repairer
with respect to another person, who assumes the role of
inspector with respect to the first person.
Person
Person
Creates Workorders
Person
Person
inspector
Creates Workorders
repairperson
Qualification


The qualifier improves the information about the multiplicity of
the association between the classes.
It is used for reducing 1-to-many multiplicity to 1-1 multiplicity
Without qualification: A directory has many files. A file belongs only to
one directory.
Directory
Directory
1
*
File
filename
filename
1
0..1
File
With qualification: A directory has many files, each with a unique name
Example
Problem Statement : A stock exchange lists many companies.
However, a stock exchange lists only one company with a
given ticker symbol. A company may be listed on many stock
exchanges, possibly with different ticker symbols.
Find company with ticker symbol AAPL.
StockExchange
lists
Company
tickerSym
Use of Qualification reduces multiplicity
Company
StockExchange
StockExchange
Directory
tickerSym
tickerSym
filename
1
0..1
Company
FILE
officer
Company
office
Organization
Many-to-Many Qualification
Person
Aggregation
Models "part of" hierarchy
 Useful for modeling the breakdown of a
product into its component parts
(sometimes called bills of materials (BOM)
by manufacturers)

Aggregation
Plain association: peer relationship.
Aggregation: whole/part relationship.
- An object may be a part of ONLY one aggregate at a time.
Company
whole
1
*
Department
part
Aggregation
Special kind of association
 For “part-whole” relationships
 For “has-a” relationships
 Aggregation-by-Value: Composition


Aggregation-by-Reference: Aggregation
Composition
In Composition (composite aggregation):
- An object may be a part of ONLY one composite at a time.
- Whole is responsible for the disposition of its parts.
Window
whole
1
*
Frame
part
Composition (by Value)
gfdgfdgfdgfdgfdg
Aggregation (by Reference)
Product Catalog
Roll Call
Product
1
*
Student
 Aggregation
vs. Composition

Both denote whole-part relationships

Both enable modeling at multiple levels of abstraction:
whole or part
Aggregation vs Composition (contd.)

Aggregation: does not link the lifetimes of the whole and its parts.
Aggregation can occur when a class is a collection or container of other
classes, but where the contained classes do not have a strong life cycle
dependency on the container—essentially, if the container is destroyed, its
contents are not.

Composition: usually has a strong life cycle dependency between
instances of the container class and instances of the contained class(es): If
the container is destroyed, normally every instance that it contains is
destroyed as well. Note that (where allowed):
 Parts with non-fixed multiplicity can be created after the composite
itself.  lifetime
 Such parts can be explicitly removed before the death of the
composite.  lifetime
 An object may be a part of only one composite at a time.  strong
ownership
Generalization




Also called Inheritance or Specialization.
Connects generalized classes to more specialized
classes.
Sometimes called the “is-a” relationship because each
instance of a subclass is an instance of the superclass
as well.
NOTATION :
A triangle connecting the superclass to its subclasses. The
superclass connected by a line to the apex of the triangle. The
subclasses are connected by lines to a horizontal bar attached to
the base of the triangle.
Aggregation Vs Generalization
Both associations describe trees (hierarchies)
AGGREGATION:
 Aggregation relates instances (involves two or more different
objects).
 Two distinct objects are involved; one of them is a part of the other.
 An aggregation tree is composed of object instances that are all part
of a composite object.
 “part-of” relationship.
GENERALIZATION:
 Generalization relates classes (a way to structure the description of
a single object).
 It is a way of structuring the description of a single object.
 An generalization tree is composed of classes that describe an
object
 “a-kind-of”,”is-a” relationship.
Class relationships
Aggregation:
• Represented by has-a relationship
• Also called Whole-part, Composition, or Embedding
• Cardinality is associated with this relationship
Inheritance
• Represented by Is-A relation
• No cardinality is associated
• Also referred to as generalization/specialization
Association
• It is used when objects of two classes communicate or
there is a dependency that doesn’t fit the category of
aggregation or inheritance
• Cardinality is associated
Grouping constructs:
Module:
A logical construct for grouping classes, associations, and
generalizations. It captures one perspective or view of a
situation.
For example:
Electrical, Plumbing and ventilation modules are different views
of a building.
SHEET:
A mechanism for breaking a large object model into a series of
pages.
Revision - Relationships
1. Dependency
a semantic relationship between two things in which a change to one thing
(independent) may affect the semantics of the other thing (dependent).
Directed is optional and label is optional.
2. Associations
a structural relationship that describes a set of links, a link being a connection
between objects.
Can be directed labels
employer
0..1
Aggregation
Can have multiplicity & role names
employee
*
a special kind of association. It represents a structural relationship
between the whole and its parts. Aggregation is inherently TRANSITIVE.
An aggregate has parts, which may inturn have parts.
Represented by
a diamond.
3. Generalization
a specialization/generalization relationship in which objects of the specialized element
(the child) are more specific than the objects of the generalized element.
Aggregation Vs Association
Aggregation relates instances.
 If two objects are tightly bound by a part-whole relationship, it is
aggregation.
Vs
Association:
 If two objects considered are independent, even though they may
often be linked

Company
Works for
Person
Division
Department
How do you find classes?







Learn about problem domain: Observe your client
Apply general world knowledge and intuition
Take the flow of events and find participating objects in use
cases
Apply design patterns
Try to establish a taxonomy ( classification, derivatives )
Do a textual analysis of scenario or flow of events (Abbott
Textual Analysis, 1983)
Nouns are good candidates for classes
Mapping parts of speech to object model components
[Abbot 1983]
Part of speech
Model component
Example
Proper noun
object
Jim Smith
Improper noun
class
Toy, doll
Doing verb
method
Buy, recommend
being verb
inheritance
is-a (kind-of)
having verb
aggregation
has an
modal verb
constraint
must be
adjective
attribute
3 years old
transitive verb
method
enter
intransitive verb
method (event)
depends on
Example: Scenario from
Problem Statement





Jim Smith enters a store with the intention of buying a toy
for his 3 year old child.
Help must be available within less than one minute.
The store owner gives advice to the customer. The advice
depends on the age range of the child and the attributes of
the toy.
Jim selects a dangerous toy which is unsuitable for the child.
The store owner recommends a more yellow doll.
( Is is-a (kind-of) and has-a present in the above text ? )
Object Modeling in Practice:
Class Identification
Foo
Balance
CustomerId
Deposit()
Withdraw()
GetBalance()
Class Identification: Name of Class, Attributes and Methods
Object Modeling in Practice: Encourage Brainstorming
“Dada”
Foo
Balance
CustomerId
Balance
CustomerId
Deposit()
Withdraw()
GetBalance()
Deposit()
Withdraw()
GetBalance()
Account
Balance
CustomerId
Naming is important!
Deposit()
Withdraw()
GetBalance()
Object Modeling in Practice
Account
Bank
Name
Balance
AccountId
Deposit()
Withdraw()
GetBalance()
Customer
Name
CustomerId
Find New Objects
Iterate on Names, Attributes and Methods
Object Modeling in Practice: A Banking System
Account
Bank
Name
Balance
AccountId
*
Deposit()
Withdraw()
GetBalance()
Customer
Has
Name
CustomerId
Find New Objects
Iterate on Names, Attributes and Methods
Find Associations between Objects
Label the associations
Determine the multiplicity of the associations
Object Modeling in Practice: Categorize!
( many accounts belong to 1 bank OR a bank holds many accounts – aggregation)
Account
Bank
* Balance
AccountId
Name
Deposit()
Withdraw()
GetBalance()
Savings
Account
Withdraw()
Customer
*
Has
Name
CustomerId
Checking
Account
Mortgage
Account
Withdraw()
Withdraw()
Object Modeling in Practice: Heuristics






Explicitly schedule meetings for object identification
Try to differentiate between entity, boundary and control
objects
Find associations and their multiplicity
 Unusual multiplicities usually lead to new objects or
categories
Identify Aggregation
Identify Inheritance: Look for a Taxonomy, Categorize
Allow time for brainstorming , Iterate, iterate
Summary
In this lecture, we described:







Identification of objects and classes
Refinement of objects with attributes and operations
Generalization
Associations
Aggregation
Composition
Multiplicity
A static class model for ABC distributing company
Create the class model using the following class relations and the
business rules:
•An
Invoice is composed of one or more Entries
•An Invoice is created for exactly one Customer
•An Invoice is created from one or more CustomerOrders
•An Invoice is used to update the AccountsReceivable account
•An Inventory is composed of zero or more StockItems
•A PackingOrder is initiated from one or more Invoices
•A PackingOrder is created from Inventory items
•A PackingOrder is used to update the Inventory
•A StockOrder is received from a Supplier
•A StockOrder is used to update the Inventory
•A StockOrder is used to update the AccountsPayable account
Class Diagram (a rough sketch for the above problem)
AccountsReceivable
Invoice
CustomerOrder
Customer
Entry
Account
PackingOrder
Created from
updates
Inventory
Supplier
Received from
StockItem
StockOrder
updates
updates
AccountsPayable
Notes:
Please refer to Design_Principles.doc, for details on:
•Coupling
•Cohesion
References:
Notes derived from
Ms. Chandrakala .C.B.,
Dept. of Information & Communication Technology,
Manipal Institute of Technology, Manipal University, India: