Reading Books Douban 3 MIN READ

Notes on The Pragmatic Programmer

Reading notes on responsibility, refactoring, and a project that taught me how much it matters to understand the user’s work.

The Pragmatic Programmer ·

阅读中文原文 →

A Philosophy of Programming

Take responsibility

We can commit to getting something done properly without guaranteeing every single aspect of it. We’re entitled to decline responsibility for impossible work or risks that are too great.

If you do take responsibility for an outcome, be honest. Have options ready before you deliver bad news.

Explain what you can do to recover, instead of leaving it at “It can’t be done.”

Broken windows. Repair a “broken window” when you see it.

We all tend to let things slide. If we tolerate our own mistakes, the whole system starts to get unstable.

Manage my knowledge portfolio

  1. Serious investors invest regularly.

  2. Diversification is essential for lasting success.

  3. Smart investors balance conservative assets with higher-risk, higher-return investments.

  4. Investors try to buy low and sell high to maximize their returns.

  5. Review and rebalance your assets periodically.

Goals.

  1. Learn a new language each year.

  2. Read technical books.

  3. Read books outside technology.

  4. Take classes.

  5. Get involved in projects and organizations outside your field.

  6. Keep up with what’s happening.

  7. Go online.

Think critically

Critical thinking.

Communicate

  1. Know what you plan to talk about.

    Use an outline. Plan.

  2. Know your audience.

  3. Pick your moment.

  4. Choose a style.

  5. Make the document look good.

  6. Get your audience involved.

  7. Listen first.

  8. Answer people’s questions.

The DRY principle

Every piece of knowledge in a system must have a single, unambiguous, authoritative representation.

Don’t Repeat Yourself.

Orthogonality

In a well-designed system, the interface and the database are orthogonal. You can change the interface without touching the database, and change the database without touching the interface.

Local fixes.

Avoid depending on properties you have no control over.

The idea of delegation?

Schrödinger’s cat.

Refactoring

  1. Keep new features out of a refactor.

  2. Test as much as you can before you start.

  3. Take small, considered steps.

You don’t know why the code failed because you never understood why it worked in the first place.

After a year on a project, I kept asking why we were so exhausted and still couldn’t write software the customer was happy with. At first we blamed the users’ shifting requirements and changes of mind that seemed to come out of nowhere. As the project drew to a close, I realized I wouldn’t be happy using the thing I’d made myself. Worse, I was building software for corn production without understanding how corn production works from start to finish. With only the requirements from users to go on, there was no amount of code tuning that would let us handle it well. I didn’t even know what work the thing I was making was meant to serve.

Always be aware of what you’re doing.

Avoid programming blindly.

Work from a plan.

Rely on things you can count on.

Document your assumptions.

Test your assumptions as well as your code.

Set priorities for your work.

Don’t be a slave to history.

GUI

What you see is what you get, but what you see is all you get.

Fix the Problem, Not the Blame

Taking as a basic premise that the computer hasn’t made a mistake, spend more time solving the problem and less time finding someone to blame.

Design by contract

Honor the contract when doing what has to be done. For the things we’re interested in, striving for perfection is what moves us forward.

Work with a User to Think Like a User