30
Object Oriented Concepts and Programming เสถียร หันตา คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา

Object Oriented Concepts and Programming · Data Flow Diagrams (DFD) ... client interviews ... หาก module มีการเกาะยึดสูง

Embed Size (px)

Citation preview

Object Oriented Concepts and Programming

เสถยร หนตาคณะเทคโนโลยสารสนเทศและการสอสารมหาวทยาลยพะเยา

Lecture Outline

Software development and design

Structured analysis and design

Object-Oriented analysis and design

Function

Object-Oriented programming

Software development and design

Software

ชดค าสงหรอโปรแกรมทใชควบคมการท างานของเครองคอมพวเตอรทเขยนขนดวยภาษาคอมพวเตอร

สรางขนเพอแกปญหาของผใชและท างานตามทผใชตองการไดอยางถกตอง

Software Development

Software Development Life Cycle

Software Analysis and Design

Structured Analysis and Design

Object Oriented Analysis and Design

Structured Analysis and Design

Data Oriented

Data Flow Diagrams (DFD)

Entity Relationship Diagrams (ERD)

Action Oriented

Finite State Machine (FSM)

DFD Level 0

DFD Level 1

DFD Level 3

DFD

ER Diagram

Object-Oriented Analysis

Builds a real-world model from requirements

client interviews

domain knowledge

real-world experience

The model addresses three aspects of objects

class structure and relationships

sequencing of interactions and events

data transformations and computations

Models of Object-Oriented Analysis

Class Model

static structure

what objects are in the system?

how are they related?

Dynamic Model

behavioral aspects

what events occur in the system

when do they occur and in what

order?

Functional Model

data transformations

“what” does the system do

Data-Oriented

Action-Oriented

Both Data and Actions

Object Oriented Analysis and Design

The Unified Modeling Language (UML)

ตวอยาง

Use-case diagram Class diagram

UML DiagramsStructural

: element of spec. irrespective of time

Class

Component

Deployment

Object

Composite structure

Package

Behavioral: behavioral features of a system / business process

Activity

State machine

Use case

Interaction

Interaction: emphasize object interaction

• Communication (collaboration)

• Sequence

• Interaction overview

• Timing

Structured analysis and design

Object oriented analysis and design

Functions

What we call them:

functions, methods, modules

Functions are a core construct in OO and

non-OO programs

Principals of good functions apply in either

language

But less of a problem in OO – can you think why?

Functions

Functional decomposition แยกปญหาใหเปนสวนยอย

ใช function แกปญหาทละสวน มลกษณะเปนล าดบชน

Problems

การควบคมและการประสานงาน รวมอยท Main method

การเปลยนแปลงท าใหเกดผลกระทบมาก

Functions

Functions, Methods, Modules

Cohesion

Coupling

Cohesion and Coupling

Cohesion (การเกาะยด) การเกาะยด คอระดบของความสมพนธภายใน module

หาก module มการเกาะยดสง แสดงวาสามารถท างานดวยตวของมนเองระดบหนง และมการเรยกใชหรอผกยดกบโปรแกรมตาง module นอย

Coupling (การปฏสมพนธ) การตดตอสงขอมลระหวาง module

ถาระบบใดมปฏสมพนธระหวาง module มาก การยดเกาะภายในจะมโอกาสลดนอยลง

Goal

Flexibility, independence of modules

Looser connections, less brittle system

Reusability

Loosely-coupled modules, each highly

cohesive

Object Oriented Programming

Object

Attributes, Methods and Events.

Inheritance

Encapsulation

Polymorphism

Programming Languages

ภาษาคอมพวเตอรใชในการสรางซอฟแวร แบงเปน 3 กลมหลก ๆ

Machine languages

Assembly languages

High-Level languages

Machine Languages

เปนเลขฐานสอง ประกอบดวย 0 และ 1 มความยากในการเขยนโปรแกรมเนองจาก

เปนภาษาทมนษยเขาใจไดยาก ความผดพลาดเพอ 1 จดกท าใหโปรแกรมลมเหลวได ตวอยาง

1110100010101 111010101110 10111010110100 1010001110111

Assembly Languages

เกดจากการออกแบบตวอกษรภาษาองกฤษใหแทนค าสงรหสเลขฐานสองเรยกวา รหส mnemonic

คอมพวเตอรตองแปลเปนภาษาเครองกอนประมวลผล ตวอยาง

ADD 1001010, 1011010

High-Level Languages

เปนภาษาทท าใหการเขยนโปรแกรมงายขน ใกลเคยงกบภาษามนษย แบงเปน สองกลมหลก

Procedural (Structural) languages

Object-Oriented Languages

Procedural Languages

เปนภาษาระดบสง ทมลกษณะเปนค าสงเรยงล าดบเปนขนตอน และเปนโครงสราง

ตวอยาง C

COBOL

Fortran

LIPS

Perl

Object-Oriented Languages

ใหความสนใจท modeling data ไมใชโครงสราง เขยนโปรแกรมโดยใชแบบแปลนของแบบจ าลอง Classes

ตวอยาง C++

Java

VB.NET

OO Terms and Conceptso Object and Classo Inheritance, Encapsulation and

Polymorphismo Relationship and Interaction between

classes

OO Analysis and Designo Object Modeling with UMLo UML Diagramso Tools

Mapping UML model into OO Programming Languageso Java Language