The Evolutionary Nature of Professional Software Development
Total Page:16
File Type:pdf, Size:1020Kb
Emergent Design This page intentionally left blank Emergent Design The Evolutionary Nature of Professional Software Development Scott L. Bain Upper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid Capetown • Sydney • Tokyo • Singapore • Mexico City Illustrations by Andrea Chartier Bain 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 the publisher was aware of a trademark claim, the designa- tions 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 war- ranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or con- sequential damages in connection with or arising out of the use of the information or programs contained herein. The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact: U.S. Corporate and Government Sales (800) 382-3419 [email protected] For sales outside the United States please contact: International Sales [email protected] Visit us on the Web: informit.com/aw Library of Congress Cataloging-in-Publication Data Bain, Scott L. Emergent design : the evolutionary nature of professional software development / Scott L. Bain. p. cm. Includes index. ISBN 978-0-321-50936-9 (hardcover : alk. paper) 1. Computer software—Development. 2. Computer software—Development—Vocational guidance. I. Title. QA76.76.D47B345 2008 005.1—dc22 2007050637 Copyright © 2008 Pearson Education, Inc. All rights reserved. Printed in the United States of America. This publication is protected by copyright, and per- mission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, write to: Pearson Education, Inc Rights and Contracts Department 501 Boylston Street, Suite 900 Boston, MA 02116 Fax: (617) 671-3447 ISBN-13: 978-0-321-50936-9 ISBN-10: 0-321-50936-6 Text printed in the United States on recycled paper at Courier in Westford, Massachusetts. First printing, March 2008 To Alan Shalloway and all instructors and staff at Net Objectives, whose collegial support and innovative ideas have contributed endlessly to my development as a technologist and educator. And . To Andrea and Griffin, who have enriched my entire life, and for whom I do pretty much everything I do. This page intentionally left blank Contents Series Foreword ___________________________________________________________xvii Preface _____________________________________________________________________xxiii Acknowledgments ________________________________________________________xxix About the Author__________________________________________________________xxxi Chapter 1 Software as a Profession___________________________________1 How Long Have Human Beings Been Making Software?________________1 What Sort of Activity Is Software Development? ______________________2 What Is Missing? __________________________________________________6 Who Is Responsible? _______________________________________________8 Uniqueness _______________________________________________________9 Chapter 2 Out of the Closet, Off to the Moon _______________________11 Patterns and Professionalism in Software Development________________11 Andrea’s Closet __________________________________________________12 Off to the Moon __________________________________________________18 Forces Lead to Forces ________________________________________22 Different Forces, Different Design______________________________22 And There Are More Contextual Forces ________________________23 The Costs and Benefits _______________________________________24 On to Mars _________________________________________________26 vii viii Contents The Value of Patterns _____________________________________________26 Summary________________________________________________________27 Chapter 3 The Nature of Software Development __________________29 We Fail Too Much ________________________________________________30 Definitions of Success _____________________________________________31 The Standish Group ______________________________________________32 Doing the Wrong Things __________________________________________34 Doing the Things Wrong __________________________________________35 Time Goes By, Things Improve _____________________________________38 One Reason: The Civil Engineering Analogy _________________________38 Giving Up Hope __________________________________________________41 Ignoring Your Mother_____________________________________________42 Bridges Are Hard, Software Is Soft __________________________________43 We Swim in an Ocean of Change ___________________________________43 Accept Change ___________________________________________________44 Embrace Change _________________________________________________45 Capitalize on Change _____________________________________________46 A Better Analogy: Evolving Systems ________________________________49 Summary________________________________________________________52 Chapter 4 Evolution in Code: Stage 1 ________________________________55 Procedural Logic Replaced with Object Structure _____________________56 The Origins of Object Orientations and Patterns ______________________56 An Example: Simple Conditionals and the Proxy Pattern ______________58 The Next Step: Either This or That __________________________________62 Why Bother? ____________________________________________________65 One Among Many________________________________________________66 Summary________________________________________________________67 Contents ix Chapter 5 Using and Discovering Patterns _________________________69 Design from Context: More Carpentry from Scott_____________________70 Patterns Lead to Another Cognitive Perspective ______________________79 Patterns Help Give Us a Language for Discussing Design _______________79 Patterns in This Book _____________________________________________80 Summary________________________________________________________81 Chapter 6 Building a Pyramid_________________________________________83 Elements of the Profession_________________________________________83 A Visual Representation ___________________________________________85 Summary________________________________________________________86 Chapter 7 Paying Attention to Qualities and Pathologies _________89 Encapsulation____________________________________________________91 Cohesion ________________________________________________________91 Method Cohesion____________________________________________92 Cohesion of Perspective Level _________________________________94 Class Cohesion ______________________________________________96 How Cohesive Is Cohesive Enough? ___________________________98 Coupling ________________________________________________________99 Intentional Coupling Versus Accidental Coupling ________________99 Types of Coupling __________________________________________101 Redundancy ____________________________________________________106 Redundancy and Coupling___________________________________110 Testability ______________________________________________________112 Readability _____________________________________________________114 Pathologies _____________________________________________________114 Indicators of Weak Cohesion _________________________________115 Indicators of Accidental or Illogical Coupling ___________________116 Indicators of Redundancy____________________________________118 Summary ______________________________________________________119 x Contents Chapter 8 Paying Attention to Principles and Wisdom ___________121 Separating Use from Creation _____________________________________122 Fowler’s Perspectives________________________________________122 Another Kind of Perspective _________________________________123 The Perspective of Use ______________________________________125 A Separate Perspective: Creation _____________________________125 Considering Construction Details Last _________________________127 The Real World_____________________________________________129 The Open-Closed Principle _______________________________________129 Open-Closed at the Class Level _______________________________131 Open-Closed at the Method Level ____________________________132 The Dependency Inversion Principle _______________________________133 Advice from the Gang of Four_____________________________________135 Designing to the Interface of a Method ________________________136 Designing to the Interface of a Class___________________________138 GoF: Favor Object Aggregation Over Class Inheritance __________139 GoF: Consider What Should Be Variable in Your Design and Encapsulate the Concept That Varies ___________________________143 Summary ______________________________________________________146 Chapter 9 Paying Attention to Practices ___________________________147 Consistent Coding Style __________________________________________148 Comments_________________________________________________149