Basic Concept of Object-Oriented Paradigm

					Chapter 1 Introduction to objectOriented Modeling and Unify Model Language

2009/11/8

1

1.1 Models and modeling


Model Give an abstract view of a system, highlighting the important aspects of its design, ignoring large amounts of low level detail.

2009/11/8

2

1.1.1 Models of software1


Fig. 0.1 A Primitive model of software development
Analyze Requirement Write code

Requirement specification

Source code

2009/11/8

3

1.1.1 Models of software 2


Fig. 0.2 A more complex software development process
Design module structure Write code

Analyze Requirements

Requirement specification
2009/11/8

Structure Chart

Source code
4

1.1.1 Models of software 3




Analysis model A model to help understand the application being addressed by a system Design Model A model gives an abstract view of a system, high-lighting certain important aspects of its design, such as subroutine and their relationship, and ignoring large amount of low-level detail, such as coding.
5

2009/11/8

1.1.1 Models of software 4




Analysis model is a product of analysis phase Design Model is




a product of design phase a transformation of analysis model. It exists the problem of “Is the transform correct?”

2009/11/8

6

1.2 Methodologies1 (方法論)


Methodology To talk about the method of developing of software. (討論發展軟體的方法)


Software developing is not simply a case of sitting down at a terminal and typing in the program code.

2009/11/8

7

1.2 Methodologies 2


Classification (分類) of methodologies


Procedure oriented method




It is a method to talk about how a system are made up of a collection of data, which are processed by modules external to the data. (資料與程式分開) Data flow and structured method (資料流程圖) are used in analysis.



Object-oriented method


It talks about how a system are made up of a collection of objects, which encapsulate the data and the function to 2009/11/8 process the data. (資料與程式緊密結合)

8

1.3 The Unified Modeling Language1 (一致性模塑語言)


UML (The Unified Modeling Language)




Accepted as a standard by OMG (Object Management Group) Its design based on 4+1 view model of the structure of a software system
Implementation view Use case view Deployment view Process view Design view

2009/11/8

9

1.3 The Unified Modeling Language 2

 




Use Case(使用案例) view – requirement Design view – logical structure Implementation view – physical components Process view – issue of the concurrency Deployment (分置)view – how the physical components are distributed across the physical environment
2009/11/8 10

1.3 The Unified Modeling Language 3








Model – The perspective(透視) of a view; view is concept, while model is that you can see it. Model element – the element that construct a model Diagram – the graphical representation of model elements. Model is represented as a set of diagrams.
11

2009/11/8

1.3 The Unified Modeling Language 4


UML’s diagram types View
Use case view Use case and design views Use case and design views Use case and design views Design view Design and process views Design and process views Implementation view Deployment view
12

Diagram
1. 2. 3. 4. 5. 6. 7. 8. 9.

Use case diagram Object diagram Sequence diagram Collaboration diagram Class diagram Statechart diagram Activity diagram Component diagram Deployment diagram
2009/11/8

1.4 Design Model and Code
specifies UML UML model Abstract view of specifies Programming language Source code Executing program Object structure Abstract view of

Compile-time

Run-time

Object structure: to understand the meaning of UML model and program
2009/11/8 13

1.5 Modeling With Objects


Object Modeling Technique (OMT)

 

Object model Dynamic Model Functional model



Relationship among models

2009/11/8

14

1.5.1 Object Modeling




Definition It is to capture the static structure of a system by showing the objects in the system, relationships between the objects, and the attributes and operations that characterize each class of objects. Key items
  



Objects and classes Attributes Operations relationships between the objects
15

2009/11/8

1.5.2 Objects and classes1




Object – An individual entity in real world, which owns part of data of the system and methods to permit other objects in the system to perform certain operations on that data. Class – to describe the common structure (represents the same kind of entity) of a set of objects.
16

2009/11/8

1.5.2 Objects and classes 2










Attributes – to name the data in an object Method – to name the function in an object to be called by other objects in the system. Operations is the concept of methods. Associations – the relationships between the objects Links


A link is a physical or conceptual connection between objects.
17

2009/11/8

1.5.2 Objects and classes 3


The graphical notation of class

Name of a class Declaration of attributes Declaration of methods

2009/11/8

18

1.5.2 Objects and classes 4


Example
Part - name: String - Number: long - cost: double + part(nm: String, num: long, cst: double) + getName(): String + getNumber(): long + getCost(): double

2009/11/8

19

1.5.2 Objects and classes 5


