29.11.2014 Views

Smalltalk and Object Orientation: an Introduction - Free

Smalltalk and Object Orientation: an Introduction - Free

Smalltalk and Object Orientation: an Introduction - Free

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

21. Frameworks <strong><strong>an</strong>d</strong> Patterns for <strong>Object</strong> Oriented<br />

Design<br />

21.1 <strong>Introduction</strong><br />

Designing complex software systems is hard. It is a great deal easier to reuse <strong>an</strong> existing software<br />

system, merely modifying it where necessary, th<strong>an</strong> to build it from scratch. These two facts have led to<br />

a great deal of interest in what has become termed software frameworks in the object oriented<br />

community. A software framework is “the reusable design of a system or a part of a system expressed<br />

as a set of abstract classes [<strong><strong>an</strong>d</strong> concrete classes] <strong><strong>an</strong>d</strong> the way inst<strong>an</strong>ces of (subclasses of) those classes<br />

collaborate” [Beck <strong><strong>an</strong>d</strong> Johnson 1994]. However such frameworks are notoriously difficult to document.<br />

For example the Model View Controller (MVC) framewo rk in <strong>Smalltalk</strong> is very powerful, but it has<br />

proved difficult to explain in a clear <strong><strong>an</strong>d</strong> simple m<strong>an</strong>ner how the MVC should be used [Krasner <strong><strong>an</strong>d</strong><br />

Pope 1988].<br />

In the object oriented community a number of researchers have explored the work of <strong>an</strong> architect<br />

who d esigned a l<strong>an</strong>guage for encoding knowledge of the design <strong><strong>an</strong>d</strong> construction of buildings<br />

[Alex<strong><strong>an</strong>d</strong>er et al 1977, Alex<strong><strong>an</strong>d</strong>er 1979]. The knowledge is described in terms of patterns which capture<br />

both a recurring architectural arr<strong>an</strong>gement <strong><strong>an</strong>d</strong> a rule for how <strong><strong>an</strong>d</strong> wh en to apply this knowledge. That<br />

is, they incorporate knowledge about the design as well as the basic design relations.<br />

The result is that there is now a growing community exploring how software frameworks c<strong>an</strong> be<br />

documented using (software) design patterns (for example, [Johnson 1992] <strong><strong>an</strong>d</strong> [Birrer <strong><strong>an</strong>d</strong><br />

Eggenschmiler 1993]). Johnson’s paper describes the form that these design patterns take <strong><strong>an</strong>d</strong> the<br />

problems encountered in applying them.<br />

The remainder of the chapter is structured in the following m<strong>an</strong>ner: Sectio n two considers what a<br />

framework is <strong><strong>an</strong>d</strong> the role of patterns in documenting frameworks. Section three introduces the<br />

HotDraw framework <strong><strong>an</strong>d</strong> Section four presents a very simple pattern documenting how you c<strong>an</strong> use<br />

HotDraw to construct a simple editor.<br />

21.2 Patterns <strong><strong>an</strong>d</strong> frameworks<br />

21.2.1 What is a framework?<br />

A framework is a reusable design of a program or a part of a program expressed as a set of classes. That<br />

is, a framework is a set of prefabricated software building blocks that programmers c<strong>an</strong> use, extend, or<br />

customize for specific computing solutions. With frameworks, software developers don’t have to start<br />

from scratch each time they write <strong>an</strong> application. Frameworks are built from a collection of objects, so<br />

both the design <strong><strong>an</strong>d</strong> code of a framework m ay be reused. However frameworks are not necessarily easy<br />

to design or implement. Questions such as “how much will it cost” to produce a framework <strong><strong>an</strong>d</strong> “how<br />

much will we benefit” from the network are difficult to <strong>an</strong>swer [Moser <strong><strong>an</strong>d</strong> Nierstrasz 1996]. In addition<br />

reusing frameworks instead of libraries c<strong>an</strong> cause subtle architectural ch<strong>an</strong>ges in <strong>an</strong> application calling<br />

for innovative m<strong>an</strong>agement [Sparks, Benner <strong><strong>an</strong>d</strong> Faris, 1996].<br />

Frameworks c<strong>an</strong> provide solutions to different types of problem domain. These include a pplication<br />

frameworks, domain frameworks <strong><strong>an</strong>d</strong> support frameworks:<br />

• Application frameworks encapsulate expertise applicable to a wide variety of programs. These<br />

frameworks encompass a horizontal slice of functionality that c<strong>an</strong> be applied across client<br />

domains. An application framework might provide the basic facilities of a payroll system, or a<br />

171

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!