Chapter 11: Object-Oriented Design

 < Day Day Up > 



11.1 Introduction

The first nine chapters of the book discussed how to structure the objects in a problem, and Chapter 10 addressed how to organize the relationships between objects for utility objects. The discussion in Chapter 10 suggested that composition should always be preferred over classification when designing and constructing utility objects; however, most objects used in a program are not utility objects but represent parts of the problem definition. When the objects are part of the problem definition, should composition or classification be used when constructing an object?

The choice of composition or classification can normally be determined by answering the question, "Is the relationship between the objects an 'is-a' or a 'has-a' relationship?" "Is-a" relationships are always implemented with classification, and "has-a" relationships are implemented with composition. This simple test is often used by designers as an acid test to determine if objects should be constructed by composition or classification. This chapter argues that as with any simple test it is simply not powerful enough to be applied indiscriminately. Care must be taken to consider the results of an "is-a" or "has-a" test in light of the context. How are the objects used in the problem definition? Do object design criteria other than if the relationship is one of "is-a" or "has-a" affect the choice between composition or classification? Do considerations involving how the program needs to be implemented impact the choice of composition or classification?

This chapter looks at how to construct objects that are part of the problem definition. It first looks at how to apply "is-a" and "has-a" relationships to the design of a program. It then examines how the problem and program contexts must be considered before implementing the design.



 < Day Day Up > 



Creating Components. Object Oriented, Concurrent, and Distributed Computing in Java
The .NET Developers Guide to Directory Services Programming
ISBN: 849314992
EAN: 2147483647
Year: 2003
Pages: 162

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