160 likes | 280 Views
Generic Interfaces and Encapsulation, Continued. Kirk Scott. Corbel From Wikipedia, the free encyclopedia. Jump to: navigation , search For other uses, see Corbel (disambiguation ) .
E N D
CorbelFrom Wikipedia, the free encyclopedia • Jump to: navigation, searchFor 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.
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
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
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
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
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
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
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
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
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.
These are my mnemonic devices for the patterns and their characteristics: • Flyweight: Immutable core • Decorator: Nested construction, concentric function—Big fish eats little fish (stay tuned) • State: Subdivide design to support (state) transition