Chapter 2. Keep It Simple

Simplicity should be a core value for all Java programmers, but it’s not. Most developers have yet to establish simplicity as a core value. I’ll never forget when one of my friends asked for a code review and handed me a nine-page, hideously complex blob with seemingly random Java tokens. All kinds of thoughts swarmed through my mind in a period of seconds. At first, I thought it was a joke, but he kept staring expectantly. My next thought was that he hated me; I couldn’t think of anything I’d done to deserve it. Finally, I began to read. After three pages of pure torture, I glanced up. He was grinning from ear to ear. My slackened jaw fell open, and I finally realized that he was proud of this code.

It’s a cult. If you’ve coded for any length of time, you’ve run across someone from this warped brotherhood. Their creed: if you can write complicated code, you must be good.

The Value of Simplicity

Simplicity may be the core value. You can write simple code faster, test it more thoroughly with less effort, and depend on it once it’s done. If you make mistakes, you can throw it away without reservation. When requirements change, you can refactor with impunity. If you’ve never thought about simplicity in software development before, let’s first talk about what simplicity is not:

  • Simple does not mean simple-minded. You’ll still think just as hard, but you’ll spend your energy on simplicity, elegance, and the interactions between simple components. e=mc2 is a remarkably ...

Get Better, Faster, Lighter Java now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.