万本电子书0元读

万本电子书0元读

顶部广告

Refactoring TypeScript电子书

售       价:¥

6人正在读 | 0人评论 9.8

作       者:James Hickey

出  版  社:Packt Publishing

出版时间:2019-10-18

字       数:121.8万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Discover various techniques to develop maintainable code and keep it in shape. Key Features * Learn all about refactoring - why it is important and how to do it * Discover easy ways to refactor code with examples * Explore techniques that can be applied to most other programming languages Book Description Refactoring improves your code without changing its behavior. With refactoring, the best approach is to apply small targeted changes to a codebase. Instead of doing a huge sweeping change to your code, refactoring is better as a long-term and continuous enterprise. Refactoring TypeScript explains how to spot bugs and remove them from your code. You’ll start by seeing how wordy conditionals, methods, and null checks make code unhealthy and unstable. Whether it is identifying messy nested conditionals or removing unnecessary methods, this book will show various techniques to avoid these pitfalls and write code that is easier to understand, maintain, and test. By the end of the book, you’ll have learned some of the main causes of unhealthy code, tips to identify them and techniques to address them. What you will learn * Spot and fix common code smells to create code that is easier to read and understand * Discover ways to identify long methods and refactor them * Create objects that keep your code flexible, maintainable, and testable * Apply the Single Responsibility Principle to develop less-coupled code * Discover how to combine different refactoring techniques * Learn ways to solve the issues caused by overusing primitives Who this book is for This book is designed for programmers who are looking to explore various refactoring techniques to develop healthy and maintainable code. Some experience in JavaScript and TypeScript can help you easily grasp the concepts explained in this book.
目录展开

Preface

About the Book

About the Author

Learning Objectives

Audience

Approach

Chapter 1

Introduction

About TypeScript

What Is It?

What's All the Fuss About?

TypeScript versus JavaScript

Why I Chose TypeScript for This Book

What Is Refactoring?

Let's Define It

Our Approach

Design Patterns

Why Refactor at All?

Slow Development

Saving Money

Navy SEALS Get It

Being a Craftsman

Case Study #1

Case Study #2

When Should I Refactor?

The Boy Scout Rule

Repetitive Work

Difficulty Adding Features

In the End

Chapter 2

Null Checks Everywhere!

Identification

Billion-Dollar Mistake

Example

Is It That Bad?

Non-Nullable Types

Null Object Pattern

Empty Collections

Fixing It Up

Take 2

What About Objects?

Special Case Pattern

Situation

An Order Class That Needs to Be Refactored

Refactoring the Order Class

Chapter 3

Wordy Conditionals

Identification

A Little Bit of This, a Little Bit of That

Misbehaving Conditionals

Combining Conditionals

Situation

The Code

Guideline

Extracting Methods from Conditionals

What's Wrong Here?

The Fix

Extracting Conditional Logic to Explicit Classes

Let's Get Classy

SRP

Using It

Pipe Classes

Your Classes Might Be Doing Too Much...

Piping Our Logic

Bonus Refactor

Chapter 4

Nested Conditionals

Identification

A Monster

A Closer Look

Guard Clauses

Scenario

Fail Fast

Fixing It Up

Gate Classes

Scenario

Gate Classes to the Rescue

Useful for Web APIs

Chapter 5

Primitive Overuse

Identification

What's Wrong Here?

Value Objects

Scenario

Initial Refactor

Addressing Primitives

Creating Our Object

Moving Along

Immediate Validation

Deceptive Booleans

Scenario

New Business Rules

More Rules...

Is It Really That Bad?

Just Use Enums

Strategy Pattern

Chapter 6

Lengthy Method Signatures

Identification

The Slippery Slope of Optional Parameters

The Issue

Guidelines

Creating a Reusable Private Method

A Simple Example

Creating Semantically Meaningful Methods

A Brief Look at Some Advanced Solutions

Extracting Data Objects

Extraction

Chapter 7

Methods That Never End

Identification

When Is a Method Too Long?

Give It a Name

Being Strategic

Chapter 8

Dumping Grounds

Identification

Object-Oriented?

The Great Debate

Coupling

Warning Sign

One of These Things Is Not Like The Others

You Have Mail

Breaking It Up

Keep Separate Things Separate

Speak or Listen

CQRS

Read and Write

Next Steps

Commands

Queries

Conclusion

A Word of Caution

Chapter 9

Messy Object Creation

Identification

Factory Functions

Functions versus Static Methods

Combining Refactoring Techniques

Complexity Remains...

Building It

The Builder Pattern

One Last Improvement

Chapter 10

Conclusion

This Is Just The Beginning!

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部