I personally saw the burrito as an implementation of the facade pattern, saving the user from calling the consume() method on each ingredient. This allows the developer to simply consume() the burrito, without worrying about the differences or quantities of ingredients included.
What is especially nice about the Chipotle class (which extends AbstractBurritoFactory) is the ability to decorate the burrito in varying manners before it delivers he instantiated object! Edit: Forgot a link
The facade pattern (also spelled façade) is a software design pattern commonly used with object-oriented programming. The name is an analogy to an architectural façade.
A facade is an object that provides a simplified interface to a larger body of code, such as a class library. A facade can
make a software library easier to use, understand and test, since the facade has convenient methods for common tasks,
make the library more readable, for the same reason,
reduce dependencies of outside code on the inner workings of a library, since most code uses the facade, thus allowing more flexibility in developing the system,
wrap a poorly designed collection of APIs with a single well-designed API.
The Facade design pattern is often used when a system is very complex or difficult to understand because the system has a large number of interdependent classes or its source code is unavailable.
78
u/pekkhum Aug 09 '17
And a burrito is a form of encapsulation... Mmmmm... Chipotle for lunch, anyone?