Pizza Inversion - a Pattern for Efficient Resource Consumption

by Brad Appleton <brad@bradapp.net>
http://www.bradapp.net/
last modified 02/12/1999

© 1995-1999 by Brad Appleton. All rights reserved.

Pizza Inversion may sound like a cheesy name for a pattern, but it describes a recurring solution to a problem that is of fundamental significance to most software developers I know. I find myself using it much more frequently than anything in the now famous Design Patterns book[1]. Keep reading and I'm certain you'll soon find yourself agreeing with me.


Pizza Inversion Object Consumptional

Intent

Efficiently internalize the external state of multiple hot pizza slices, while encapsulating thermodynamic heat-transfer and minimizing the latency time to access the pizza's surface.

Also Known As

Pizza Sandwich

Motivation

One of the more significant problems faced by software engineers revolves around the need for nutritional sustenance while maintaining personal productivity. The impossibly hectic schedules of most software development projects demands that developers spend more time developing software than satisfying their hunger. At the same time, developers need food to remain healthy, alert, and productive. There is even anecdotal evidence to suggest this factor is sometimes more important than sleep.

The consumption of pizza (often in a group setting) is a commonly pursued remedy for addressing this important issue. Pizza often tastes, and smells, better than more traditional "fast foods," and is very rich in dairy-content and carbohydrates. Also, it is usually delivered, so you don't have to wait in line to order your food, or for it to be prepared and brought to your table.

Because efficiency and scheduling are always important concerns, developers frequently need to consume multiple slices of round pizza in a short period of time. The tomato sauce tends to be very hot, however, and the cheese on top of it adds to the problem by forming an insulating layer that locks in the heat. To make matters worse, cheese contains non-negligible levels of fat and, when melting, forms pockets of grease which can reach exceedingly high temperatures (a condition aggravated by fatty toppings like ground beef, pepperoni, and Italian sausage).

When trying to eat pizza quickly, the grease on the cheese and the hot tomato sauce underneath can severely burn the roof of one's mouth. This is not only painful, but may also damage the taste buds in this sensitive region of the mouth, rendering them useless for a short duration.

The naive approach of waiting for the pizza to cool may at first seem reasonable. But the resultant increase in the latency-time between when the pizza arrives and when it has cooled enough for human consumption imposes an unacceptable performance penalty that impedes programmer productivity.

Therefore, it is desirable to find a method for eating the pizza quickly without burning one's mouth. At the same time, one still wants to experience the full splendor that comes from the taste and smell of a savory pizza fresh from the oven.

One such method involves inverting one slice of pizza on top of another slice:

By inverting one of the pizza slices as shown above, the resulting design structure forms a layered hierarchy in which the crust encapsulates the cheese, sauce, and toppings from the top and bottom of the mouth. This insulates the mouth from the hot cheese and sauce while permitting the pizza to be consumed at approximately twice the usual rate.

Applicability

Use Pizza Inversion when:

Structure

Participants

Collaborations

Consequences

Implementation

Consider the following issues when applying the Pizza Inversion pattern:
  1. Data Compression and Loss: One needs to be extra careful when using only a single slice and/or when the pizza has extra cheese because then excess cheese can easily ooze out the side and burn your mouth. In this case, use your Hands to press the pieces (or halves) together to and detach the excess Cheese, Toppings, and Sauce, before inserting into Mouth.

  2. Singleton Slice: If you have a single slice of pizza you can envision an imaginary line lengthwise down the center of the slice that divides it into two symmetrical halves. Fold one half of the slice over (and on top of) the other half. Another variation that works with a single slice (assuming you have a round pizza) is to fold the pointed end of the slice towards the crust end. You don't get full slice coverage this way but some have expressed a preference for this particular implementation.

  3. Olfactory Method: One of the desirable aspects of eating pizza isn't just the taste, but also the smell of the steaming hot cheeses, toppings, and fresh-baked crust. Folding one slice over another slice lessens the effect of this pleasing olfactory sensation. One commonly employed compromise is to take a brief moment at the very beginning to fully enjoy the sight and smell of the pizza before commencing with its consumption. Spend a good half-minute or so observing and inhaling the full sight and aroma of the tomatoes, mozzarella, fresh basil, garlic, onion and other spices, and all of the toppings. Once the visual and olfactory organs have been used to employ Observer[1] and Reflection[2] for the non-oral aspects of your pizza-eating experience, begin folding and then consuming the PizzaSlices promptly thereafter. This imposes a small but tolerable performance penalty due to increased latency-time prior to oral access.

  4. Multi-Slicing: A number of adjacent and attached slices may be folded over onto an equivalent number of adjacent slices. Hence one could fold two pieces onto two pieces, three pieces onto three pieces, and so on. For "individual size" pizzas, simply fold the entire half of the pizza over onto the other half.

  5. Mix-In Slices: This works particularly well for collaborations involving large numbers of consuming objects. Rather than trying to satisfy each Consumer's favorite combination of Toppings, simply order relatively few Toppings on each pizza and let each Consumer use PizzaSlices from different pizzas to create their own custom configuration of Toppings.

Known Uses

The historical origins influencing this method of pizza consumption may be traced back to the "Pita" and the Earl of Sandwich.

Related Patterns

Acknowledgements

References

[1] E. Gamma, R. Helm, R. Johnson, J. Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software, Addison-Wesley, Reading, MA, 1995.
[2] F. Buschmann, R. Meunier, H. Rohnert, P. Sommerlad, M. Stal. Pattern-Oriented Software Architecture: A System of Patterns, John Wiley and Sons, New York, NY, 1996.
[3] Hans Rohnert. personal correspondence, August 1997.