Pragmatic Programmer Tips
Pragmatic Programmer Tips
pragprog.com/tips
Buy →
Andy and Dave wrote this influential, classic book to help their
clients create better software and rediscover the joy of coding.
Almost twenty years later, its advice is still spot on, and the Pragmatic philosophy has
spawned hundreds of books, screencasts, and audio books, as well as thousands of careers
and success stories.
We’ve posted the 100 tips from the book here for your reference and enjoyment. Tweet
and share your favorites!
Why spend your life developing software unless you care about doing it well?
Tweet this
Turn off the autopilot and take control. Constantly critique and appraise your work.
Tweet this
It’s your life. Grab hold of it and make it what you want.
Tweet this
1/17
Provide Options, Don’t Make Lame Excuses
Instead of excuses, provide options. Don’t say it can’t be done; explain what can be done.
Tweet this
Fix bad designs, wrong decisions, and poor code when you see them.
Tweet this
You can’t force change on people. Instead, show them how the future might be and help
them participate in creating it.
Tweet this
Don’t get so engrossed in the details that you forget to check what’s happening around
you.
Tweet this
Tweet this
Tweet this
2/17
Don’t be swayed by vendors, media hype, or dogma. Analyze information in terms of you
and your project.
Tweet this
Treat English as Just Another Programming Language. Write documents as you would
write code: honor the DRY principle, ETC, automation, and so on.
Tweet this
It’s Both What You Say and the Way You Say It
There’s no point in having great ideas if you don’t communicate them effectively.
Tweet this
Documentation created separately from code is less likely to be correct and up to date.
Tweet this
A thing is well designed if it adapts to the people who use it. For code, that means it must
adapt by changing.
Tweet this
Tweet this
3/17
If it’s easy to reuse, people will. Create an environment that supports reuse.
Tweet this
Design components that are self-contained, independent, and have a single, well-defined
purpose.
Tweet this
No decision is cast in stone. Instead, consider each as being written in the sand at the
beach, and plan for change.
Tweet this
Neal Ford says, “Yesterday’s Best Practice Becomes Tomorrow’s Antipattern.” Choose
architectures based on fundamentals, not fashion.
Tweet this
Tracer bullets let you home in on your target by trying things and seeing how close they
land.
Tweet this
Prototype to Learn
Prototyping is a learning experience. Its value lies not in the code you produce, but in the
lessons you learn.
Tweet this
4/17
Design and code in the language of the problem domain.
Tweet this
Tweet this
Use experience you gain as you implement to refine the project time scales.
Tweet this
Plain text won’t become obsolete. It helps leverage your work and simplifies debugging
and testing.
Tweet this
Use the shell when graphical user interfaces don’t cut it.
Tweet this
An editor is your most important tool. Know how to make it do what you need, quickly
and accurately.
Tweet this
Version control is a time machine for your work; you can go back.
5/17
Tweet this
It doesn’t really matter whether the bug is your fault or someone else’s—it is still your
problem, and it still needs to be fixed.
Tweet this
Don’t Panic
Tweet this
Create a focussed test that reveals the bug before you try fixing it.
Tweet this
Most exceptions tell both what failed and where it failed. If you’re lucky you might even
get parameter values.
Tweet this
It is rare to find a bug in the OS or the compiler, or even a third-party product or library.
The bug is most likely in the application.
Tweet this
Prove your assumptions in the actual environment—with real data and boundary
conditions.
6/17
Tweet this
You spend a large part of each day working with text. Why not have the computer do some
of it for you?
Tweet this
Software can’t be perfect. Protect your code and users from the inevitable errors.
Tweet this
Use contracts to document and verify that code does no more and no less than it claims to
do.
Tweet this
Crash Early
A dead program normally does a lot less damage than a crippled one.
Tweet this
If it can’t happen, use assertions to ensure that it won’t. Assertions validate your
assumptions. Use them to protect your code from an uncertain world.
Tweet this
Where possible, the function or object that allocates a resource should be responsible for
deallocating it.
7/17
Tweet this
Act Locally
Keep the scope of mutable variables and open resources short and easily visible.
Tweet this
Small steps always; check the feedback; and adjust before proceeding.
Tweet this
Avoid Fortune-Telling
Tweet this
Coupling ties things together, so that it’s harder to change just one thing.
Tweet this
Don’t get values from an object, transform them, and then stick them back. Make the
object do the work.
Tweet this
Try not to have more than one dot when you access something.
Tweet this
8/17
Avoid Global Data
Tweet this
Tweet this
All programs transform data, converting an input into an output. Start designing using
transformations.
Tweet this
Don’t hang on to data within a function or module. Take one down and pass it around.
Tweet this
Consider alternatives that better fit your needs, such as interfaces, delegation, or mixins
Tweet this
Tweet this
9/17
Tweet this
Mixins add functionality to classes without the inheritance tax. Combine with interfaces
for painless polymorphism.
Tweet this
When code relies on values that may change after the application has gone live, keep those
values external to the app. When you application will run in different environments, and
potentially for different customers, keep the environment and customer specific values
outside the app.
Tweet this
Tweet this
Shared state opens a large can of worms that can often only be fixed by rebooting.
Tweet this
Variations in timing and context can expose concurrency bugs, but in inconsistent and
irreproducible ways.
Tweet this
10/17
Tweet this
Tweet this
When it feels like your code is pushing back, it’s really your subconscious trying to tell you
something’s wrong.
Tweet this
Rely only on reliable things. Beware of accidental complexity, and don’t confuse a happy
coincidence with a purposeful plan.
Tweet this
Get a feel for how long things are likely to take before you write code.
Tweet this
Mathematical analysis of algorithms doesn’t tell you everything. Try timing your code in
its target environment.
Tweet this
Just as you might weed and rearrange a garden, rewrite, rework, and re-architect code
when it needs it. Fix the root of the problem.
11/17
Tweet this
A test is a perspective into your code, and gives you feedback about its design, api, and
coupling.
Tweet this
Tweet this
Build small pieces of end-to-end functionality, learning about the problem as you go.
Tweet this
Design to Test
Tweet this
Test ruthlessly. Don’t make your users find bugs for you.
Tweet this
Property-based tests will try things you never thought to try, and exercise your code in
ways is wasn’t meant to be used.
Tweet this
12/17
Tip #72, pg. 234:
Complex code creates a breeding ground for bugs and opportunities for attackers to
exploit.
Tweet this
Tweet this
Name to express your intent to readers, and rename as soon as that intent shifts.
Tweet this
They might know a general direction, but they won’t know the twists and turns.
Tweet this
Tweet this
Tweet this
13/17
Work with a User to Think Like a User
It’s the best way to gain insight into how the system will really be used.
Tweet this
Policy Is Metadata
Don’t hardcode policy into a system; instead express it as metadata used by the system.
Tweet this
Create and maintain a single source of all the specific terms and vocabulary for a project.
Tweet this
When faced with an impossible problem, identify the real constraints. Ask yourself: “Does
it have to be done this way? Does it have to be done at all?”
Tweet this
Tweet this
Tweet this
14/17
Teams should be small and stable, where everyone trusts each other and depends on each
other.
Tweet this
If you don’t schedule it, it’s not going to happen. Schedule reflection, experimentation,
learning and skills improvement.
Tweet this
Organize Around Functionality, Not Job Functions. Don’t separate UI/UX designers from
coders, frontend from backend, testers from data modelers, design from deployment.
Build teams so you can build code end-to-end, incrementally and iteratively.
Tweet this
Don’t adopt a development method or technique just because other companies are doing
it. Adopt what works for your team, in your context.
Tweet this
Don’t wait weeks or months to deliver just because your process demands it.
Tweet this
Use commits or pushes to trigger builds, tests, releases. Use a version control tag to
deploy to production.
Tweet this
15/17
Test Early, Test Often, Test Automatically
Tests that run with every build are much more effective than test plans that sit on a shelf.
Tweet this
’Nuff said.
Tweet this
Introduce bugs on purpose in a separate copy of the source to verify that testing will catch
them.
Tweet this
Identify and test significant program states. Testing just lines of code isn’t enough.
Tweet this
Once a human tester finds a bug, it should be the last time a human tester finds that bug.
Automatic tests should check for it from then on.
Tweet this
A computer will execute the same instructions, in the same order, time after time.
Tweet this
16/17
Develop solutions that produce business value for your users and delight them every day.
Tweet this
Artisans of an earlier age were proud to sign their work. You should be, too.
Tweet this
First, Do No Harm
Tweet this
Tweet this
It’s Your Life. Share it. Celebrate it. Build it. AND HAVE FUN!
Tweet this
17/17