November 200491.3913 Ron McFadyen1 Composite Pattern A composite is a group of objects in which some...
-
Upload
meryl-green -
Category
Documents
-
view
212 -
download
0
Transcript of November 200491.3913 Ron McFadyen1 Composite Pattern A composite is a group of objects in which some...
November 2004 91.3913 Ron McFadyen 1
Composite Pattern
A composite is a group of objects in which some objects contain others; one object may represent groups, and another may represent an individual item, a leaf.
November 2004 91.3913 Ron McFadyen 2
Composite Pattern
Generic UML class diagram
Component
Operation()
Leaf
Operation()
Composite
Operation()Other()
*Client
November 2004 91.3913 Ron McFadyen 3
Composite Pattern
Consider the handout from Refactoring by Martin Fowler
•“Refactoring is the process of changing a software system in such a way that it does not alter the external behavior of the code yet improves its internal structure.”•P 76 Long Method:
•“object programs … short methods”•“the longer a procedure is, the more difficult it is to understand”•“A heuristic we follow is that whenever we feel the need to comment something, we write a method instead”•“How do you identify the clumps of code to extract? A good technique is to look for comments. They often signal a kind of semantic distance.”
November 2004 91.3913 Ron McFadyen 4
Composite Pattern
Refactoring by Martin Fowler
•Figure 4.1. The composite structure of tests
Test
TestSuite TestCase
FileReaderTester
junit.framework
*
November 2004 91.3913 Ron McFadyen 5
Composite Pattern
Junit is a testing framework for Java (If interested, see www.junit.org)
Any class that contains a test, must be subclassed from TestCase
Tests can be grouped into test suites
Pages 92-93 illustrate how to use junit to manage a suite of tests
We’ll look at an example for NextGenPOS