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 the classes, requiring a recompilation whenever prices change. Consider replacing this; read it from a database or from another configuration source (perhaps XML-based).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.134.151