Section 10.1. INTRODUCTION


10.1. INTRODUCTION

One approach to reducing the cost of software is to make software easier to reuse. Doing so reduces the risk and expense of developing new applications. The ability to reuse code depends on two properties: modularity and easy composition. Modularity allows us to separate concerns [26], making code easier to understand, maintain, and treat as a unit. Easy composition allows us to combine the capabilities of different code modules in different applications.

Unfortunately, today's object-oriented languages, such as Java, are limited in their ability to modularize and compose code. Modularity is limited because the basic unit of encapsulation and reuse is the class. Once the organization of a class hierarchy is fixed, it is always possible to define new features whose implementations crosscut the existing set of classes. For example, it is common for features that add global properties, such as security, thread safety, fault tolerance, or performance constraints, to affect code in multiple classes. It is difficult to encapsulate such features in a single class. Instead, object-oriented programs generally consist of sets of collaborating classes [16], and changes to one class often require coordinated changes to others.

Current object-oriented languages are also limited in their ability to compose features. Java's support for composition depends primarily on single inheritance and subtype polymorphism. These mechanisms do not scale well when there are a large number of features. For example, there are three possible ways to organize two features, A and B, into classes (see Figure 10-1): (1) put them in the same class, (2) make A a subclass of B, or (3) make B a subclass of A.

Figure 10-1. Organizing features in classes.


Each choice has different implications regarding the composition of A and B. For example, the first two choices force B to be included whenever A is included. Thus, by forcing the programmer to choose a single fixed class hierarchy, Java makes it difficult to compose a collection of features in an orthogonal manner. As the number of features grows, this problem becomes more severe, because the number of possible feature combinations grows rapidly, but the number of feature combinations that can be practically supported does not.

This chapter describes how mixins [9], a kind of generic type, can improve the flexibility of Java class hierarchies, thereby improving the ability to modularize code and compose features. The purpose of this chapter is threefold. First, we provide an introduction to mixin programming. We describe our mixin extension to Java and the additional language support that we implemented to increase the effectiveness of programming with mixins. Second, to give a concrete example, we summarize our previously published evaluation [13] of how mixins allow us to build customizable GUI libraries. In particular, we explain how a nested form of mixins, called mixin layers [27, 28], can be used to implement a configurable GUI that runs on platforms with widely dissimilar capabilities, such as cell phones, PDAs, and PCs. We also show how mixin layers support the implementation of crosscutting features, so mixinlayers can be thought of as aspects [23]. Third, we propose a new approach of integrating mixins into object-oriented type systems and a new way of reconciling the implementation tradeoffs inherent in parametric polymorphism.



Aspect-Oriented Software Development
Aspect-Oriented Software Development with Use Cases
ISBN: 0321268881
EAN: 2147483647
Year: 2003
Pages: 307

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net