Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and Addison-Wesley was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. Figures on pages 26 and 28 (top figure) of this book were previously published on pages 108 and 164 of Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, and John M. Vlissides. Copyright 1995 by Pearson Education, Inc. Republished by permission of Pearson Education, Inc., Publishing as Pearson Addison-Wesley. Excerpted text on pages 3 and 4 was previously published in Pattern Languages of Program Design 3 by Robert Martin, Dirk Riehle, and Frank Buschmann (Addison-Wesley, 1998). Republished by permission. All rights reserved. The publisher offers discounts on this book when ordered in quantity for bulk purchases and special sales. For more information, please contact: U.S. Corporate and Government Sales (800) 382-3419 corpsales@pearsontechgroup.com For sales outside of the U.S., please contact: International Sales (317) 581-3793 international@pearsontechgroup.com Visit Addison-Wesley on the Web: www.awprofessional.com Library of Congress Cataloging-in-Publication Data Kerievsky, Joshua. Refactoring to patterns / Joshua Kerievsky. p. cm. (Addison-Wesley signature series) ISBN 0-321-21335-1 1. Software refactoring. 2. Software patterns. I. Title. II. Series. QA76.76.R42K47 2004 005.1'6dc22 2004012166 Copyright © 2005 by Pearson Education, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form, or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior consent of the publisher. Printed in the United States of America. Published simultaneously in Canada. For information on obtaining permission for use of material from this work, please submit a written request to: Pearson Education, Inc. Rights and Contracts Department 75 Arlington Street, Suite 300 Boston, MA 02116 Fax: (617) 848-7047 Text printed on recycled paper 1 2 3 4 5 6 7 8 9 10CRW0807060504 First printing, July 2004 Dedication For Tracy, Sasha, and Sophia |