项目作者: jvirico

项目描述 :
Examples of Decorator design pattern implemented in Java and Python.
高级语言: Python
项目地址: git://github.com/jvirico/pizza_decorator.git
创建时间: 2021-04-03T18:39:48Z
项目社区:https://github.com/jvirico/pizza_decorator

开源协议:MIT License

下载


Pizza and Decorator pattern

Examples of Decorator design pattern implemented in Java and Python [2]. The Java example uses the concept of pizza and pizza toppings to exemplify this pattern [3].

Decorator pattern

In object-oriented programming, decorator pattern is a flexible alternative to subclassing for extending funcionality. It allows to attach additional responsabilities to an object dynamically, without affecting the behaviour of other objects from the same class. It is often useful for adhering to the Single Responsibility Principle, as it allows functionality to be divided between classes with unique areas of concern. Decorator use can be more efficient than subclassing, because an object’s behavior can be augmented without defining an entirely new object [1].

\
Fig. 1 - UML class design of Decorator pattern.

Cite this work

  1. J. Rico, (2019) Decorator pattern examples in Java and Python.
  2. [Source code](https://github.com/jvirico/pizza_decorator)

References

[1] - Decorator Pattern Wikipedia\
[2] - SHVETS, Alexander. Dive Into Design Patterns. Refactoring. Guru, 2018.
\
[3] - PPCU, Budapest. Design Patterns