`

Write Boring Code

 
阅读更多
Tom Ball, Sun Microsystems公司的技术主管说如何写出更好的代码.

Ball:我能给出最好的建议就是——并且是我总是遵守的——只要可能就去写单调(boring)的代码. 这样的代码会是如此清晰明了(obvious)以至于它无需注释并且其他充满智慧的开发者会将其忽略并跳过. 写下这样的代码, 它只做一件事但是可以把这件事情做的非常漂亮, 基于此你可以写下它然后忘记它, 它会在后台安静地工作.

举例来说, NetBeans IDE的classfile模块做一件事情, 读取JVM类文件然后把它们变成基于JVM规范的类. 你无法修改这些类中的任何一个——因为它们是不可变的(immutable). 它不支持类文件的编辑和创建, 任何熟悉JVM规范的人也不会对它感兴趣.

因为这个模块是"单调的(boring)", 没有人会想要修改(hack)它——它只在JVM规范改变的时候被更新——因此它会在几年内非常稳定. 由于非常简单, 所以它非常快, 几乎不占用内存, 并且由于它是不可变的(immutable)所以它也是线程安全的(threadsafe). 可能最重要的是, 因为它是稳定且单调的(boring), 我才可以做其他的项目而不是成天来维护或增强它.

---
对Tom Ball访问的原文在 http://java.sun.com/developer/Meet-Eng/ball/?feed=JSC

分享到:
评论

相关推荐

    Automate.the.Boring.Stuff.with.Python.Practical.Programming

    In Automate the Boring Stuff with Python, you'll learn how to use Python to write programs that do in minutes what would take you hours to do by hand—no prior programming experience required....

    sourcecode.zip

    In Automate the Boring Stuff with Python, you'll learn how to use Python to write programs that do in minutes what would take you hours to do by hand-no prior programming experience required....

    Advanced Apple Debugging & Reverse Engineering v0.9.5

    You’ll start off by introspecting a program you didn’t even write — Xcode! 2. Help & Apropos Just like any respectable developer tool, LLDB ships with a healthy amount of documentation. Knowing ...

    Android代码-javapoet

    the need to write boilerplate while also keeping a single source of truth for the metadata. Example Here's a (boring) HelloWorld class: package com.example.helloworld; public final class HelloWorld {...

    Learning [removed] JavaScript programming Vol 1: The language core

    You will learn how to write JavaScript code that not only works, but that you can be proud of. The latest, completely revised edition takes into account the most current JavaScript language version. ...

    Picture.Guide.to.iOS.Programming.B019HL24VK

    In this book you will have the opportunity to write code, use Apple technologies and create multiple applications that would be eligible for distribution by Apple. Table of Contents Getting Started ...

    核心JSF编程(chm)

    核心JSF编程。chm版本。英文 JavaServer Faces promises to bring rapid user-interface ... It also automates low-level, boring details like control flow and moving code between web forms and business logic.

    Android代码-gwteventbinder

    GWT's EventBus is great - it allows you to write maintainable GWT applications by decoupling the components of your application, making them easy to add, modify, or remove. However, using EventBus in ...

    Delphi Cookbook Third Edition

    books like this one, which would be particularly boring, I guess), but you can find some recipes that explain some of the most important RTL features and some less known but really useful classes. You...

    Soft.Skills.The.software.developers.life.manual

    Appendix A: If you can write code, you can understand finances Appendix B: How the stock market works: Rules of the system Appendix C: Garbage in, garbage out: Diet and nutrition basics Appendix D: ...

    word自动转化为chm

    The capitalized term “Software” used below refers to Macrobject Word-2-CHM 3.0, any updates to the software, any supplemental code provided to you by Macrobject Software, the user manual, any ...

Global site tag (gtag.js) - Google Analytics