Historically, the painter was responsible for the mixing of the paint; keeping a ready supply of pigments, oils, thinners and driers. The painter would use his experience to determine a suitable mixture depending on the nature of the job. In modern times, the painter is primarily responsible for preparation of the surface to be painted, such as patching holes in drywall, using masking tape and other protection on surfaces not to be painted, applying the paint and then cleaning up.
Now, assume one also desires the ability to add borders to windows. Again, the original Window class has no support. The ScrollingWindow subclass now poses a problem, because it has effectively created a new kind of window. If one wishes to add border support to many but not all windows, one must create subclasses WindowWithBorder and ScrollingWindowWithBorder etc. This problem gets worse with every new feature or window subtype to be added. For the decorator solution, we simply create a new BorderedWindowDecorator—at runtime, we can decorate existing windows with the ScrollingWindowDecorator or the BorderedWindowDecorator or both, as we see fit. Notice that if the functionality needs to be added to all Windows, you could modify the base class and that will do. On the other hand, sometimes (e.g., using external frameworks) it is not possible, legal, or convenient to modify the base class.
Writing a class decorator is very similar to writing a function decorator. The only difference is that the decorator will receive a class and not a function as an argument. In fact, all the decorators you saw above will work as class decorators. When you are using them on a class instead of a function, their effect might not be what you want. In the following example, the @timer decorator is applied to a class:
Color, made up of hue, saturation, and value, dispersed over a surface is the essence of painting, just as pitch and rhythm are the essence of music. Color is highly subjective, but has observable psychological effects, although these can differ from one culture to the next. Black is associated with mourning in the West, but in the East, white is. Some painters, theoreticians, writers and scientists, including Goethe, Kandinsky, and Newton, have written their own color theory.