CHAPTER 21 Testing Advanced Program Architectures
WHAT’S IN THIS CHAPTER?
- Learning how the Observer Pattern leads to loosely coupled code
- Improving the reliability of the Observer Pattern with argument checking
- Coding a game using the Mediator Pattern
- Using the Interface Segregation Principle to simplify development with the Mediator Pattern
- Unit-testing a mediator and its colleagues
WROX.COM CODE DOWNLOADS FOR THIS CHAPTER
The wrox.com code downloads for this chapter are found at www.wrox.com/go/reliablejavascript
on the Download Code tab. The files are in the Chapter 21 download and individually named according to the filenames noted throughout this chapter.
Most programs you have written were probably written to achieve some goal. The architecture may have been the conventional, top-down variety that you learned along with object-oriented programming. The architectures you will consider in this chapter are different. They allow independent parts to interact in a decentralized manner. The overall goal happens as if by magic.
The patterns in question are known as the Observer and Mediator. They are similar in that they are decentralized, but the means of communication differ.
ENSURING RELIABLE USE OF THE OBSERVER PATTERN
If you’ve subscribed to daily newspaper delivery, you’ve participated in a real-life implementation of the Observer Pattern. By sending your subscription card to the newspaper publisher, you alerted the publisher that you would like to have ...
Get Reliable JavaScript: How to Code Safely in the World's Most Dangerous Language now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.