Download presentation
Presentation is loading. Please wait.
Published byLindsey Stokes Modified over 6 years ago
1
Unit 11 Generic Interfaces and Encapsulation, Continued
Kirk Scott
2
Corbel From Wikipedia, the free encyclopedia
Jump to: navigation, search For other uses, see Corbel (disambiguation). In architecture a corbel (or console) is a piece of masonry jutting out of a wall to carry any superincumbent weight. A piece of timber projecting in the same way was called a "tassel" or a "bragger".[1] The technique of corbelling, where rows of corbels deeply keyed inside a wall support a projecting wall or parapet, has been used since Neolithic times.[2] It is common in Medieval architecture and in the Scottish baronial style as well as in the Classical architectural vocabulary, such as the modillions of a Corinthian cornice and in ancient Chinese architecture.
6
This is an introductory unit.
These are the units/chapters belonging to this section of the course: Unit 12, Flyweight, book chapter 13 Unit 13, Decorator, book chapter 27 Unit 14, State, book chapter 22
7
What will be given next is an extremely brief overview of these topics.
Although the patterns are different from each other, they can be viewed as having this broad characteristic in common: They wrap up functionality in a desirable way In other words, they provide models for how to divide attributes and operations among classes in an overall design
8
Flyweight Book definition:
The intent of the Flyweight pattern is to use sharing to support large numbers of fine-grained objects efficiently. Comment mode on: It might be preferable to say “large numbers of references to a smaller set of fine-grained objects”, although there may also be a large number of objects Simple large-scale sharing is supported by making the shared object(s) immutable
9
Decorator Book definition:
The intent of Decorator is to let you compose new variations of an operation at runtime. Comment mode on: Although the term “compose” appears in the definition, the Decorator pattern is not related to the composite design pattern, which will be given later
10
The word compose describes nested construction where the resulting object contains a composite of functionalities In brief, nested construction refers to this idea: Subclasses contain instance variables that are of the type of one of their superclasses This came up in the proxy design pattern, where it proved less than ideal It is used in earnest in this design pattern
11
Command Book definition:
The intent of the Command pattern is to encapsulate a request in an object. Comment mode on: Informally, this pattern allows you to “pass a method”
12
You “pass a method” by creating a class containing the desired method, constructing an instance of the class, and passing that object as a parameter In the receiving code it is then possible to call the desired method on the object
13
State Book definition:
The intent of the State pattern is to distribute state-specific logic across classes that represent an object’s state Comment mode on: What this means is that a problem will be analyzed in terms of its states There will be a class for in the design for each state
14
The code for a particular state will occur only once, in a method for that state, rather than many times, in several different domain methods in a non-state design The practical goal and consequence of distributing or dividing logic among various state classes is to avoid needless repetition of code
15
In summary: Flyweight encapsulates the core, immutable characteristics of a kind of entity into a class so that references to instances of that class can be shared Decorator nests construction of objects of different classes, resulting in an object with a “concentric” set of functionalities
16
Command packages a method in a class so that it can be called elsewhere by passing an object that the method can be called on State subdivides functionality associated with states into different classes In one way or another, these patterns all have something to do with what belongs in a given class in a design.
17
These are my mnemonic devices for the patterns and their characteristics:
Flyweight: Immutable core Decorator: Nested construction, concentric function Command: Packaged, wrapped, passable method State: Subdivide design to support (state) transition
18
The End
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.