Previous Next

Becoming a Better Programmer A Handbook for People Who Care About Code (Pete Goodliffe) (z-library.sk, 1lib.sk, z-lib.sk)

Author: Pete Goodliffe

编程

If you’re passionate about programming and want to get better at it, you’ve come to the right source. Code Craft author Pete Goodliffe presents a collection of useful techniques and approaches to the art and craft of programming that will help boost your career and your well-being. Goodliffe presents sound advice that he’s learned in 15 years of professional programming. The book’s standalone chapters span the range of a software developer’s life—dealing with code, learning the trade, and improving performance—with no language or industry bias. Whether you’re a seasoned developer, a neophyte professional, or a hobbyist, you’ll find valuable tips in five independent categories: Code-level techniques for crafting lines of code, testing, debugging, and coping with complexity Practices, approaches, and attitudes: keep it simple, collaborate well, reuse, and create malleable code Tactics for learning effectively, behaving ethically, finding challenges, and avoiding stagnation Practical ways to complete things: use the right tools, know what “done” looks like, and seek help from colleagues Habits for working well with others, and pursuing development as a social activity

📄 File Format: PDF
💾 File Size: 23.0 MB
6
Views
0
Downloads
0.00
Total Donations

📄 Text Preview (First 20 pages)

ℹ️

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

