Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 0 Introduction to Presentation Format

Similar presentations


Presentation on theme: "Chapter 0 Introduction to Presentation Format"— Presentation transcript:

1 Chapter 0 Introduction to Presentation Format
학번: 이름: 이대현

2 Presentation Outline Object-Oriented Modeling Concepts OO Principles
OO Relationships Introduction to UML

3 객체의 정의 (1) 객체(Object)란? 문제 영역의 실세계에 존재하는 구체적인 대상을 모델링한 것.
게임 - 지형, 캐릭터, 몬스터, 우주선, 보스, … 그래픽 라이브러리 - 점, 선, 사각형, 원, 윈도우, ... 학사 관리 소프트웨어 - 사람, 학생, 직원, 시간제 직원, ... 문서 편집기 프로그램 - 글자, 단어, 문장, 문단, 문서, 글씨체, ... Data (storage) provides the state. ex) int i; Operations provides the behavior. functions, procedures, subroutines, methods, etc. Value vs Variable Value: 2, 3, -7, 3.14, "hello", etc. Variables: int i; char c;

4 객체의 정의 (2) 모델링 방법 데이터와 그 데이터 위에 수행되는 함수들을 가진 소프트웨어 모듈을 이용.
데이터는 객체의 상태(State, Attributes)를 저장하는 데 사용 함수는 그 객체가 수행하는 기능(Behavior, Operations, Methods)을 정의 객체의 조건 (State + Behavior) with Unique Identity 상태 기능 식별 Data (storage) provides the state. ex) int i; Operations provides the behavior. functions, procedures, subroutines, methods, etc. Value vs Variable Value: 2, 3, -7, 3.14, "hello", etc. Variables: int i; char c;

5 객체 지향 프로그래밍 개념 (1) 기존의 시각 하나의 프로그램은 여러 개의 데이터와 이 데이터 위에 수행되는 함수들의 집합 데이터 + 함수들 = 프로그램 상호 연관된 데이터와 함수들이 별도의 독립된 정보인 것처럼 취급된다. int main( ) { } f0( ); f1( ); f2( ); f3( ); f4( ); f5( ); f999( ); Synonym Attribute Variable, Data Structure, Data, Storage Method Operation, Function, Procedure, Algorithms Example of Traditional View Basic, Cobol COMMON block in Fortran Call by Reference in HLL Pointer Manipulation in HLL In OOP Throught the Pre-defined Message Protocol only applies to pure OOPLs.

6 ... 객체 지향 프로그래밍 개념 (2) Object 객체 지향적 시각 f3( ); f5( );
하나의 프로그램은 여러 개의 객체들로 구성됨 각 객체는 소수의 데이터와 함수들로 구성됨 객체 + 객체 = 프로그램 (소수의) 데이터 + (소수의) 함수 = 객체 f3( ); f5( ); ... f2( ); f4( ); f7( ); f1( ); f6( ); Object

7 클래스(Class) 클래스란? A Group of objects with similar properties, common behaviors, common relationships to other objects and common semantics(J. Rumbaugh, et Al. Object Oriented Modeling and Design) 유사한 여러 객체들에게 공통적으로 필요로 하는 데이터와 이 데이터 위에서 수행되는 함수들을 정의하는 소프트웨어 단위. 객체를 찍어내는 “도장” Example Pen, Car, House, Stack, IntegerStack, Number cf. type Type has no explict behavior (function) component. Class is an implementation of Type. Type is more general tern, while class is in OOP.

