Skip to Content
Node与Express开发(第2版)
book

Node与Express开发(第2版)

by Ethan Brown
June 2021
Intermediate to advanced
290 pages
9h 21m
Chinese
Posts & Telecom Press
Content preview from Node与Express开发(第2版)
232
|
第
20
章
么你很可能不知道从哪里开始。不管什么时候面对一个一眼看不穿的问题,你
第一个想法
都会是:“这个问题的来源我要怎么
排除
呢?”毕竟你排除得越多,需要看的地方就越少。
排除法可以有多种形式,以下是一些常见的例子。
•
有步骤地注释掉或禁用一些代码块。
•
编写能够被单元测试覆盖到的代码。单元测试本身提供了一个排除问题来源的框架。
•
分析网络流量,确定问题是产生在客户端还是服务器端。
•
找出系统中与发现问题的部分有相似之处的部分,并对其进行测试。
•
使用先前正常输入的数据,之后一次修改一点点,直到问题显现。
•
使用版本控制系统,来回切换版本直到问题消失,你就可以定位出特定的代码变更(更
多信息请查看
git bisect
命令)。
•
“模拟”某些功能,以便排除复杂的子系统。
不过,排除法并非是万能的。很多时候,问题是由两个甚至更多组件之间的复杂交互造成
的。只要排除(或模拟)其中任何一个组件,问题就可能会消失,但是并不能定位到其中
的某个组件。不过即便是在这种情形下,排除也有助于缩减问题来源的范围,尽管它还没
有直接给你指明问题所在的位置。
如果能做到细致而有条理,排除法是其中最成功的。如果只是漫无目的地排除一些组件,
而不考虑它们是如何影响整体的,就很容易错过一些东西。你可以自己试试:当考虑要不
要排除某个组件时,梳理一下如果移除这个组件会对系统产生怎样的影响。这样就会知道
应该期望什么样的结果,以及移除这个组件能否告诉你有用的信息。
20.2
 利用
REPL
和控制台
不管是
Node
还是浏览器,都给你提供了一个 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

面向对象的思考过程(原书第5版)

面向对象的思考过程(原书第5版)

马特 魏斯费尔德
精通模块化JavaScript

精通模块化JavaScript

Nicolás Bevacqua

Publisher Resources

ISBN: 9787115565099