📄 Page 1
Pete Goodliffe Becoming a Better Programmer A HANDBOOK FOR PEOPLE WHO CARE ABOUT CODE
📄 Page 2
PROGR AMMING Becoming a Better Programmer ISBN: 978-1-491-90553-1 US $39.99 CAN $41.99 “ This book will fuel your passion for the art and science of programming. Pete understands that great software comes from good people doing their best work.” —Lisa Crispin Author of Agile Testing: A Practical Guide for Testers and Agile Teams Twitter: @oreillymedia facebook.com/oreilly If you're passionate about programming and want to get better at it, you've come to the right source. Code Craft author Pete Goodliffe presents a collection of useful techniques and approaches to the art and craft of programming that will help boost your career and your well-being. Goodliffe presents sound advice that he's learned in 15 years of professional programming. The book's standalone chapters span the range of a software developer's life—dealing with code, learning the trade, and improving performance—with no language or industry bias. Whether you're a seasoned developer, a neophyte professional, or a hobbyist, you'll find valuable tips in five independent categories: ■ Code-level techniques for crafting lines of code, testing, debugging, and coping with complexity ■ Practices, approaches, and attitudes: keep it simple, collaborate well, reuse, and create malleable code ■ Tactics for learning effectively, behaving ethically, finding challenges, and avoiding stagnation ■ Practical ways to complete things: use the right tools, know what “done” looks like, and seek help from colleagues ■ Habits for working well with others, and pursuing development as a social activity Pete Goodliffe is a programmer, software development columnist,musician, and author. He never stays at the same place in the software food chain. Pete writes a magazine column called “Becoming a Better Programmer,” and has contributed to several software development books. He regularly speaks on software development topics. Pete Goodliffe Becoming a Better Programmer A HANDBOOK FOR PEOPLE WHO CARE ABOUT CODE B ecom ing a B etter Program m er Goodliffe
📄 Page 3
Praise for Becoming a Better Programmer Becoming a Better Programmer oozes experience and communicates the wisdom drawn from a career in the software business. Snappy, single-topic chapters make the book really readable with common themes being tackled from every angle. If you are a software engineer looking to go from good to great, this book is for you. I will be using it with the junior developers I’m responsible for mentoring. — Andrew Burrows lead developer Goodliffe takes the very broad subject of computer programming and manages to break it down into a clear, compelling, and engaging narrative. He has a particular flair for saying things that seem obvious, but I hadn’t realised before he said them. Any programmer who aspires to be a great programmer should read this book. — Greg Law cofounder and CEO of Undo Software Pete Goodliffe successfully blends the theoretical with the practical. Where things must be done in a particular way, he pulls no punches. Where grey areas exist, he clearly explains different points of view. If you consider and apply what he says you’ll benefit and be better; you’ll become a better programmer. Overall this book is full of distilled real-world experience, mixed with humor, to provide gentle wisdom. — Dr. Andrew Bennett BEng/PhD/MIET/MIEEE This book will fuel your passion for the art and science of programming. Pete understands that great software comes from good people doing their best work. He illustrates how to do this through good coding practices, a good attitude, and good relationships, with lots of examples. Bonus: it’s really fun to read! — Lisa Crispin coauthor of Agile Testing: A Practical Guide for Testers and Agile Teams
📄 Page 4
Pete’s got a wealth of experience being a programmer and mentor. In this book, he’s applied the same attention to detail categorising and describing those experiences as he does to the task of actually being a programmer. Knowing about programming is only one part of “being a programmer,” and whether you’re new to the Code Factory, an old hand, or starting to mentor someone, this is a treasure trove of advice about how to go about it—from someone who really knows. It’s a manual about many of the hurdles you’ll encounter, and how to negotiate them safely and effectively. — Steve Love editor of C Vu magazine All too often, programmers are divided into average programmers and rockstar or ninja developers. Where there’s a rockstar, there’s a trashed codebase with broken classes and spaced-out control flow. Where there’s a ninja, there’s mysterious bugs and build problems that appear in the middle of the night. Where there’s an average, there’s a distribution. In the longterm, what matters is less where on the distribution someone is than where they are headed. If you want to divide programmers into two groups, there are programmers who get better and programmers who don’t. You care about the first group. This book is for them. — Kevlin Henney consultant, speaker, and author of 97 Things Every Programmer Should Know This book is quite dull, and I’m not convinced by the fish on the cover. — Alice Goodliffe age 12
📄 Page 5
Pete Goodliffe Becoming a Better Programmer
📄 Page 6
Becoming a Better Programmer by Pete Goodliffe Copyright © 2015 Pete Goodliffe. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safaribooksonline.com). For more information, contact our corporate/ institutional sales department: 800-998-9938 or corporate@oreilly.com. Editors: Mike Loukides and Brian MacDonald Production Editor: Melanie Yarbrough Copyeditor: Jasmine Kwityn Proofreader: Sonia Saruba Indexer: Pete Goodliffe Cover Designer: Karen Montgomery Interior Designer: David Futato Illustrator: Pete Goodliffe October 2014: First Edition Revision History for the First Edition: 2014-10-01: First release See http://oreilly.com/catalog/errata.csp?isbn=9781491905531 for release details. The O’Reilly logo is a registered trademarks of O’Reilly Media, Inc. Becoming a Better Programmer, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc. While the publisher and the author have used good faith efforts to ensure that the information and instruc‐ tions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intel‐ lectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights. ISBN: 978-1-491-90553-1 [LSI]
📄 Page 7
For my wife, Bryony, who I adore. And our three wonderful girls. Psalm 150.
📄 Page 8
(This page has no text content)
📄 Page 9
Table of Contents Also by Pete Goodliffe. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii 1. Care About the Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Adopting the correct approach and attitude to code Part I. you.write(code); 2. Keeping Up Appearances. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Code presentation: layout and naming 3. Write Less Code!. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Avoiding unnecessary lines of code 4. Improve Code by Removing It. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Identifying and removing dead code 5. The Ghost of a Codebase Past. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Learning from the code you wrote in the past 6. Navigating a Route. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 How to start working with unfamiliar code 7. Wallowing in Filth. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Dealing with unpleasant, messy code 8. Don’t Ignore That Error!. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Healthy attitudes for error handling vii
📄 Page 10
9. Expect the Unexpected. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 Writing robust code that considers all possibilities 10. Bug Hunting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 How to find and fix bugs 11. Testing Times. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 Developer testing: unit, integration, and system tests 12. Coping with Complexity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Designing code well, to avoid unnecessary complexity 13. A Tale of Two Systems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 The consequences of good and bad design Part II. Practice Makes Perfect 14. Software Development Is…. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 What is this software stuff? 15. Playing by the Rules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 Inventing rules that define your development team 16. Keep It Simple. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 Striving for simplicity in our software 17. Use Your Brain. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 Programmers are allowed and encouraged to use their brain; don't be stupid! 18. Nothing Is Set in Stone. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 No code is sacred, everything changes 19. A Case for Code Reuse. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 The healthy way to reuse code 20. Effective Version Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 Using version control well viii | Table of Contents
📄 Page 11
21. Getting One Past the Goalpost. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 Working effectively with the QA team 22. The Curious Case of the Frozen Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 Code freeze: what it is, and whether it is necessary 23. Please Release Me. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 Making software releases Part III. Getting Personal 24. Live to Love to Learn. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 How to learn effectively 25. Test-Driven Developers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 Driving as an analogy to programming: how do we learn and pass the test? 26. Relish the Challenge. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 How to find the right challenges to stay motivated and keep your skills sharp 27. Avoid Stagnation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 Preventing your programming skills from going stale 28. The Ethical Programmer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 Ethical issues in the developer's life 29. A Love for Languages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 Learning many programming languages and loving the ones you use 30. Posturing Programmers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 Improving the programmer's health: posture, eye strain, and keeping your spirits up Part IV. Getting Things Done 31. Smarter, Not Harder. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 Working effectively: avoiding unnecessary work and solving the right problems 32. It’s Done When It’s Done. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 Defining your programming tasks and knowing exactly when you're done Table of Contents | ix
📄 Page 12
33. This Time I’ve Got It…. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 Avoiding a narrow focus: find the best way to solve a problem Part V. The People Pursuit 34. People Power. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 How to position yourself alongside excellent programmers, and how to work well in a team 35. It’s the Thought That Accounts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305 Accountability: how it improves you and your work 36. Speak Up!. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 Communication skills for the software developer 37. Many-festos. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323 Software manifestors: what and why? 38. An Ode to Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 A cautionary tale of software mismanagement Epilogue. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 x | Table of Contents
📄 Page 13
Also by Pete Goodliffe Code Craft: The Practice of Writing Excellent Code (No Starch Press) 97 Things Every Programmer Should Know (O’Reilly, contributed three chapters) Beautiful Architecture (O’Reilly, contributed one chapter) xi
📄 Page 14
(This page has no text content)
📄 Page 15
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 ap‐ proaches 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 experi‐ enced, 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: xiii
📄 Page 16
• 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 im‐ provement, 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 com‐ fortable. 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 xiv | Introduction
📄 Page 17
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 fol‐ lowing 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 high‐ lighted 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 Introduction | xv
📄 Page 18
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 program‐ mers. 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 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 crea‐ tive professionals use Safari Books Online as their primary resource for research, prob‐ lem solving, learning, and certification training. Safari Books Online offers a range of product mixes and pricing programs for organi‐ zations, 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 Pro‐ fessional, 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 Technol‐ ogy, 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 xvi | Introduction
📄 Page 19
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 bookques tions@oreilly.com. 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 cri‐ tique. 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—pro‐ vided much valuable feedback and helped shape the text you’re reading. I am grateful for their expert input. Introduction | xvii
📄 Page 20
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. xviii | Introduction
The above is a preview of the first 20 pages. Register to read the complete e-book.

💝 Support Author

0.00
Total Amount (¥)
0
Donation Count

Login to support the author

Login Now

Recommended for You

Loading recommended books...
Failed to load, please try again later
Back to List