O'Reilly logo

Joy of Patterns: Using Patterns for Enterprise Development, The by Brandon Goldfedder

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Summary

Whenever you use a decorator, be careful not to misuse; the number of function calls and complexity might be an issue in some domains. Be sure to determine if a strategy pattern (see GOF), often combined with a composite (also GOF), might be a better choice for altering sets of algorithms.

Here are some other things to think about:

  • If we wished to add a new ChickenBurger type, how much of an impact to the existing system would result? How many toppings would it support? Compare this to the pure inheritance way to solve the problem.

  • When I put together this problem, I considered making the meat patty itself a topping. What are the pros and cons to this approach?

  • One problem with this solution is that the pricing factors are hardcoded into ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required