Download
slide1 n.
Skip this Video
Loading SlideShow in 5 Seconds..
Object Oriented Development PowerPoint Presentation
Download Presentation
Object Oriented Development

Object Oriented Development

332 Views Download Presentation
Download Presentation

Object Oriented Development

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Object Oriented Development

  2. Object-Oriented DevelopmentHistorical Perspective • Concepts like “objects” and “attributes of concepts” actually date back to the early 1950s – in early works in Artificial Intelligence (Berard, 1993) • Real legacy of object oriented movement began 1966 – Kristen Nygaard and Ole-Johan Dahl created SIMULA, first language to provide encapsulation at a more abstract level than subprograms; data abstraction and classes were introduced to simulate a problem. • 1970s – Smalltalk – first true object oriented language • LOGO • LISP • 1986 - Objective-C, C++, Self, Eiffel, Flavors • 1990s – ongoing investigation of object oriented domain analysis, testing, metrics and management

  3. 객체지향개발의 등장배경 객체지향 방법론의 등장 이유는 프로그래머 생산성 향상과 유지보수비용 절감으로 집약된다. 그 이유는 다음과 같다. 1. 객체중심의 모델링이 현실세계를 보다 가깝게 묘사하기 때문에 시스템에 대한 이해가 증진 되기 때문이다 2. 소프트웨어의 재사용성(reusability)의 증가. 3. 그래픽 유저 인터페이스(GUI)와 윈도우 시스템의 등장을 들 수 있다. 4. 모델과 현실간의 자연스러운 대응을 통해 실시간 시스템 개발에 적합하다는 주장도 있다. 5. 객체지향 분석과 설계는 객체지향 프로그래밍을 전제로 성립 가능 3

  4. Object and Class Item B916X5 Bolt 200 0 method ItemID를 출력하라 Description을 출력하라 Quantity를 출력하라 Item을 인도하라 Item을 기록하라 property(변수) ItemID Description Quantity NumberAllocated object class S716X10 Screw 350 300 : main( ) { Item bolt; // 객체생성 bolt.reportprint(const int * quantity); // 생성된 객체로 // 하여금 메소드를 실행 Item screw; screw.record(const char * itemid); } : class Item { private: char itemid; char description; unsigned int quantity; unsigned int numallocate; // 클래스의 속성 정의 public; Item( ); ~Item( ); recordprint(const char* itemid); // 메소드 reportprint(const int * quantity); record(const char * itemid); }; *보충설명 :개개의 객체들은 클래스에 의해 정의되며 객체들을 생성할 수 있는 템플릿을 만들어 준다. 그러므로 객체는 클래스의 인스탄스이다. 또한 클래스는 객체지향 소프트웨어 구축의 근원이 된다.

  5. 붕어빵과 Object 붕어빵 기계와 Class

  6. What is an Object? • An object is a piece of code that owns things called attributes and provides services through methods (also called operations or functions). Typically the methods operate on private data -- also called instance data or object state -- that the object owns. • A collection of like objects make up a class (sometimes called a type). A class acts as a template that describes the behavior of sets of like objects. • Technically speaking, objects are run-time instances of a class. An object is identified by a unique ID (also known as a reference or handle) Robert Orfali, Dan Harkey

  7. ClassName attributes operations Classes A class is a description of a set of objects that share the same attributes, operations, relationships, and semantics. Graphically, a class is rendered as a rectangle, usually including its name, attributes, and operations in separate, designated compartments.

  8. Sound Signal Amplify Signal Play Amplifier Tape Deck Speaker Turn On Turn Off Set Volume Amplify Signal Turn On Turn Off Play Stop Sound Signal 객체의 동작원리 • 객체들은 메시지를 보냄에 의해 서로간에 의사소통을 한다. 서버 객체 클라이언트 객체

  9. 객체의 동작원리 • 객체들은 서비스를 윈하는 객체가 서비스를 제공하는 객체에게 메시지를 보냄으로써 의사 소통을 한다. • 메시지 시그내쳐는 오퍼레이션 시그내쳐에 일치해야 한다. 즉 서비스 제공 객체가 가지고 있는 오퍼레이션에 맞게 메시지를 보내야 한다는 것이다. • 객체는 오퍼레이션이 일치하는 지 확인하고 난 뒤 다시 서비스를 원하는 객체 즉, 클라이언트 객체에게 그 결과값을 되돌려준다. 서버 객체 클라이언트 객체 메시지 시그내쳐 Play Turn On, Turn Off, Play, Pause, Stop 오퍼레이션

  10. 객체의 동작원리 • 메시지, 오퍼레이션, 메소드 간에 용어를 구별해야 한다. Method: Play: start motor start laser position laser detect light signal convert to ... Message: Play Operation: Turn On, Turn Off, Play, Pause, Stop Message객체들 사이의 시그날(신호)이다. Operation 객체에 의해 제공되는 서비스이다. Method 오퍼레이션을 실질적으로 구현한 것이다.

  11. Why OO? • OO Approaches in General • OO approaches encourage the use of “modern” software engineering technology • OO approaches promote and facilitate software reuse • OO approaches facilitate interoperability • When done well, OO approaches produce solutions which closely resemble the original problem

  12. Why OO? • When done well, OO approaches result in software that is easily modified, extended, and maintained • The Overall OO Approach • Traceability improves if an overall OO approach is used • There is a significant reductionin integration problems • The conceptual integrity of both the process and product improves source: Motivation for an Object-Oriented Approach to Software Engineering, Edward Berard The conceptual integrity- means that the system’s separate components work well together as a whole with balance between flexibility, maintainability, efficiency…

  13. Abstraction 몬트리안 추상화

  14. Abstraction • Mapping abstraction to software

  15. Abstraction • Practical Abstraction

  16. Abstraction

  17. Abstraction • Better Abstraction

  18. Abstraction • The Progress of Abstraction • Assembly language is a small abstraction of the machine while imperative languages (명령형언어: C, BASIC, and FORTRAN) were abstractions of assembly language. • These are improvements over assembly language but still require you to think in terms of the structure of the computer rather than the structure of the problem you are trying to solve.

  19. Abstraction • In the old model, the programmer must establish the association between the machine model and the model of the problem being solved • The OO approach provides TOOLS for the programmer to represent elements in the problem space

  20. Encapsulation “One of the fundamental principles of object technology is that the internals of an object are private to that object and may not be accessed or even examined from outside the object” - David Taylor, Author Business Engineering with Object Technology (Wiley, 1995) • Encapsulation means “don’t tell me how you do it; just do it” • An object publishes a public interface that defines how other objects can interact with it

  21. Encapsulation method Instance Data method method method

  22. Encapsulation • The two main reasons for controlling access to an objects functions are: • Keep client programmers’ hands off portions they shouldn't touch -- parts that are necessary for the internal machinations of the object but not part of the interface that users need to solve their particular problem • Allow the library designer to change the internal workings of the structure without worrying about how it will affect the client programmer.

  23. Encapsulation • Java uses three explicit keywords and one implied keyword to set the boundaries in a class: • public • private • Protected (상속받은클래스에서 참조) • implied ‘friendly’

  24. friend 함수 class NeMo { int garo, sero; // 비공개 멤버 변수 public: NMo(int g, int s) { // 생성자함수 garo = g; sero = s; } void pyosi(){ printf("\n GaRo : %d\n", garo); printf( " SeRo : %d\n", sero); printf( " MyunJuk : %d\n", garo*sero); } friend void main(); // NeMo의 비공개 멤버를 }; // main()에서 사용할 수 있게 한다 void main(){ NeMo x(5, 10); printf(" x garo : %d\n", x.garo); printf(" x sero : %d\n", x.sero); x.garo = 30; x.sero = 40; x.pyosi(); getch(); } <실행결과> x.garo : 5 x.sero : 10 GaRo : 30 SeRo : 40 MyunJuk : 1200 24

  25. 상속 일반화: 유사한 클래스들 사이의 공유되는 속성과 동작을 묶어 주고 또한 서로 다른 점을 보존 할 수 있게 해 주는 추상화기법. 동물 모양, 무게 숨쉬기 표유류 바다동물 자식수 발의 개수 수영속도 최적온도 젖먹음 헤엄침 상어 고양이

  26. Inheritance Children classes can enhance the behavior of their parents. And if parental behavior is enhanced, it is to the benefit of the children. - Steve Jobs • Inheritance is the mechanism that allows you to create new child classes -- known as subclasses or derived classes -- from existing parent classes • Child classes inherit their parent’s methods and data structures

  27. Inheritance • You can add new methods to a child’s class or override (modify) inherited methods to define new class behaviors • You use inheritance to extend objects; it means everything in that object plus ...

  28. Inheritance Car Bus Truck This is an example of a typical class hierarchy tree. Note the arrows point upward from a class to its parent class -- the idea is that classes must know their parent class, but not vice versa.

  29. Inheritance • Some object models support single inheritance(Java) while others (C++) support multiple inheritance • Abstract classes are classes whose main purpose is to be inherited by others

  30. Polymorphism • Polymorphism is a fancy way of saying that the same method can do different things, depending on the class that implements it • Objects in different classes receive the same messageyet react in different ways

  31. 생성자 함수의 다중정의(Overload) main(void){     init a('R');     // 한 개의 매개변수로 객체생성 a.disp(); init b(1, 'H'); // 두 개의 매개변수로 객체생성 b.disp(); } #include <iostream> class  init {     int  id;        char  letter;        public:  init(char c)  {   id=0;  letter=c;  }  // 생성자 함수의 다중정의 init(int i, char c) {   id= i; letter=c;  }             void disp(void) {   printf("%d  %c\n",  id, letter);  } }; 

  32. Reuse • Expected Benefits of Reuse • Timeliness • Decreased maintenance effort • Investment • Reliability • Efficiency • Consistency Source B. Meyer, Object-Oriented Software Construction, 1997

  33. Reuse • What Should we Reuse? • Personnel • Designs and Specifications • Design Patterns • Source Code • Abstracted Modules Source B. Meyer, Object-Oriented Software Construction, 1997

  34. Software Design Static Modeling using theUnified Modeling Language (UML) Material based on [Booch99, Rambaugh99, Jacobson99, Fowler97, Brown99]

  35. Model Example: Map(1/2) (a) Picture (c) Incomplete Representation

  36. Model Example: Map(2/2) (c) Geomorphology Representation (d) Geological Representation

  37. UML Diagrams Use case diagram Sequence diagram Collaboration diagram State diagram Activity diagram Class diagram Object diagram Component diagram Deployment diagram

  38. UML Diagrams Structural Diagrams Behavioral Diagrams To visualize, specify, construct, and document the static aspect of a system To visualize, specify, construct, and document the dynamic aspect of a system Use case diagram Sequence diagram Collaboration diagram State diagram Activity diagram Class diagram Object diagram Component diagram Deployment diagram

  39. Plan Coding Testing Object Oriented Development Process OOA Use Case Diagram Conceptual Class Diagram Sequence Diagram Sate Transition Diagram Activity Diagram OOD Detail Class Diagram Component Diagram Deployment Diagram

  40. ClassName attributes operations Classes A class is a description of a set of objects that share the same attributes, operations, relationships, and semantics. Graphically, a class is rendered as a rectangle, usually including its name, attributes, and operations in separate, designated compartments.

  41. ClassName attributes operations Class Names The name of the class is the only required tag in the graphical representation of a class. It always appears in the top-most compartment.

  42. Person name : String address : Address birthdate : Date ssn : Id Class Attributes An attribute is a named property of a class that describes the object being modeled. In the class diagram, attributes appear in the second compartment just below the name-compartment.

  43. Class Attributes (Cont’d) Attributes are usually listed in the form: attributeName : Type A derived attribute is one that can be computed from other attributes, but doesn’t actually exist. For example, a Person’s age can be computed from his birth date. A derived attribute is designated by a preceding ‘/’ as in: / age : Date Person name : String address : Address birthdate : Date / age : Date ssn : Id

  44. Class Attributes (Cont’d) Person Attributes can be: + public # protected - private / derived + name : String # address : Address # birthdate : Date / age : Date - ssn : Id

  45. Person name : String address : Address birthdate : Date ssn : Id eat sleep work play Class Operations Operations describe the class behavior and appear in the third compartment.

  46. PhoneBook newEntry (n : Name, a : Address, p : PhoneNumber, d : Description) getPhone ( n : Name, a : Address) : PhoneNumber Class Operations (Cont’d) You can specify an operation by stating its signature: listing the name, type, and default value of all parameters, and, in the case of functions, a return type.

  47. Person Person name : String birthdate : Date ssn : Id Person eat() sleep() work() play() Person name address birthdate eat play Depicting Classes When drawing a class, you needn’t show attributes and operation in every diagram. Person

  48. SmokeAlarm Responsibilities -- sound alert and notify guard station when smoke is detected. -- indicate battery state Class Responsibilities A class may also include its responsibilities in a class diagram. A responsibility is a contract or obligation of a class to perform a particular service.

  49. Relationships In UML, object interconnections (logical or physical), are modeled as relationships. There are three kinds of relationships in UML: • dependencies • generalizations • associations

  50. Dependency Relationships A dependency indicates a semantic relationship between two or more elements. The dependency from CourseSchedule to Course exists because Course is used in both the add and remove operations of CourseSchedule. CourseSchedule Course add(c : Course) remove(c : Course)