promo_download_app_ios_2025
Натисніть знайти для пошуку
Working Effectively with Legacy Code
Working Effectively with Legacy Code
Working Effectively with Legacy Code
Характеристики та опис

Користувальницькі характеристики

ISBN978-0131177055
АвторMichael Feathers
Рік2019
ВидавництвоPrentice Hall
Сторінк456
Get more out of your legacy systems: more performance, functionality, reliability, and manageability Is your code easy to change?Can you get nearly instantaneous feedback when you do change it?Do you understand it?If the answer to any of these questions is no, you have legacy code, and it is draining time and money away from your development efforts. In this book, Michael Feathers offers start-to-finish strategies for working more effectively with large, untested legacy code bases. This book draws on material Michael created for his renowned Object Mentor seminars: techniques Michael has used in mentoring to help hundreds of developers, technical managers, and testers bring their legacy systems under control. adding features, fixing bugs, improving design, optimizing performance Getting legacy code into a test harness Writing tests that protect you against introducing new problems Techniques that can be used with any language or platform--with examples in Java, C++, C, and C# Accurately identifying where code changes need to be made Coping with legacy systems that aren t object-oriented Handling applications that don t seem to have any structureThis book also includes a catalog of twenty-four dependency-breaking techniques that help you work with program elements in isolation and make safer changes. (c) Copyright Pearson Education. All rights reserved. Foreword by Robert C. Martin. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvPreface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiPART I: The Mechanics of Change. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Chapter 1: Changing Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Four Reasons to Change Software . . . . . . . . . . . . . . . . . . . . . . . . . . 4Risky Change . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Chapter 2: Working with Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9What Is Unit Testing? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12Higher-Level Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14Test Coverings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14The Legacy Code Change Algorithm . . . . . . . . . . . . . . . . . . . . . . . 18Chapter 3: Sensing and Separation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Faking Collaborators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23Chapter 4: The Seam Model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29A Huge Sheet of Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29Seams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30Seam Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33Chapter 5: Tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45Automated Refactoring Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45Mock Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47Unit-Testing Harnesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48General Test Harnesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53viii CONTENTSPART II: Changing Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55Chapter 6: I Don’t Have Much Time and I Have to Change It. . . . . . . . . . . 57Sprout Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .59Sprout Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63Wrap Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67Wrap Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76Chapter 7: It Takes Forever to Make a Change . . . . . . . . . . . . . . . . . . . . . . 77Understanding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .77Lag Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .78Breaking Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .85Chapter 8: How Do I Add a Feature? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87Test-Driven Development (TDD) . . . . . . . . . . . . . . . . . . . . . . . . . . .88Programming by Difference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .94Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .104Chapter 9: I Can’t Get This Class into a Test Harness . . . . . . . . . . . . . . . . 105The Case of the Irritating Parameter . . . . . . . . . . . . . . . . . . . . . . .106The Case of the Hidden Dependency . . . . . . . . . . . . . . . . . . . . . . .113The Case of the Construction Blob . . . . . . . . . . . . . . . . . . . . . . . .116The Case of the Irritating Global Dependency . . . . . . . . . . . . . . . .118The Case of the Horrible Include Dependencies . . . . . . . . . . . . . . .127The Case of the Onion Parameter . . . . . . . . . . . . . . . . . . . . . . . . .130The Case of the Aliased Parameter . . . . . . . . . . . . . . . . . . . . . . . . .133Chapter 10: I Can’t Run This Method in a Test Harness . . . . . . . . . . . . . . 137The Case of the Hidden Method . . . . . . . . . . . . . . . . . . . . . . . . . .138The Case of the “Helpful” Language Feature . . . . . . . . . . . . . . . . .141The Case of the Undetectable Side Effect . . . . . . . . . . . . . . . . . . . .144Chapter 11: I Need to Make a Change. What Methods Should I Test? . . . 151Reasoning About Effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .151Reasoning Forward . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .157Effect Propagation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .163Tools for Effect Reasoning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .165Learning from Effect Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . .167Simplifying Effect Sketches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .168CONTENTS ixChapter 12: I Need to Make Many Changes in One Area. . . . . . . . . . . . . . 173Interception Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174Judging Design with Pinch Points . . . . . . . . . . . . . . . . . . . . . . . . . 182Pinch Point Traps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184Chapter 13: I Need to Make a Change,but I Don’t Know What Tests to Write . . . . . . . . . . . . . . . . . . 185Characterization Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186Characterizing Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189Targeted Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190A Heuristic for Writing Characterization Tests . . . . . . . . . . . . . . . 195Chapter 14: Dependencies on Libraries Are Killing Me . . . . . . . . . . . . . . . 197Chapter 15: My Application Is All API Calls . . . . . . . . . . . . . . . . . . . . . . . 199Chapter 16: I Don’t Understand the Code Well Enough to Change It . . . . 209Notes/Sketching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210Listing Markup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211Scratch Refactoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212Delete Unused Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213Chapter 17: My Application Has No Structure . . . . . . . . . . . . . . . . . . . . . 215Telling the Story of the System . . . . . . . . . . . . . . . . . . . . . . . . . . . 216Naked CRC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220Conversation Scrutiny . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224Chapter 18: My Test Code Is in the Way . . . . . . . . . . . . . . . . . . . . . . . . . . 227Class Naming Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227Test Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228Chapter 19: My Project Is Not Object Oriented.How Do I Make Safe Changes?. . . . . . . . . . . . . . . . . . . . . . . . 231An Easy Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232A Hard Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232Adding New Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236Taking Advantage of Object Orientation . . . . . . . . . . . . . . . . . . . 239It’s All Object Oriented . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242Chapter 20: This Class Is Too Big and I Don’t Want It to Get Any Bigger . 245Seeing Responsibilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249x CONTENTSOther Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .265Moving Forward . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .265After Extract Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .268Chapter 21: I’m Changing the Same Code All Over the Place . . . . . . . . . . 269First Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .272Chapter 22: I Need to Change a Monster Methodand I Can’t Write Tests for It . . . . . . . . . . . . . . . . . . . . . . . . . 289Varieties of Monsters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .290Tackling Monsters with Automated Refactoring Support . . . . . . .294The Manual Refactoring Challenge . . . . . . . . . . . . . . . . . . . . . . . .297Strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .304Chapter 23: How Do I Know That I’m Not Breaking Anything?. . . . . . . . 309Hyperaware Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .310Single-Goal Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .311Preserve Signatures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .312Lean on the Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .315Chapter 24: We Feel Overwhelmed. It Isn’t Going to Get Any Better. . . . . .319PART III: Dependency-Breaking Techniques . . . . . . . . . . . . . . . . . . . .323Chapter 25: Dependency-Breaking Techniques . . . . . . . . . . . . . . . . . . . . . 325Adapt Parameter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .326Break Out Method Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .330Definition Completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .337Encapsulate Global References . . . . . . . . . . . . . . . . . . . . . . . . . . . .339Expose Static Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .345Extract and Override Call . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .348Extract and Override Factory Method . . . . . . . . . . . . . . . . . . . . . .350Extract and Override Getter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .352Extract Implementer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .356Extract Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .362Introduce Instance Delegator . . . . . . . . . . . . . . . . . . . . . . . . . . . . .369Introduce Static Setter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .372Link Substitution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .377Parameterize Constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .379Parameterize Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .383CONTENTS xiPrimitivize Parameter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385Pull Up Feature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388Push Down Dependency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392Replace Function with Function Pointer . . . . . . . . . . . . . . . . . . . . 396Replace Global Reference with Getter . . . . . . . . . . . . . . . . . . . . . 399Subclass and Override Method . . . . . . . . . . . . . . . . . . . . . . . . . . . 401Supersede Instance Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404Template Redefinition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408Text Redefinition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412Appendix: Refactoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415Extract Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423

Working Effectively with Legacy Code

В наявності
Код: 14428
700 
Способи оплати
Безпечна оплата
  • Як післяплата, тільки без переплат
  • Повернем гроші, якщо щось піде не так
  • Bigl гарантує безпеку
Післяплата
Нова Пошта, Самовивіз
Способи доставки
Нова Пошта — Безкоштовно за умови
Укрпошта — від 35 грн
Самовивіз
Умови повернення
Уточнюйте у продавця
Інші товари продавця
Подібні товари інших продавців
Дивіться також
Новинки в категорії Товари, загальне
Чат