Object Oriented Design Course Material
Object Oriented Design Course Material
since 1986, software researchers and practitioners have been studying the
discipline of object oriented design. in that time, they have developed a set of
well-defined design principles that aid developers in designing software that is
robust, flexible, maintainable, and reusable.
The basic concepts of object oriented paradigm are relatively easy to understand
and easy to apply. The object oriented approach was invented because of the
difficulties, people were trying to produce quality systems on time and within
budget, especially for large systems with many people involved, so the object
orientation is an outstanding approach for software development
2 Design Concepts
2.1 Abstraction
An example of procedural a abstraction would be the word OPEN for a door. OPEN
implies a long sequence of procedural steps ( e.g, walk to the door, reach out and
grasp knob, turn knob and pull door, etc.)
Data abstraction is a named collection of data that describes a data object. For
example, the data abstraction for door would encompass a set of attributes that
describe the door ( e.g., door type, weight, direction, etc.)
It follows that the procedural abstraction OPEN would use of information
contained in the attributes of the data abstraction door.
2.2 Architecture
Process models focus on the design of the business that the system must
accommodate.
2.3 Patterns
The perceived complexity of two problems when they are combined is often
greater than the sum of the perceived complexity when each is taken separately.
This leads to a “divide and conquer” strategy. So, it is easier to solve a complexity
problem when you break it into manageable pieces.
The use of information hiding as a design criterion for modular systems provides
the great benefits when modifications are required during testing and later, during
software maintenance.
2.7 Refinement
The Object Model (OM): It depicts the object classes in the system and their
relationship, as well as their attributes and operations, and thus represents
the static structure of the system. The object model is represented
graphically by a class diagram.
The Dynamic Model (Dm): It captures the essential behaviour of the system
by exploring the behaviour of the objects over time, and the flow of control
and events among the objects. Scenarios of the flow of events are captured
in event-trace diagram. These diagrams, along with state transition
diagrams (state charts), compose the OMT dynamic model.
The Functional Model (FM): Is a hierarchical set of data flow diagrams (DFD)
of the system and describes its internal process without explicit concern for
how these process are actually performed.
Covering the full generic life cycle. OOSE process consists of three main phases,
each produces a set of models:
o Robustness analysis:
It consists of four steps, the process is iterative, so each of the steps may have to
be done more than once.
The first step aimed to identifying classes and objects. The purpose of this step is
to establish the boundaries of the problem and to obtain a first
decomposition(abstraction form).
The second step is concerned with determining the behaviour and attributes of
each abstraction, and the distribution of responsibilities over components of the
system. (attributes and desired behaviours are identified by analyzing typical usage
scenarios. The semantics of usage scenarios are captured in sequence and
collaboration diagrams ( termed interaction diagram and object diagram,
respectively).
The third step concerned with finding relationships between objects. During
analysis, emphasis is on finding relationships between abstraction. During design,
is about inheritance,... the result is shown in class diagrams, collaboration
diagrams, and so-called module diagrams.
Finally, the abstraction are refined up to a detailed level. A decision is made about
the representation of each abstraction, algorithms are selected, and solution-
oriented classes are added when needed.
In this method, the difficult is to decide when to iterate and what to do in a specific
iteration.
3.4 Unified modelling language (UML)
UML diagrams
Use case typically stand for verb phrases that can be derived from user
requirements and from possible uses of the system actors.
Use cases are : add user, remove user, receive message and send
message.
Online system
Add user
Remove user
Receive
message
Chat user
Send message
Extend relationship:
<< extends>>
Browse
<< extends>>
search
Uses/include relationship:
( two use cases might not have any kind of inheritance, but one still use
the other for a specific purpose).
Gives price
<< extends>>
Locate book
Whenever a book is located it has to return the price of the item.
Example: Use case diagram of a computer game:
Computer game
<<uses>>
Saves information
Player
Makes move Board
<<uses>>
Update itself
Record Booking
Cancel
<<uses>>
Get list
For example:
Actor(s): Librarian
Update student
view student biographic biographic file
Secretary file
<<extends>>
Enter academic records
Print student grades
<<extends>>
Administration
Get statistical results
Get query results
Activity diagrams
Conduct meetings
Elicit requirements
Formal prioritization
[yes]
[No]
Define actors
Enter participant Id
Check participant
[Not found]
[found]
search
[Not found] [found]
Search an item
[Not found]
[found]
Update number of
copies
Classes and objects
Attributes (states)
Methods (behaviour)
Company Car
-Name: string
+Id: integer
Add()
Modify()
Associations:
Two analysis classes are related to one another, these relationships are
called associations.
1 manage 1
Manager company
relationship
1 owns 1..*
Company car
* zero or more.
1..* 1..*
Student Book
Copy
Associations class relationship ( class related with another class by another class).
`
Aggregation:
X Y
ex2.
1..*
Company Branch
ex3.
1..* 1..*
Car Driver
Body Motor
Class diagram.
Composition aggregation
Book
1..*
page
*
paragraph
Generalization
Is - a
B student
Person
+ Id integer
- Name string
- address string
Add()
student Teacher
Dependency relationship
Customer Order
Add() Add(No,nm,....)
CalcTotal()
1..* Item
Payment Order_detail
Item_code Integer
+amount double - quantity 1 1..* Description String
- tax -Price double
-weight double
ClacSubTotal() getPrice()
CalcWeight() GetWeight()
Person
+ Id integer
- Name string
- address string
Add()
student Teacher
Class diagram
:Person
Id 123
Name “ali”
address “Sert”
: student :Teacher
Object diagram
Sequence diagram
UML sequence diagrams model the flow of logic within your system in a
visual manner, enabling you both to document and validate your logic,
and are commonly used for both analysis and design purposes.
:Object1 :Object2
M1
R1
M2
Instead of three arrows between the two objects, we have two arrows
with a condition on the second arrow.
:Object1 :Object2
M1
accept
X
reject
Ex.
:student :registrar
Request_reg(name,percente)
check
Ok
Or,,,,,
:student :registrar
Request_reg(name,percente)
Accept[percentage>=70%]
Example. Sequence diagram for a bookstore inventory system. it has
three objects: the customer, the bookstore and the book.
orderbook(title,author)
locate(title,author) check
Book is found
Return price
give price
Gives book
Ex2. When the customer wants to buy a property, he/she has to accept
the agreement conditions displayed by the system. Then, he/she has to
submit his/her credit card number to the many handling subsystem.
borrow(MID, CID)
borrow(Copy)
okToBorrow( )
borrow(Member)
borrow( )
Alternatives
If you want to show that several messages are conditionally sent under
the same guard, you'll have to use an 'opt' combined fragment. The
combined fragment is shown as a large rectangle with an 'opt' operator
plus a guard, and contains all the conditional messages under that
guard.
Loop
When the sequence gets to the return value "balance," it checks to see if
the balance is less than the amount. If the balance is not less than the
amount, the next message sent is the addDebitTransaction message,
and the sequence continues as normal. However, in cases where the
balance is less than the amount, then the sequence enters the break
combination fragment and its messages are sent. Once all the messages
in the break combination have been sent, the sequence exits without
sending any of the remaining messages (e.g., addDebitTransaction).
Parallel
The parallel combination fragment is drawn using a frame, and you place
the text "par" in the frame's namebox. You then break up the frame's
content section into horizontal operands separated by a dashed line.
Each operand in the frame represents a thread of execution done in
parallel.
The following figure offers an easy-to-understand example of a
sequence with parallel activities. The sequence goes like this: A
hungryPerson sends the cookFood message to the oven object. When
the oven object receives that message, it sends two messages to itself at
the same time (nukeFood and rotateFood). After both of these messages
are done, the hungryPerson object is returned yummyFood from the
oven object.
Collaboration diagram
3:book is found
:Book :Bookstore
1: orders a book
:Customer
1:inser card
3: locates password
9: enters kind
11:enters amount
17:takes cash
18:removes his card
:User :ATM
16:dispense cash
10:requests amount
8:requests kind 4:validate account
2:requests password 12:process transaction
6:bank accept
14:bank transaction succeed
:Bank :Consortium
13:process bank
5:verify card
:AddAdvert :Client :Campiagn :Advert
:CampaignManager
:AddASdvetUI
StartInterface
SelectClient
ShowClientCampaigns
listCampaigns
listAdverts
All state diagrams being with an initial state of the object. This is the
state of the object when it is created. After the initial state the object
begins changing states. Conditions based on the activities can
determine what the next state the object transitions to.
Example: Order object
When the object enters the Checking state it performs the activity "check items." After the
activity is completed the object transitions to the next state based on the conditions [all items
available] or [an item is not available]. If an item is not available the order is canceled. If all
items are available then the order is dispatched. When the object transitions to the
Dispatching state the activity "initiate delivery" is performed. After this activity is complete the
object transitions again to the Delivered state.
State diagrams can also show a super-state for the object. A super-state is used when many
transitions lead to a certain state. Instead of showing all of the transitions from each state to
the redundant state a super-state can be used to show that all of the states inside of the
super-state can transition to the redundant state. This helps make the state diagram easier to
read.
Both the Checking and Dispatching states can transition into the Canceled state, so a
transition is shown from a super-state named Active to the state Cancel. By contrast, the
state Dispatching can only transition to the Delivered state, so we show an arrow only from
the Dispatching state to the Delivered state.
Note:
You can see that transitions are a reflection of your business rules. For example, you
see that you can attempt to enroll a student in a course only when it is open for
enrolment or full, and that a seminar may be split (presumably into two seminars)
when the waiting list is long enough to justify the split. You can have recursive
transitions, also called self transitions, that start and end in the same state. An
example of which is the student dropped transition when the seminar is full.
Package A
package name
Package B Package C
The package diagram shows how the various classes are grouped into packages. There
are two "top-level" classes - ATMMain and ATMApplet - which allow the system to
be run (respectively) as an application or as an Applet. (Only one of the two would be
instantiated in any particular use of the system.)
Each of these classes, in turn, depends on the package ATM which contains the class
ATM that represents the system as a whole, and the class Session that represents one
session. ATM depends on Session, and vice versa - since the ATM creates Sessions,
and each Session, in turn, uses the ATM to interact with the customer.
The subpackage physical contains the classes that represent the various physical
components of the ATM. For the purposes of this simulation, these are simulated by a
GUI. A real ATM would have quite different classes in this package - classes that
actually control its physical components. The class ATM makes use of these
components, and Session and the various kinds of transaction gain access to them
through ATM to actually perform the needed operations.
Finally, the package banking contains classes that represent the banking enterprise
itself and the information communicated back and forth between the ATM and the
bank - i.e. classes which might be the same in a totally different implementation of an
ATM that interacts with the same bank.
This is, of course, a simulation. However, most of the code that is specific to the
simulation resides in the package physical, plus the two top-level classes. Presumably,
the other classes and packages might be similar in a real system.
SubSysA
SubSysA
Example:
Behavioral diagram
Implementation model
Subsystem C Subsystem A
Subsystem D Subsystem B
cohesion