The graphical notation of an object
General form An example
myScrew: Part Name = “screw” Number = 28834 Cost = 100
20

Object-name: class-name

Attribute’s value

2009/11/8

1.5.3 Associations1


The kinds of associations


Zero to one association One to one association One to many association

○





●



Many to many association

●

●

2009/11/8

21

1.5.3 Associations2


Link attributes is a property of the links in an association. E.g. 1,
Accessible by file
● ●

user

Access permission
2009/11/8 22

1.5.3 Associations3


Example-2


role names – boss, worker
boss ○ Person Name… ● worker ● Works-for ● Salary Job title Name Address Company

managers

2009/11/8

Performance rating

23

1.5.3 Associations4
• Example-3 Modeling an association as a Class
User ● Authorized on ● Workstation

Authorization Priority privileges start session

● Home directory directory
2009/11/8 24

1.5.3 Associations5


Example-4


qualification

Directory

File name

file

2009/11/8

25

1.5.3 Associations6


Aggregation (聚合) It is the“part-whole” or“a-part-of” relationship.
Microcomputer

․ monitor

○

System box

mouse

Keyboard

Chassis(框架)
2009/11/8

CPU

RAM

fan
26

1.5.3 Associations7


Example for Aggregation


UML Model for 學校行政組織
學校行政組織

秘 書 室
2009/11/8

教 務 處

總 務 處

學 務 處

會 計 室

人 事 室

計 算 機 中 心

圖 書 館

研 發 處
27

1.5.3 Associations8


Figure
Color Center position Pen type

Generalization and inheritance
1 dimension Orientation scale

Move Select Rotate

0 dimension

Line Endpoint display
2009/11/8

Arc
Radius Start angle scale

Point

display
28

1.5.3 Associations9


Aggregation versus Generalization
Fluorescent lamp

Lamp

Incandescent lamp

Ballast (穩壓 器)
2009/11/8

starter

Twist mount socket

base

Power line

switch

29

1.5.4 Some Feature of Classes1


Abstract Classes、Concrete Classes
ClassA
Int p; Method1(); Method2(int x);

(右圖) ClassB繼承ClassA,ClassA 中定義的 Method1及Method2只有 介面,沒有處理程序,處理程序 在ClassB中定義,此時ClassA稱為 Abstract class,ClassB則稱為 Concrete class

ClassB Int p;

2009/11/8

Method1(); Method2(int x);

30

1.5.4 Some Feature of Classes2


Propagation of operation





利用繼承可以達到 operation 的傳送 如因A有 method1() , B也有, C也因B有 method1()而有method1() ,此暨A傳 method1()給B,B再傳給C 具有Aggregation 特性的物件群,有 Propagation of operation的特性。

2009/11/8

31

1.5.4 Some Feature of Classes3


Overriding operation
ClassA

(右圖) ClassB繼承ClassA, ClassA中定義了 Method1及 Method2的介面及處理程序, ClassB也定義Method1及Method2 的處理程序,此時不特別指名的 使用Method1、Method2 ,皆指 ClassB的Method1、Method2, 此 稱為Overriding
2009/11/8

Int p; Method1(); Method2(int x);

ClassB Int p;

Method1(); Method2(int x);

32

1.5.4 Some Feature of Classes4


Generalization as extension and restriction
ClassB::Method1(){ ClassA::Method1(); … 其他指令 … } ClassB::Method1(){ If ( p>10)
2009/11/8

Extension:

ClassA
Int p; Method1(); Method2(int x);

Restriction:
ClassB Int p; Method1(); Method2(int x);
33

ClassA::Method1(); }

1.5.4 Some Feature of Classes5


Multiple inheritance

ClassC Int p;
Method3(); Method4(int x);

ClassA Int w; Method1(); Method2(int x);

ClassB
Int p;
2009/11/8 34

1.5.4 Some Feature of Classes6


Recursive aggregation
ClassA

ClassB

Classx

Classw

2009/11/8

35

1.5.4 Some Feature of Classes7




Candidate keys Is a minimal set of attributes that uniquely identifies an object or link. Constraints they are functional relationships between entities of an object model.
Employee Salary
2009/11/8

○

boss

․
{salary <= boss.salary}
36

1.5.4 Some Feature of Classes8


Constraints on links
{ordered} Country office ․ Person

2009/11/8

37

1.5.4 Some Feature of Classes9


General constraints
Person ․
Member-of {subset}
Chair-of

․Committee
․

2009/11/8

38

