object oriented design
play

Object-Oriented Design Lecture 9: Generalization/Specialization - PowerPoint PPT Presentation

Object-Oriented Design Lecture 9: Generalization/Specialization Sharif University of Technology 1 Department of Computer Engineering Analysis Workflow: Analyze a Use Case The analysis workflow consists of the following activities:


  1. Object-Oriented Design Lecture 9: Generalization/Specialization Sharif University of Technology 1 Department of Computer Engineering

  2. Analysis Workflow: Analyze a Use Case • The analysis workflow consists of the following activities: • Architectural analysis • Analyze a use case • Outputs: • analysis classes • use case realizations • Analyze a class • Analyze a package 2 Sharif University of Technology

  3. Generalization • Generalization is a relationship between a more general thing and a more specific thing: • the more specific thing is consistent in every way with the more general thing. • the substitutability principle states that you can substitute the more specific thing anywhere the more general thing is expected. • generalization applies to all classifiers and some other modeling elements. 3 Sharif University of Technology

  4. Generalization/Specialization • Generalization hierarchies may be created by generalizing from specific things or by specializing from general things. 4 Sharif University of Technology

  5. Inheritance • Class inheritance is implicit in a generalization relationship between classes. • The subclass inherits the following features from its parents - attributes, operations, relationships, and constraints. 5 Sharif University of Technology

  6. Inheritance: Overriding • Subclasses may: • add new features; • override inherited operations: • the subclass provides a new operation with exactly the same signature as the parent operation it wishes to override; the operation signature consists of an operation name, types of all parameters in order, and return type. 6 Sharif University of Technology

  7. Abstract Operations and Classes • Abstract operations are designed to have no implementation: • they serve as placeholders; • all concrete subclasses must implement all inherited abstract operations. • An abstract class has one or more abstract operations: • abstract classes can't be instantiated; • abstract classes define a contract as a set of abstract operations that concrete subclasses must implement. 7 Sharif University of Technology

  8. Abstraction Level • all things at the same level in a generalization hierarchy should be at the same level of abstraction. 8 Sharif University of Technology

  9. Polymorphism • Polymorphism means "many forms". It allows you to design systems using an abstract class, then substitute concrete subclasses at runtime - such systems are very flexible and easy to extend; just add more subclasses. • Encapsulation, inheritance, and polymorphism are the "three pillars" of OO. 9 Sharif University of Technology

  10. Polymorphism: Example 10 Sharif University of Technology

  11. Polymorphism: Concrete Operations • Polymorphic operations have more than one implementation: • different classes may implement the same polymorphic (abstract/concrete) operation differently; • polymorphism allows instances of different classes to respond to the same message in different ways. 11 Sharif University of Technology

  12. Advanced Generalization: Generalization Sets • Generalization set - a set of subclasses organized according to a particular rule; constraints: • {complete} - generalization set contains all possible members; • {incomplete} - generalization set does not contain all possible members; • {disjoint} - an object may be an instance of no more than one of the members of the generalization set; • {overlapping} - an object may be an instance of more than one of the members of the generalization set; • {incomplete, disjoint} - the default. 12 Sharif University of Technology

  13. Generalization Sets: Implementation 13 Sharif University of Technology

  14. Generalization Sets: Example 14 Sharif University of Technology

  15. Reference • Arlow, J., Neustadt, I., UML 2 and the Unified Process: Practical Object- Oriented Analysis and Design , 2 nd Ed. Addison-Wesley, 2005. 15 Sharif University of Technology

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend