YALE UNIVERSITY
DEPARTMENT OF COMPUTER SCIENCE
CPSC 427a: Object-Oriented Programming | Handout #9 | |
Professor M. J. Fischer | December 1, 2010 | |
Study Guide to Exam 2
For the exam, you are responsible for everything covered by exam 1 (see Study Guide to Exam 1) as well as the following materials covered since that exam: the contents of lectures 12–22 and corresponding class demos, the concepts used in problem set 4, and the entire textbook (Chapters 1–18) except for the following sections:
Below is an index to the lecture notes. It lists all of the sections, subsections, and slide titles from lectures 12–22.
∙ Accessing B in A’s methods
∙ “Law” of Consistency/Encapsulation
∙ “Law” of Demeter
∙ “Law” of Demeter
∙ Design Exercise: FamilyDatebook
∙ Model-Viewer-Controller design paradigm
∙ Realtime measurements
∙ Realtime measurements
∙ HirezTime class
∙ HirezTime class structure
∙ StopWatch class
∙ Hangman game
∙ Overall design
∙ Use cases
∙ Code structure: Model
∙ Code structure: Viewer and controller
∙ Class Game
Storage management13 ∙ String store
∙ Refactored hangman game
∙ Flex arrays
∙ Flex array implementation issues
∙ String store limitation
∙ Refactored hangman game
∙ Flex arrays
∙ Flex array implementation issues
∙ String store limitation
∙ Refactoring Board class
∙ Get and set functions
∙ Coping with privacy problems
∙ Type safety
∙ Casts in C
∙ Different kinds of casts
∙ C++ casts
∙ Explicit cast syntax
∙ Implicit casts
∙ Ambiguity
∙ explicit keyword
∙ How to define operator extensions
∙ Other special cases
∙ Virtual virtue
∙ Main virtue
∙ Using polymorphism
∙ Interface file
∙ Class Linear
∙ Example: Stack
∙ Example: Queue
∙ Class structure
∙ C++ features
∙ #include structure
∙ Template overview
∙ Template functions
∙ Specialization
∙ Template classes
∙ Compilation issues
∙ Template parameters
∙ Using template classes
∙ What is multiple inheritance
∙ Object structure
∙ Diamond pattern
∙ Tightly coupled classes
∙ Example: List and Cell
∙ Circularity with #include
∙ What happens?
∙ Resolving circular dependencies
∙ 16-Multiple-template
∙ Container class hierarchy
∙ Item class hierarchy
∙ Ordered template class
∙ Alternative Ordered interfaces
∙ A bit of history
∙ Containers
∙ Common container operations
∙ vector<T>
∙ Iterators
∙ Iterator example
∙ Using iterator inside a class
∙ Using subscripts and size()
∙ Algorithms
∙ STL sort algorithm
∙ Reverse sort example
∙ Reverse sort example (cont.)
∙ pair<T1, T2>
∙ map<Key,Val>
∙ Using a map<Key,Val>
∙ Copying from one container to another
∙ Copying from one container to another – example
∙ string class
∙ Derivation from STL containers
∙ Replacing authority with understanding
∙ Two kinds of derivation
∙ How are they the same?
∙ What is simple derivation good for?
∙ What are the problems with simple derivation?
∙ What is polymorphic derivation good for?
∙ What are the problems of polymorphic derivation?
∙ Contrasts between simple and polymorphic derivation
∙ Containment as an alternative to simple derivation
∙ Argument for containment
∙ STL container as a base class
∙ Can I turn an STL container into a polymorphic base class?
∙ A polymorphic base class
∙ Dynamic cast
∙ Exceptions
∙ Exception handling
∙ C-style solution using status returns
∙ C++ exception mechanism
∙ C++ exception mechanism (recall)
∙ Throwing an exception
∙ Catching an exception
∙ What kind of object should an exception throw?
∙ Standard exception class
∙ Catching standard exceptions
∙ Deriving your own exception classes from std::exception
∙ Multiple catch blocks
∙ Rethrow
∙ Throw restrictions
∙ Uncaught exceptions: Ariane 5
∙ Uncaught exceptions: Ariane 5 (cont.)
∙ Termination
∙ General OO principles
∙ What is a design pattern?
∙ Adaptor pattern
∙ Adaptor diagram
∙ Indirection
∙ Proxy pattern
∙ Polymorphism pattern
∙ Polymorphism diagram
∙ Controller
∙ Three kinds of controllers
∙ Bridge pattern
∙ Bridge diagram
∙ Subject-Observer or Publish-Subscribe: problem
∙ Subject-Observer or Publish-Subscribe: pattern
∙ Subject-Observer or Publish-Subscribe: diagram
∙ Singleton pattern
∙
∙ Reusability, Flexibility, and Maintainability
∙ The Waterfall Software Process
∙ Why a Pure Waterfall Process is Usually Not Practical
∙ The Spiral Process
∙ Advantage of OO Design
∙ Aspect of Reusability
∙ Making a Class Re-usable
∙ Reducing Dependency Among Classes
∙ Aspect of Flexibility
∙ Some Techniques to Achieve Flexibility
∙ Roadmap
∙ What is a Design Pattern
∙ UML/OMT Notation
∙ Example: Duck Game
∙ Initial Design
∙ Design Change: add fly()
∙ Problem
∙ Anticipating Changes
∙ Handling Varying Behaviors
∙ Design
∙ Programming to implementation vs. interface/supertype
∙ Implementation
∙ Exercise
∙ The Strategy Pattern
∙ Exercise (UML diagram)
∙ Summary: Design Principles
∙ Example: KitchenViewer Interface
∙ KitchenViewer Example
∙ Selecting Antique Style
∙ KitchenViewer Using Standard Inheritance
∙ The Abstract Factory Idea
∙ Abstract Factory Design Pattern Applied to KitchenViewer
∙ Abstract Factory Design Pattern
∙ Concrete and Abstract Layers
∙ Abstract Factory Application Sequence Diagram
∙ Potential use of this Design Pattern?
∙ References
∙ Example: Starbuzz Coffee
∙ Problem
∙ Problem (UML diagram)
∙ Attempt 1
∙ Potential Changes
∙ Design idea
∙ Design approach 1
∙ Decorator design
∙ Decoration Delegation Process
∙ Decorator Class Model
∙ Sequence Diagram for Decorator
∙ Decoration Features
∙ Exercise
∙ Some Common Design Patterns
∙ Example: Weather-O-Rama
∙ Weather-O-Rama
∙ Weather-O-Rama Interface
∙ First Implementation
∙ Observer Pattern
∙ Observer Design Pattern
∙ How does Observer apply these design principles?
∙ Discussion
∙ User Interfaces
∙ Interfaces for C++
∙ Overall Structure of a GUI
∙ Concurrency and Events
∙ Event Loop
∙ A GUI event structure
∙ Interface between user and system code
∙ Binding system calls to user functions
∙ Polymorphic binding
∙ Binding through callback registration
∙ Callback using function pointers: GUI side
∙ Callback using function pointer: User side
∙ Type safety
∙ Signals and slots
∙ Structure of gtkmm
∙ Compiling a gtkmm program
∙ Linking a gtkmm program
∙ Using a GUI
∙ Example: clock
∙ Main program