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
分享到:
相关推荐
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....
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....
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 ...
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 {...
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. ...
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版本。英文 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.
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 ...
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...
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: ...
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 ...