1.5.4 Some Feature of Classes10


derived objects, links, and attributes The value is a function of another one or ones.
Machine

․Assembly
offset offset

․Part

Offset Part.Offset = assembly.machine.offset X part.assembly.offset
2009/11/8 39

1.6 Dynamic Modeling1
 

To concern with the time and changes of the system To include the following entities:
 


   

Event State State diagram Operation Concurrency Scenarios Event traces
40

2009/11/8

1.6 Dynamic Modeling2


Event and state


Event (事件)




An individual stimulus from one object to another is called. Ex 物件A叫用物件B的一個method,對物件B來 說就是接收一個 event

2009/11/8

41

1.6 Dynamic Modeling3


Event generalization
Event time User input Device

Mouse button location

keyboard character

2009/11/8

control

graphic

42

1.6 Dynamic Modeling4




State: The attribute value and links held by an object is called. The description of states State: name Description: describe in narrative language Event sequence to set the state: Condition that characterizes the state: Event accepted in the state: Event action next-state

2009/11/8

43

1.6 Dynamic Modeling5


State diagram
Event(attributes) [condition]/action State1 Do: activity State2 Do: activity

2009/11/8

44

1.6 Dynamic Modeling6


State generalization ․
forward Neutral Reverse

transmission

․


first

second

third

Automatic transition (進入state後就自動轉進)
以 ․ 表示
45

2009/11/8

1.6 Dynamic Modeling7


Nested state diagrams: 目的是讓圖清晰

s1 s3
State Sn:

s2 sn
s4 sn2 sn1 sn3
46

(為Nested state)
2009/11/8

sn4

1.6 Dynamic Modeling8


Concurrency


再同一state內有多個activity同時進行
Playing rubber N-S vulnerability N-S game N-S game vulnerable

․

Not vulnerable

E-S wins rubber

․
2009/11/8

E-W vulnerability E-W game E-W game Not E-S wins vulnerable vulnerable rubber
47

1.6 Dynamic Modeling9


Activity


指在一state內所做的動作, 如在圖書館內查書。
指進入一state時所要做的 動作,如在一管制場地進 口用計數器計算入場人數 指走出一state時所要做的 動作,如在一管制場地進 口用計數器計算出場人數

表示方式 State Do: activity Entry/ action Exit action



Entry action




Exit actions


2009/11/8

48

1.6 Dynamic Modeling10


Scenarios
 

把一行為的系列動作依時間次序寫出來 如校務行政系統的選課行為
1. 進入網頁 2. 選擇學生身分 3. 進入選課系統 4. 登入 5. 系統出現選課畫面 6. 點選欲選的課的開課班級 7. 系統出現該班所開課程目錄 8. 點選欲選的課 9. 點選“結束”或“再選” 10.系統結束或回到第五步

2009/11/8

49

1.6 Dynamic Modeling11


Event traces


將Scenarios以下圖表示出來
:UI :object1 :object2

actor

:objectn

time
doA()

event
2009/11/8

表示物件1叫用物件n 的method “doA()”

50

1.6 Dynamic Modeling12


登入的 Event traces
:UI getUser()
check(user, psw) getPsw(user)

actor
Key in Psw and user-id

:PswChk

:UserFile

:選課系統

checkuser()

[Not valid]

[valid] 選課(權限)
51

2009/11/8

1.7 Functional Modeling1


Data flow diagram (DFD,資料流向圖)
 

用以表示物件內activity處理時資料的流向 Modeling element
symbol meaning Process (module) Data flow Data store Actor Control flow

2009/11/8

52

1.7 Functional Modeling2


E.g.,登入的 DFD

Password, user-id

password [valid] 選課系統

keyboard
pswchk

[not valid]

2009/11/8

53

1.7 Functional Modeling3
• One of DFD Forms
q r
s

w p t u v

x

y
2009/11/8 54

1.7 Functional Modeling4


The Primitive Flow Type


Transform flow
a b c



Transaction flow
r

p

T

s … t

2009/11/8

55

1.7.1 Software structure of DFD1
• Transform flow
a b c

• 相對的 software structure controller

a
2009/11/8

b

c
56

1.7.1 Software structure of DFD2
• Transaction flow
p T r s …

• 相對的 software structure
controller p
R

t

T
S

..

2009/11/8

T

57

1.7.1 Software structure of DFD3


Show the software structure of the example on page 54 in class

2009/11/8

58

End of the chapter

2009/11/8

59


				
DOCUMENT INFO