益处

Nassim Nicholas Taleb 在《Antifragile》中写到:“错误包含丰富的信息”。我完全同意这个观点。Bug 帮助我们更好地理解系统,告诉我们怎样提高编码、测试和调试技巧。所以我认为尽可能从 bug 中学习经验,是再正常不过的事了。

我发现为每个有趣的bug记录下来,让我轻易学习到很多。在记录的行为中我会对发生的事情思考得更深刻。同样,一旦记录下来,我可以在之后检查发生的事情。偶尔,我也会浏览文件,只阅读教训部分,对我认为是从 bug 中学到的最有价值的经验加强记忆。

我记录 bug 文件至今已经有 13 年了。这是一段漫长的时间,但是我坚持下来了,因为作为一名程序员,它帮助我进步。尝试一下吧,看看它是否也对你有益!

我有一个命名为 bugs.txt 的纯文本文件。在文件的顶部是一个具备所有标题的模板,但是没有包含信息。当我添加一个新的记录,我复制模板部分,粘贴在模板下面。然后完成记录并且填满信息。大多数展示在上面例子中的 fields 应该是不需要声明的。

有必要指出这并不是 bug 追踪器。我并没有添加所有我修复的 bug 。例如,如果我只是忘记在代码中添加声明,一旦发生这种情况,我就意识到问题出在哪里了,我并不会添加这条记录。仅仅当 bug 本身,或是修复,或是调试过程特别有趣,我才会添加一条新的记录。通常,是我导致了这个 bug。但是偶尔,特别是花几天时间才追踪到的困难 bug,尽管不是我造成的我也会添加一条记录。

一旦修复了一个 bug,我的第一反应是松了口气然后继续前进。我试着一更正后就写下这个记录。这时我的脑海中依然清晰保留所有的细节。拖延会让精确回忆发生的事情变得很困难(或者我压根忘记写下这条记录)。

至今,我已经有 194 条记录,平均每个月有一条新的记录。最重要的是教训部分。这里需要自我反省。是什么导致这个 bug 的特殊性?我发现经验常常来自于三个不同的方面:

编码。我在代码中犯了什么错误?我是否忘记了 else 部分代码?是否系统调用失败,但没有检查 response?我在未来应该怎么调整代码来防止这些问题?

测试。一般不包括本可以在测试中捕获的 bug 。要是这样的话,应该在哪个阶段测试——单元、功能、系统?丢失了哪个测试用例?

调试。我本可以怎样快速定位 bug?我是否使用了正确的方法?我是否假定了太多?我是否需要在代码中使用更好的日志记录?
[fusion_builder_container background_color=”” background_image=”” background_parallax=”none” enable_mobile=”no” parallax_speed=”0.3″ background_repeat=”no-repeat” background_position=”left top” video_url=”” video_aspect_ratio=”16:9″ video_webm=”” video_mp4=”” video_ogv=”” video_preview_image=”” overlay_color=”” overlay_opacity=”0.5″ video_mute=”yes” video_loop=”yes” fade=”no” border_size=”0px” border_color=”” border_style=”solid” padding_top=”20px” padding_bottom=”” padding_left=”” padding_right=”” hundred_percent=”no” equal_height_columns=”no” hide_on_mobile=”no” menu_anchor=”” class=”” id=””][fusion_builder_row][fusion_builder_column type=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none”][fusion_text]

 相关链接 >

[/fusion_text][/fusion_builder_column][fusion_builder_column type=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none”][fusion_portfolio layout=”carousel” picture_size=”fixed” boxed_text=”unboxed” filters=”no” columns=”6″ column_spacing=”12″ cat_slug=”apps,new” exclude_cats=”videos” number_posts=”1000″ offset=”” excerpt_length=”35″ strip_html=”yes” carousel_layout=”title_on_rollover” scroll_items=”” autoplay=”no” show_nav=”yes” mouse_scroll=”no” animation_type=”0″ animation_direction=”down” animation_speed=”0.1″ animation_offset=”” class=”” id=””][/fusion_portfolio][fusion_text]

[/fusion_text][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container][fusion_builder_container background_color=”#303030″ background_image=”” background_parallax=”none” enable_mobile=”no” parallax_speed=”0.3″ background_repeat=”repeat” background_position=”left top” video_url=”” video_aspect_ratio=”16:9″ video_webm=”” video_mp4=”” video_ogv=”” video_preview_image=”” overlay_color=”” overlay_opacity=”0.5″ video_mute=”yes” video_loop=”yes” fade=”no” border_size=”0px” border_color=”” border_style=”solid” padding_top=”” padding_bottom=”” padding_left=”” padding_right=”” hundred_percent=”yes” equal_height_columns=”no” hide_on_mobile=”no” menu_anchor=”” class=”” id=””][fusion_builder_row][fusion_builder_column type=”1_6″ last=”no” spacing=”yes” center_content=”no” hide_on_mobile=”no” background_color=”” background_image=”” background_repeat=”no-repeat” background_position=”left top” hover_type=”none” link=”” border_position=”all” border_size=”0px” border_color=”” border_style=”solid” padding=”” margin_top=”” margin_bottom=”” animation_type=”” animation_direction=”” animation_speed=”0.1″ animation_offset=”” class=”” id=””][/fusion_builder_column][fusion_builder_column type=”1_2″ last=”no” spacing=”yes” center_content=”no” hide_on_mobile=”no” background_color=”” background_image=”” background_repeat=”no-repeat” background_position=”left top” hover_type=”none” link=”” border_position=”all” border_size=”0px” border_color=”” border_style=”solid” padding=”” margin_top=”” margin_bottom=”” animation_type=”” animation_direction=”” animation_speed=”0.1″ animation_offset=”” class=”” id=””][fusion_text]

产品
Wex5
bex5
资源
下载中心
文档中心
在线体验
服务和社群
每周培训
开发者论坛
加入QQ群
外包和招聘中心
起步软件
关于我们
联系我们
加入我们

[/fusion_text][/fusion_builder_column][fusion_builder_column type=”1_5″ last=”yes” spacing=”yes” center_content=”no” hide_on_mobile=”no” background_color=”” background_image=”” background_repeat=”no-repeat” background_position=”left top” hover_type=”none” link=”” border_position=”all” border_size=”0px” border_color=”” border_style=”solid” padding=”” margin_top=”” margin_bottom=”” animation_type=”” animation_direction=”” animation_speed=”0.1″ animation_offset=”” class=”” id=””][fusion_separator style_type=”none” top_margin=”” bottom_margin=”20″ sep_color=”” border_size=”” icon=”” icon_circle=”” icon_circle_color=”” width=”” alignment=”” class=”” id=””/][fusion_text]

index-icon-weibo index-icon-facebook index-icon-twitter github-1

[/fusion_text][fusion_text]

wen-xin-2

[/fusion_text][/fusion_builder_column][fusion_builder_column type=”1_1″ last=”yes” spacing=”yes” center_content=”no” hide_on_mobile=”no” background_color=”” background_image=”” background_repeat=”no-repeat” background_position=”left top” hover_type=”none” link=”” border_position=”all” border_size=”0px” border_color=”” border_style=”” padding=”” margin_top=”” margin_bottom=”” animation_type=”” animation_direction=”” animation_speed=”0.1″ animation_offset=”” class=”” id=””][fusion_text]

    友情链接 | 法律说明          北京起步科技股份有限公司  ©2006-2016        京ICP备13007148号

[/fusion_text][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]