8 객체 생성 객체를 생성하려면? 인스턴스(Instance) 클래스라는 틀을 이용하여 붕어빵 찍어내듯이 객체를 생성하게 됨.
클래스라는 틀을 이용하여 붕어빵 찍어내듯이 객체를 생성하게 됨. 찍어내는 과정을 Object Instantiation 이라고 함. 인스턴스(Instance) 생성된 각각의 객체 모든 객체는 어떤 클래스로부터 생성된 인스턴스. name: Bob title: 부장 dept: 영업부 salary: 2,000 name: Bill title: 대리 dept: 영업부 salary: 1,500 name: Susan title: 과장 dept: 인사부 salary: 1,800 객체생성 class Employee { char* name; // ... }; Instantiation in C++ int main( ) { Employee Bob, John; Bob.promote(director); Employee* E1; E1 = &Bob; E1->promote(president): ... }

9 OO Principle #1 – Abstraction
객체를 모델링할 때 “문제해결에 필요한 만큼”의 속성과 오퍼레이션을 추출하는 것. 속성과 오퍼레이션을 추가할수록 모델은 실세계에 근접한다.

10 OO Principle #2 – Inheritance
기존의 클래스를 기반으로 하여 새로운 클래스를 만들어 내는 것. 하나의 클래스를 여러 서브클래스들로 세분하거나 유사한 클래스들을 군으로 묶어서 하나의 수퍼 클래스로 정의하는 과정을 소프트웨어적으로 구현한 장치 Child class may “Specialize” the parent class By adding additional attributes and methods By replacing an inherited attribute or method with another Flying Object Bird Helicopter Airplane Canary Penguin DC-10 B-747

11 다중 상속(Multiple Inheritance)
하나의 클래스가 여러 개의 수퍼 클래스를 가지는 경우 Name Conflict와 Conflict Resolution 문제 Person Student UnderGrad Graduate Faculty Staff Temporary Employee Visiting Faculty Temp. Staff

12 OO Principle #3 –Encapsulation
정보 은닉(Information Hiding) 객체의 내부 동작을 보여주지 않는 것. “나는 이러한 정보를 제공할 수 있다”와 “나는 이러한 기능을 수행할 수 있다”는 선언 ‘어떻게(How)’ 부분은 노출시키지 않음 불의의 사고를 사전에 차단함. 객체의 외부소통채널인 인터페이스(interface)를 통해서 객체와 객체는 communication을 함.

13 OO Principle #4 - Polymorphism
서로 다른 객체를 동일한 방식으로 동작 요청을 할 수 있는 성질 서로 다른 객체들은 같은 요청을 받지만 제각기 다른 방식으로 요청을 수행할 수 있음. C++ : 함수 오버로딩(Overloading), 연산자 오버로딩(Overloading)으로 구현. Open

14 메시지 전송(Message Sending)
객체들은 상호 메시지 전송을 통해서 손발을 맞추어 행동하게 됨.

15 OO Relationship (1) – Generalization
클래스와 클래스 사이의 상속 관계를 나타냄. A generalization is a “kind of” or “is a” relationship between a general thing (superclass or parent) and a more specific thing (subclass or child). Circle is a shape(O). Cirle is a kind of shape.(O) Rectangle is a shape(O). Rectangle is a kind of shape.(O) Shape is a circle(X). Shape is a kind of circle(X). 도형(Shape) (Circle) 사각형 (Rentangle)

16 class Circle : public Shape { … };
class Shape { }; class Circle : public Shape { }; class Rectangle : public Shape { };

17 OO Relationship (2) - Association
객체가 다른 객체들과 관계를 맺는 것. Represent relationship between instances of classes Student enrolls in a course / Courses have students / Courses have exams 한 클래스가 다른 클래스를 인지(Acquaintance)함을 의미. 상대 클래스의 객체에게 메시지를 전달할 때 사용되는 통로의 역할 안면이 있는 사람에게 부탁(메시지 요청)을 할 수 있다! 방향성 알고 있는 상대 쪽으로 (인지 방향) 메시지를 전달할 수 있음. 서로 인지하고 있으면 양방향 연관. Person Television call Cellphone

18 Television *theTelevision; pubic: void initialize(void) {
따라서, 상대 클래스의 객체를 가리키는 멤버 변수를 이용하여 구현함. class Television { pubic: void turnOn(void) { } }; class Person { Television *theTelevision; pubic: void initialize(void) { theTelevision->turnOn(); theCellphone->call(); } }; class Cellphone { pubic: void call(void) { } };

19 복수 연관(Multiple Association)
두 클래스 사이에 두 개 이상의 연관 관계가 맺어짐. Business Man Sport Man class BusinessMan { SportMan *theCoworker; SportMan *theFriend; }; class SportMan { BusinessMan *theCoworker; BusinessMan *theFriend; };

20 Mom Kid 0..* 0..* 연관의 다중성(Multiplicity)
한 클래스로부터 생성된 여러 개의 객체가 연관된 클래스의 단일 객체와 연관을 맺음. Mom Kid 0..* class Mom { Kid *theKid[N]; }; 0..* class Kid { Mom *theMom; };

21 OO Relationship (3) - Composition
하나의 객체가 다른 객체(부품)들의 조합으로 만들어진 것. Relation between “Whole Class” and “Part Classes” Composite Aggregation이라고도 함. 따라서 부분 객체만 홀로 존재하는 것이 불가능. Automobile class Automobile { Engine *theEngine; Tire *theTire[4]; Glass *theGlass[6]; }; 0..* 0..* Glass Tire Engine

22 OO Relationship (4) – Aggregation
Shared Aggregation Relation between “Container Class” and “Containee Classes” 한 객체가 다른 객체들을 담고 있음. 담긴 객체들은 다른 객체에 의해서 공유될 수 있음. Cabinet Bag 0..* 0..* 0..* Apple Milk

23 연관, 구성, 및 집합의 구분 기준 기준 구성 (Composition) 집합 (Aggregation) 연관
(Association) 포함 객체의 독립적인 존재 불가능 가능 부분이라는 의미의 적용 대칭성(양방향관계) 비대칭성

24 Summary 주어진 문제를 객체 지향의 모델링 요소를 이용하여 모델링하여 문제를 분석함. Modeling Primitives
Object Class Attributes Methods Message Passing Relationships Generalization Association Composition Aggregation


Download ppt "Chapter 0 Introduction to Presentation Format"

Similar presentations


Ads by Google