Many programmers know how to write correct code - code that works. But not all know how to craft great code - code that is well written and easy to understand. Code Craft teaches programmers how to move beyond writing correct code to writing great code. The book covers code writing concerns, including code presentation style, variable naming, error handling, and security; and the wider issues of programming in the real world, such as good teamwork, development processes, and documentation. Code Craft presents language-agnostic advice that is relevant to all developers, from an author with loads of practical experience. A Q&A section at the end of each chapter helps readers to review the material and makes the book suited for academic use as well.
AT THE CODEFACE
Chapter 1 ON THE DEFENSIVE
Toward Good Code
Assume the Worst
What Is Defensive Programming?
The Big, Bad World
In a Nutshell
See Also
Get Thinking
Chapter 2 THE BEST LAID PLANS
What's the Big Deal?
Know Your Audience
What Is Good Presentation?
Brace Yourself
One Style to Rule Them All
House Styles (and Where to Stick Them)
Setting the Standard
Righteous Wars?
In a Nutshell
See Also
Get Thinking
Chapter 3 WHAT'S IN A NAME?
Why Should We Name Well?
What Do We Name?
Name Games
The Nuts and Bolts
A Rose by Any Other Name
In a Nutshell
See Also
Get Thinking
Chapter 4 THE WRITESTUFF
Self-Documenting Code
Techniques for Self-Documenting Code
Practical Self-Documentation Methodologies
In a Nutshell
See Also
Get Thinking
Chapter 5 A PASSING COMMENT
What Is a Code Comment?
What Do Comments Look Like?
How Many Comments?
What Goes Inside Our Comments?
In Practice
A Comment on Aesthetics
Working with Comments
In a Nutshell
See Also
Get Thinking
Chapter 6 TO ERR IS HUMAN
From Whence It Came
Error-Reporting Mechanisms
Detecting Errors
Handling Errors
Raising Hell
Managing Errors
In a Nutshell
See Also
Get Thinking
THE SECRET LIFE OF CODE
Chapter 7 THE PROGRAMMER'S TOOLBOX
What Is a Software Tool?
Why Worry About Tools?
Power Tools
Which Tools?
In a Nutshell
See Also
Get Thinking
Chapter 8 TESTING TIMES
Reality Check
Who, What, When, and Why?
Testing Isn't Hard . . .
The Types of Test
Choosing Unit Test Cases
Design for Test
Look! No Hands!
The Face of Failure
Can You Manage It?
In a Nutshell
See Also
Get Thinking
Chapter 9 FINDING FAULT
The Facts of Life
Nature of the Beast
Pest Extermination
Bug Hunting
How to Fix Faults
Prevention
Wasp Spray, Slug Repellent, Fly Paper . . .
In a Nutshell
See Also
Get Thinking
Chapter 10 THE CODE THAT JACK BUILT
Language Barriers
Making Mountains out of Molehills
Building Builds
What Makes a Good Build System?
The Mechanics
Please Release Me
Jack-of-All-Trades, Buildmaster Of?
In a Nutshell
See Also
Get Thinking
Chapter 11 THE NEED FOR SPEED
What Is Optimization?
What Makes Code Suboptimal?
Why Not Optimize?
Why Optimize?
The Nuts and Bolts
Optimization Techniques
Writing Efficient Code
In a Nutshell
See Also
Get Thinking
Chapter 12 AN INSECURITY COMPLEX
The Risks
The Opposition
Excuses, Excuses
Feeling Vulnerable
Protection Racket
In a Nutshell
See Also
Get Thinking
THE SHAPE OF CODE
Chapter 13 GRAND DESIGNS
Programming as Design
What Do We Design?
What's All the Fuss About?
Good Software Design
How to Design Code
In a Nutshell
See Also
Get Thinking
Chapter 14 SOFTWARE ARCHITECTURE
What Is Software Architecture?
What Is Good Architecture?
Architectural Styles
In a Nutshell
See Also
Get Thinking
Chapter 15 SOFTWARE EVOLUTION OR SOFTWARE REVOLUTION?
Software Rot
The Warning Signs
How Does Code Grow?
Believe the Impossible
What Can We Do About This?
In a Nutshell
See Also
Get Thinking
A HERD OF PROGRAMMERS?
Chapter 16 CODE MONKEYS
Monkey Business
The Ideal Programmer
So What?
The Stupidest of Men
In a Nutshell
See Also
Action Sheet
Get Thinking
Chapter 17 TOGETHER WE STAND
Our Teams—The Big Picture
Team Organization
Teamwork Tools
Team Diseases
Personal Skills and Characteristics for Good Teamwork
Teamwork Principles
The Team Life Cycle
In a Nutshell
See Also
Action Sheet
Get Thinking
Chapter 18 PRACTICING SAFE SOURCE
Our Responsibility
Source Control
Configuration Management
Backups
Releasing Source Code
Wherever I Lay My Source
In a Nutshell
See Also
Get Thinking
PART OF THE PROCESS
Chapter 19 BEING SPECIFIC
What Are They, Specifically?
The Types of Specification
What Should Specifications Contain?
The Specification-Writing Process
Why Don't We Write Specifications?
In a Nutshell
See Also
Get Thinking
Chapter 20 A REVIEW TO A KILL
What Is a Code Review?
When Do You Review?
Performing Code Reviews
Review Your Attitudes
Code Perfection
Beyond the Code Review
In a Nutshell
See Also
Checklist
Get Thinking
Chapter 21 HOW LONG IS A PIECE OF STRING?
A Stab in the Dark
Why Is Estimation So Hard?
Under Pressure
Practical Ways to Estimate
The Planning Game
Keep Up!
In a Nutshell
See Also
Get Thinking
VIEW FROM THE TOP
Chapter 22 RECIPE FOR A PROGRAM
Programming Styles
Recipes: The How and the What
Development Processes
Enough, Already!
Pick a Process
In a Nutshell
See Also
Get Thinking
Chapter 23 THE OUTER LIMITS
Applications Programming
Games Programming
Systems Programming
Embedded Programming
Distributed Programming
Web Application Programming
Enterprise Programming
Numerical Programming
So What?
In a Nutshell
See Also
Get Thinking
Chapter 24 WHERE NEXT?
But What Now?
Appendix Answers and Discussion
Chapter 1: On the Defensive
Chapter 2: The Best Laid Plans
Chapter 3: What’s in a Name?
Chapter 4: The Write Stuff
Chapter 5: A Passing Comment
Chapter 6: To Err Is Human
Chapter 7: The Programmer’s Toolbox
Chapter 8: Testing Times
Chapter 9: Finding Fault
Chapter 10: The Code That Jack Built
Chapter 11: The Need for Speed
Chapter 12: An Insecurity Complex
Chapter 13: Grand Designs
Chapter 14: Software Architecture
Chapter 15: Software Evolution or Software Revolution?
Pete Goodliffe is a senior software engineer, currently working on embedded systems in C++. He never stays at the same place in the software food chain; from bringing new systems up, writing device drivers, through OS implementation, audio codecs, JVM implementation, to MIDI sequencing applications. He writes a regular column for accu.org called Professionalism in Programming and has published articles on software development in Hardcopy, C/C++ Users Journal, and Dr Dobb's Journal.