five_lines_of_code_-_how_and_when_to_refactor_-_using_typescript_examples_by_christian_clausen

Five Lines of Code - How and when to refactor - Using TypeScript examples by Christian Clausen

Book Summary

Five Lines of Code is a fresh look at refactoring for developers of all skill levels. In it, you’ll master author Christian Clausen’s innovative approach, learning concrete rules to get any method down to five lines—or less! You’ll learn when to refactor, specific refactoring patterns that apply to most common problems, and characteristics of code that should be deleted altogether.

Five Lines of Code teaches refactoring that's focused on concrete refactoring rules and getting any method/function down to five lines or less! There’s no refactoring jargon or tricky automated-testing skills required, just easy refactoring guidelines and refactoring patterns illustrated by detailed refactoring code samples.

In Five Lines of Code you will learn:

  • Improving code safely, even when you don’t understand it
  • The Extract method, Introducing Strategy pattern, and many other refactoring patterns
  • Writing stable code that enables change-by-addition
  • Real-world practices for great refactoring
    • EXTRACT METHOD (P3.2.1) — Takes part of one method and extracts it into its own method.
    • REPLACE TYPE CODE WITH CLASSES (P4.1.3) — Transforms an enum into an interface, and the enums’ values become classes.
    • PUSH CODE INTO CLASSES (P4.1.5) — Is a natural continuation of REPLACE TYPE CODE WITH CLASSES (P4.1.3), as it moves functionality into classes.
    • INLINE METHOD (P4.1.7) — Removes methods that no longer add readability to our program.
    • SPECIALIZE METHOD (P4.2.2) — Removes unnecessary and problematic generality from methods.
    • TRY DELETE THEN COMPILE (P4.5.1) — Removes unused methods from interfaces and classes when we know their entire scope.
    • UNIFY SIMILAR CLASSES (P5.1.1) — Unifies two or more classes that differ from each other in a set of constant methods.
    • COMBINE ifS (P5.2.1) — Reduces duplication by joining consecutive ifs that have identical bodies.
    • INTRODUCE STRATEGY PATTERN (P5.4.2) — Replaces variance through if by instead instantiating classes.
    • EXTRACT INTERFACE FROM IMPLEMENTATION (P5.4.4) — Replaces dependencies on a class with an interface.
    • ELIMINATE GETTER OR SETTER (P6.1.3) — Eliminates getters and setters by moving the functionality closer to the data.
    • ENCAPSULATE DATA (P6.2.3) — Localizes invariants related to variables and makes cohesion clearer.
    • ENFORCE SEQUENCE (P6.4.1) — Makes the compiler guarantee things happen in a specific order.

Improving existing coderefactoring — is one of the most common programming tasks you’ll face as a programmer. Five Lines of Code teaches you clear and actionable refactoring rules that you can apply without relying on intuitive judgements such as “code smells.” Following the author’s expert perspective — that refactoring and code smells can be learned by following a concrete set of refactoring principles — you’ll learn when to refactor your legacy code or other code, what refactoring patterns to apply to what refactoring problem, and the code characteristics that indicate it’s time for a rework.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the Technology

Every codebase includes code mistakes and code inefficiencies that you need to find and fix. Refactor the right way, and your code becomes elegant, easy to read, and easy to maintain. In this refactoring book, you’ll learn a unique approach to refactoring that implements any method / function in five lines or fewer. You’ll also discover a secret most senior devs know: sometimes it’s quicker to hammer out code and fix it later!

About the Reader

For developers of all skill levels. Examples use easy-to-read Typescript, in the same style as Java and C#.

Table of Contents

PART 1 LEARN BY REFACTORING A COMPUTER GAME

  • 3 Shatter long function
  • 4 Make type codes work
  • 5 Fuse similar code together
  • 6 Defend the data

PART 2 TAKING WHAT YOU HAVE LEARNED INTO THE REAL WORLD

Review

“Down to earth, focused, and right on point. It will challenge you without intimidating you and without insulting your intelligence.” — Robert C. Martin

“A delightful and fun introduction to one of the most overlooked parts of programming — refactoring.” — Charles Lam, EVN AG

“Gave me new insights on how to keep my code readable and my code maintainable. I highly recommend it.” — John Norcott, Webstaurantstore

“These refactoring techniques are simple but powerful, and the exercises makes it easy to learn them. They can be used in any language I know!” — Christian Hasselbalch Thoudahl, BEC Financial Technologies

About the Author

Christian Clausen works as a Technical Agile Coach teaching teams how to properly refactor their code. Previously he worked as a software engineer on the Coccinelle semantic patching project, an automated refactoring tool. He has an MSc in computer science, and five yearsexperience teaching software quality at a university level.

Product Details

Research It More

Fair Use Sources


© 1994 - 2024 Cloud Monk Losang Jinpa or Fair Use. Disclaimers

SYI LU SENG E MU CHYWE YE. NAN. WEI LA YE. WEI LA YE. SA WA HE.


five_lines_of_code_-_how_and_when_to_refactor_-_using_typescript_examples_by_christian_clausen.txt · Last modified: 2024/04/28 03:47 (external edit)