Design Patterns: Difference between revisions

Content deleted Content added
Yoderj (talk | contribs)
Criticism: Bring Paul Graham quote references together.
m Introduction: Unbold
Line 32:
Chapter 1 is a discussion of [[object-oriented]] design techniques, based on the authors' experience, which they believe would lead to good object-oriented software design, including:
 
* "Program to an 'interface', not an ''''implementation''''." (Gang of Four 1995:18)
* [[Composition over inheritance]]: "Favor '[[object composition]]' over '[[Inheritance (computer science)|class inheritance]]'." (Gang of Four 1995:20)
 
Line 56:
To the authors, 'delegation' is an extreme form of object composition that can always be used to replace inheritance. Delegation involves two objects: a 'sender' passes itself to a 'delegate' to let the delegate refer to the sender. Thus the link between two parts of a system are established only at runtime, not at compile-time. The [[Callback (computer science)|Callback]] article has more information about delegation.
 
The authors also discuss so-called '''parameterized types''', which are also known as [[Generic programming|generics]] (Ada, Eiffel, [[Generics in Java|Java]], C#, VB.NET, and Delphi) or templates (C++). These allow any type to be defined without specifying all the other types it uses—the unspecified types are supplied as 'parameters' at the point of use.
 
The authors admit that delegation and parameterization are very powerful but add a warning:
Line 62:
:"Dynamic, highly parameterized software is harder to understand and build than more static software." (Gang of Four 1995:21)
 
The authors further distinguish between '[[Object composition#Aggregation|Aggregation]]', where one object 'has' or 'is part of' another object (implying that an aggregate object and its owner have identical lifetimes) and '''acquaintance''', where one object merely 'knows of' another object. Sometimes acquaintance is called 'association' or the 'using' relationship. Acquaintance objects may request operations of each other, but they aren't responsible for each other. Acquaintance is a weaker relationship than aggregation and suggests much [[Loose coupling|looser coupling]] between objects, which can often be desirable for maximum maintainability in a design.
 
The authors employ the term 'toolkit' where others might today use 'class library', as in C# or Java. In their parlance, toolkits are the object-oriented equivalent of subroutine libraries, whereas a '[[Software framework|framework]]' is a set of cooperating classes that make up a reusable design for a specific class of software. They state that '''applications''' are hard to design, '''toolkits''' are harder, and '''frameworks''' are the hardest to design.
 
==Case study==