It is important from the view point of separation of concerns to separate optional features from core features of classes. The decorator pattern is a major technique to achieve this in single inheritance object-oriented programming languages such as Java. There are also more advanced techniques for modularity such as multiple inheritance, mixins, traits, incomplete objects and aspect-, feature- and delta-oriented programming. This direction is helpful for implementors of classes in the sense that it helps to avoid code duplication. It however makes the use of the classes complicated because one has to pick up and compose the modules that provides optional features with the modules that provides core features manually. We propose decorators as a solution to the problem. Decorators are a simple extension of mixins. One of the important differences of decorators from mixins is automatic composition: decorators are intended to be composed with classes automatically by infering the set of decorators from the use of objects, which we call decoration inference. This paper sketches and demonstrates decorators and decoration inference through simple and small examples. It also gives and discusses issues to realize decorators.
Mon 31 Oct Times are displayed in time zone: Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna change
15:40 - 17:20
Patrick DubroyY Combinator Research, USAPre-print
|Towards Automatic Decoration|