PHP Objects, Patterns and Practice (3rd edition)
CHAPTER 9 ■ GENERATING OBJECTS Figure 9-7. An abstract creator and its abstract products Implementation The abstract CommsManage ...
CHAPTER 9 ■ GENERATING OBJECTS function getFooterText() { return "BloggsCal footer\n"; } } Figure 9-8. Adding a concrete creator ...
CHAPTER 9 ■ GENERATING OBJECTS Figure 9-9. Adding concrete creators and some concrete products Consequences So what does this pa ...
CHAPTER 9 ■ GENERATING OBJECTS abstract class CommsManager { const APPT = 1; const TTD = 2; const CONTACT = 3; abstract function ...
CHAPTER 9 ■ GENERATING OBJECTS The Problem Imagine a Civilization-style web game in which units operate on a grid of tiles. Each ...
CHAPTER 9 ■ GENERATING OBJECTS class Sea {} class EarthSea extends Sea {} class MarsSea extends Sea {} class Plains {} class Ear ...
CHAPTER 9 ■ GENERATING OBJECTS object state when you generate new products. Imagine that Sea objects have a $navigability proper ...
CHAPTER 9 ■ GENERATING OBJECTS But That’s Cheating! I promised that this chapter would deal with the logic of object creation, d ...
CHAPTER 9 ■ GENERATING OBJECTS public function getCommsManager() { return $this->commsManager; } } The AppConfig class is a s ...
CHAPTER 9 ■ GENERATING OBJECTS ...
C H A P T E R 10 ■ ■ ■ Patterns for Flexible Object Programming With strategies for generating objects covered, we’re free now t ...
■Chapter 10: Patterns for Flexible Object Programming............................................................... The Composi ...
CHAPTER 10 ■ PATTERNS FOR FLEXIBLE OBJECT PROGRAMMING function bombardStrength() { $ret = 0; foreach( $this->units as $unit ) ...
CHAPTER 10 ■ PATTERNS FOR FLEXIBLE OBJECT PROGRAMMING Implementation The Composite pattern defines a single inheritance hierarch ...
CHAPTER 10 ■ PATTERNS FOR FLEXIBLE OBJECT PROGRAMMING function removeUnit( Unit $unit ) { $this->units = array_udiff( $this-& ...
CHAPTER 10 ■ PATTERNS FOR FLEXIBLE OBJECT PROGRAMMING function bombardStrength() { return 4; } } I do not want to make it possib ...
CHAPTER 10 ■ PATTERNS FOR FLEXIBLE OBJECT PROGRAMMING Often you really see the benefit of a pattern only from the client’s persp ...
CHAPTER 10 ■ PATTERNS FOR FLEXIBLE OBJECT PROGRAMMING Notice the new getComposite() method. I will return to this in a little wh ...
CHAPTER 10 ■ PATTERNS FOR FLEXIBLE OBJECT PROGRAMMING Figure 10–2. Moving add/remove methods out of the base class The annoying, ...
CHAPTER 10 ■ PATTERNS FOR FLEXIBLE OBJECT PROGRAMMING will determine the kinds of assumptions you can make when you design metho ...
«
5
6
7
8
9
10
11
12
13
14
»
Free download pdf