Introduction

You care about code. You’re passionate about programming. You’re the kind of developer who likes to craft truly great software. And you’ve picked up this book because you want to do it even better. Good call.

This book will help you.

The aim is to do exactly what it says on the cover: help you become a better programmer. But what does that mean exactly?

Pretty early in any programmer’s career comes the realisation that there’s more to being a great coder than a simple understanding of syntax and a mastery of basic design. The awesome programmers, those productive people who craft beautiful code and work effectively with other people, know far more. There are methods of working, attitudes, approaches, idioms, and techniques you learn over time that increase your effectiveness. There are useful social skills, and a whole pile of tribal knowledge to pick up.

And, of course, you need to learn syntax and design.

That is exactly what this book is about. It’s a catalogue of useful techniques and approaches to the art and craft of programming that will help you become better.

I won’t pretend that this is an exhaustive treatise. The field is vast. There’s always more to learn, with new ground being claimed every day. These chapters are simply the fruit of more than 15 years of my work as a professional programmer. I’ve seen enough code, and made enough mistakes. I won’t claim I’m an expert; I’m just well seasoned. If you can learn from the mistakes I’ve made and garner inspiration from what I’ve experienced, then you’ll gain a leg up in your own development career.

What’s Covered?

The topics covered in this book run the whole gamut of the software developer’s life:

  • Code-level concerns that affect how you write individual lines of code, as well as how you design your software modules.

  • Practical techniques that will help you work better.

  • Illustrations of effective attitudes and approaches to adopt that will help you become both super effective and well grounded.

  • Procedural and organisational tricks and tips that will help you flourish whilst you are incarcerated in the software factory.

There’s no particular language or industry bias here.

Who Should Read This?

You!

Whether you’re an industry expert, a seasoned developer, a neophyte professional, or a hobbyist coder—this book will serve you.

Becoming a Better Programmer aims to help programmers at any level improve. That’s a grand claim, but there’s always something we can learn, and always room for improvement, no matter how experienced a programmer you are. Each chapter provides the opportunity to review your skills and work out practical ways to improve.

The only prerequisite for making use of this book is that you must want to become a better programmer.

The Structure

The information in this book is presented in a series of simple, self-contained chapters, each covering a single topic. If you’re a traditionalist, you can read them in order from front to back. But feel free to read chapters in any order you want. Go straight to what seems most pertinent to you, if that makes you most happy.

The chapters are presented in five parts:

you.write(code);

We start right at the bottom, at the codeface, where programmers feel most comfortable. This section reveals important code-writing techniques, and shows ways to write the best code possible. It covers code writing, code reading, code design, and mechanisms to write robust code.

Practice Makes Perfect

Stepping back from the codeface, this part covers the important programming practices that help make you a better programmer. We’ll see healthy attitudes and approaches to the coding task, and sound techniques that will help you craft better code.

Getting Personal

These chapters dig deep to build excellence into your personal programming life. We’ll look at how to learn effectively, consider behaving ethically, find stimulating challenges, avoid stagnation, as well as improve physical well-being.

Getting Things Done

These chapters talk about practical ways to get things done: to deliver code on time without getting sidetracked or delayed.

The People Pursuit

Software development is a social activity. These chapters show how to work well with the other inhabitants of the software factory.

More important than the order you consume these chapters is how you approach the material. In order to actually improve, you have to apply what you read practically. The structure of each chapter is designed to help you with this.

In each chapter, the topic at hand is unpacked in flowing prose with stark clarity. You’ll laugh; you’ll cry; you’ll wonder why. The conclusion of each chapter includes the following subsections:

Questions

A series of questions for you to consider, and to answer. Do not skip these! They do not ask you to regurgitate the information you’ve just read. They are there to make you think deeper, beyond the original material, and to work out how the topic weaves into your existing experience.

See also

Links to any related chapters in the book, with an explanation of how the chapters fit together.

Try this…

Finally, each chapter is rounded off with a simple challenge. This is a specific task that will help you improve and apply the topic to your coding regimen.

Throughout each chapter, there are particularly important key points. They are highlighted so you don’t miss them.

Key

This is a key point. Take heed.

As you work through each chapter, please do spend time considering the questions and the Try this… challenges. Don’t gloss over them. They’re an important part of Becoming a Better Programmer. If you just flick through the information in each chapter, then it will be just that: information. Hopefully interesting. No doubt informative. But unlikely to make you a much better programmer.

You need to be challenged, and absorb what you read to your programming skillset. These closing exercises won’t take you too long. Honestly. And they will really help cement each chapter’s theme in your mind.

A Note for Mentors

This book has been designed to work as a valuable tool for mentoring fellow programmers. You can use it one-on-one or in a study group.

The best approach to this material is not to methodically work through each section together. Instead, read a chapter separately, and then get together to discuss the contents. The questions really work as a springboard for discussion, so it’s a good idea to start there.

Safari® Books Online

Note

Safari Books Online is an on-demand digital library that delivers expert content in both book and video form from the world’s leading authors in technology and business.

Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.

Safari Books Online offers a range of product mixes and pricing programs for organizations, government agencies, and individuals. Subscribers have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and dozens more. For more information about Safari Books Online, please visit us online.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

  • O’Reilly Media, Inc.
  • 1005 Gravenstein Highway North
  • Sebastopol, CA 95472
  • 800-998-9938 (in the United States or Canada)
  • 707-829-0515 (international or local)
  • 707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at http://bit.ly/becoming_a_better_programmer.

To comment or ask technical questions about this book, send email to .

For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.

Find us on Facebook: http://facebook.com/oreilly

Follow us on Twitter: http://twitter.com/oreillymedia

Watch us on YouTube: http://www.youtube.com/oreillymedia

Acknowledgments

Writing a book is a surprisingly large undertaking: one that tends to take over your life and suck other people into the maelstrom on the way. There are many people who have in some way contributed to the state of this book, from the very early drafts of this material right through until it became the complete tome that rests on your (potentially digital) bookshelf.

My wonderful wife, Bryony, has patiently supported (and put up with) me whilst my finger has been in this pie, alongside the many other pies my other fingers find. I love you, and I appreciate you very much. Alice and Amelia have provided many welcome distractions; you make life fun!

Some parts of this book originated in articles I wrote over the last few years. Steve Love, the esteemed editor of ACCU’s C Vu magazine, has contributed valuable feedback on many of these, and his encouragement and sage opinion has always been appreciated. (If you don’t know about ACCU, it is an awesome organisation for programmers who care about code.)

Many friends and colleagues have contributed valuable inspiration, feedback, and critique. These include my Akai family: Dave English, Will Augar, Łukasz Kozakiewicz, and Geoff Smith. Lisa Crispin and Jon Moore provided insight from the QA perspective, Greg Law taught me facts about bugs, whilst Seb Rose and Chris Oldwood offered much-appreciated and timely reviews.

The technical reviewers—Kevlin Henney, Richard Warburton, and Jim Brikman—provided much valuable feedback and helped shape the text you’re reading. I am grateful for their expert input.

The excellent O’Reilly team of editors and production geniuses have worked hard on this book, and I’m grateful for their skillful attention. In particular, Mike Loukides and Brian MacDonald’s early formative work helped shape the material considerably.

Lorna Ridley drew a chicken, single-handedly preventing this book from being fowl.

Get Becoming a Better Programmer now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.