Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Code Craft
ADVANCE PRAISE FOR CODE CRAFT
PREFACE
What's In It for Me?
Getting Better
Who Should Read This Book?
What's Covered?
How This Book is Organized
The Chapters—a Closer Look
How to Use This Book
A Note to Mentors
ACKNOWLEDGMENTS
ABOUT THE AUTHOR
I. AT THE CODEFACE
1. ON THE DEFENSIVE
Toward Good Code
Assume the Worst
What Is Defensive Programming?
The Big, Bad World
Techniques for Defensive Programming
Employ a Good Coding Style and Sound Design
Don't Code in a Hurry
Trust No One
Write Code for Clarity, Not Brevity
Don't Let Anyone Tinker with Stuff They Shouldn't
Compile with All Warnings Switched On
Use Static Analysis Tools
Use Safe Data Structures
Check Every Return Value
Handle Memory (and Other Precious Resources) Carefully
Initialize All Variables at Their Points of Declaration
Declare Variables as Late as Possible
Use Standard Language Facilities
Use a Good Diagnostic Logging Facility
Cast Carefully
The Fine Print
Constraints
What to Constrain
Removing Constraints
In a Nutshell
See Also
Get Thinking
Mull It Over
Getting Personal
2. THE BEST LAID PLANS
What's the Big Deal?
Know Your Audience
What Is Good Presentation?
Brace Yourself
K&R Brace Style
Exdented Brace Style
Indented Brace Style
Other Brace Styles
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
Mull It Over
Getting Personal
3. WHAT'S IN A NAME?
Why Should We Name Well?
What Do We Name?
Name Games
Descriptive
Technically Correct
Idiomatic
Appropriate
The Nuts and Bolts
Naming Variables
Naming Functions
Naming Types
Naming Namespaces
Naming Macros
Naming Files
A Rose by Any Other Name
Be Consistent
Exploit Context
Use Names to Your Advantage
In a Nutshell
See Also
Get Thinking
Mull It Over
Getting Personal
4. THE WRITESTUFF
Self-Documenting Code
Techniques for Self-Documenting Code
Write Simple Code with Good Presentation
Choose Meaningful Names
Decompose into Atomic Functions
Choose Descriptive Types
Name Constants
Emphasize Important Code
Group-Related Information
Provide a File Header
Handle Errors Appropriately
Write Meaningful Comments
Practical Self-Documentation Methodologies
Literate Programming
Documentation Tools
In a Nutshell
See Also
Get Thinking
Mull It Over
Getting Personal
5. A PASSING COMMENT
What Is a Code Comment?
What Do Comments Look Like?
How Many Comments?
What Goes Inside Our Comments?
Explain Why, Not How
Don't Describe the Code
Don't Replace Code
Keep It Useful
Avoid Distractions
In Practice
A Comment on Aesthetics
Consistency
Clear Block Comments
Indenting Comments
End-of-Line Comments
Helping You to Read the Code
Choose a Low-Maintenance Style
Breakwaters
Flags
File Header Comments
Working with Comments
Helping You to Write Routines
Bug-Fix Notices
Comment Rot
Maintenance and the Inane Comment
In a Nutshell
See Also
Get Thinking
Mull It Over
Getting Personal
6. TO ERR IS HUMAN
From Whence It Came
Error-Reporting Mechanisms
No Reporting
Return Values
Error Status Variables
Exceptions
Signals
Detecting Errors
Handling Errors
When to Deal with Errors
Possible Reactions
Code Implications
Raising Hell
Managing Errors
In a Nutshell
See Also
Get Thinking
Mull It Over
Getting Personal
II. THE SECRET LIFE OF CODE
7. THE PROGRAMMER'S TOOLBOX
What Is a Software Tool?
Why Worry About Tools?
Power Tools
Understand What It Can Do
Learn How to Drive it
Know What Tasks It's Good For
Check That It's Working
Have a Clear Route to Find Out More
Find Out When New Versions Appear
Which Tools?
Source Editing Tools
Source Code Editor
Source Manipulation Tools
Source Navigation Tools
Revision Control
Source Generation
Source Beautifiers
Code Construction Tools
Compiler
Linker
Build Environment
Testing Toolchain
Debugging and Investigative Tools
Debugger
Profiler
Code Validators
Metrics Tools
Disassembler
Fault Tracking
Language Support Tools
The Language
Run Time and Interpreter
Components and Libraries
Miscellaneous Tools
Documentation Tools
Project Management
In a Nutshell
See Also
Get Thinking
Mull It Over
Getting Personal
8. TESTING TIMES
Reality Check
Who, What, When, and Why?
Why We Test
Who Tests
What Testing Involves
When We Test
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?
Fault-Tracking System
Bug Reviews
In a Nutshell
See Also
Get Thinking
Mull It Over
Getting Personal
9. FINDING FAULT
The Facts of Life
Nature of the Beast
The View from 1,000 Feet
The View from the Ground
The View from the Trenches
Pest Extermination
The Low Road
The High Road
Bug Hunting
Compile-Time Errors
Run-Time Errors
Identify a Failure
Reproduce It
Locate the Fault
Understand the Problem
Create a Test
Fix the Fault
Prove You've Fixed It
If All Else Fails
How to Fix Faults
Prevention
Wasp Spray, Slug Repellent, Fly Paper . . .
Debugger
Memory Access Validator
System Call Tracing
Core Dump
Logging
Static Analyzer
In a Nutshell
See Also
Get Thinking
Mull It Over
Getting Personal
10. THE CODE THAT JACK BUILT
Language Barriers
Interpreted Languages
Compiled Languages
Byte-Compiled Languages
Making Mountains out of Molehills
Building Builds
What Makes a Good Build System?
Simplicity
Uniformity
Repeatable and Reliable
Atomic
Coping with Errors
The Mechanics
Choice of Targets
Housekeeping
Dependencies
Automated Builds
Build Configuration
Recursive Make
Please Release Me
Jack-of-All-Trades, Buildmaster Of?
In a Nutshell
See Also
Get Thinking
Mull It Over
Getting Personal
11. THE NEED FOR SPEED
What Is Optimization?
What Makes Code Suboptimal?
Why Not Optimize?
Alternatives
Why Optimize?
The Nuts and Bolts
Prove You Need to Optimize
Identify the Slowest Code
Testing the Code
Optimizing the Code
After Optimization
Optimization Techniques
Design Changes
Code Changes
Writing Efficient Code
In a Nutshell
See Also
Get Thinking
Mull It Over
Getting Personal
12. AN INSECURITY COMPLEX
The Risks
The Opposition
Excuses, Excuses
Feeling Vulnerable
Insecure Design and Architecture
Buffer Overrun
Embedded Query Strings
Race Conditions
Integer Overflow
Protection Racket
System Installation Techniques
Software Design Techniques
Code Implementation Techniques
Procedural Techniques
In a Nutshell
See Also
Get Thinking
Mull It Over
Getting Personal
III. THE SHAPE OF CODE
13. GRAND DESIGNS
Programming as Design
What Do We Design?
What's All the Fuss About?
Good Software Design
Simplicity
Elegance
Modularity
Good Interfaces
Extensibility
Avoid Duplication
Portability
Idiomatic
Well-Documented
How to Design Code
Design Methods and Processes
Design Tools
In a Nutshell
See Also
Get Thinking
Mull It Over
Getting Personal
14. SOFTWARE ARCHITECTURE
What Is Software Architecture?
Software Blueprints
Points of View
Where and When Do You Do It?
What Is It Used For?
Of Components and Connections
Components
Connections
What Is Good Architecture?
Architectural Styles
No Architecture
Layered Architecture
Pipe and Filter Architecture
Client/Server Architecture
Component-Based Architecture
Frameworks
In a Nutshell
See Also
Get Thinking
Mull It Over
Getting Personal
15. SOFTWARE EVOLUTION OR SOFTWARE REVOLUTION?
Software Rot
The Warning Signs
How Does Code Grow?
Believe the Impossible
What Can We Do About This?
Writing New Code
Maintenance of Existing Code
In a Nutshell
See Also
Get Thinking
Mull It Over
Getting Personal
IV. A HERD OF PROGRAMMERS?
16. CODE MONKEYS
Monkey Business
The Eager Coder
The Code Monkey
The Guru
The Demiguru
The Arrogant Genius
The Cowboy
The Planner
The Old Timer
The Zealot
The Monocultured Programmer
The Slacker
The Reluctant Team Leader
You
The Ideal Programmer
So What?
The Stupidest of Men
In a Nutshell
See Also
Action Sheet
Get Thinking
Mull It Over
Getting Personal
17. TOGETHER WE STAND
Our Teams—The Big Picture
Team Organization
Management Approach
Division of Responsibility
Organization and Code Structure
Teamwork Tools
Team Diseases
Tower of Babel
Dictatorship
Development Democracy
Satellite Station
The Grand Canyon
Quicksand
Lemmings
Personal Skills and Characteristics for Good Teamwork
Communication
Humility
Dealing with Conflict
Learning and Adaptability
Know Your Limitations
Teamwork Principles
Collective Code Ownership
Respect Other People's Code
Code Guidelines
Define Success
Define Responsibility
Avoid Burnout
The Team Life Cycle
Team Creation
Team Growth
Inward Team Growth
Outward Team Growth
Teamwork
Team Closure
In a Nutshell
See Also
Action Sheet
Get Thinking
Mull It Over
Getting Personal
18. PRACTICING SAFE SOURCE
Our Responsibility
Source Control
Revision Control
Access Control
Working with the Repository
Leave Branching to the Trees
A Brief History of Source Control
Configuration Management
Backups
Releasing Source Code
Wherever I Lay My Source
In a Nutshell
See Also
Get Thinking
Mull It Over
Getting Personal
V. PART OF THE PROCESS
19. BEING SPECIFIC
What Are They, Specifically?
The Types of Specification
Requirements Specification
Functional Specification
System Architecture Specification
User Interface Specification
Design Specification
Test Specification
What Should Specifications Contain?
The Specification-Writing Process
Why Don't We Write Specifications?
In a Nutshell
See Also
Get Thinking
Mull It Over
Getting Personal
20. A REVIEW TO A KILL
What Is a Code Review?
When Do You Review?
Whether to Review
Which Code to Review
Performing Code Reviews
Code Review Meetings
Where?
When?
Roles and Responsibilities
Agenda
Integration Reviews
Review Your Attitudes
The Author's Attitude
The Reviewer's Attitude
Code Perfection
Beyond the Code Review
In a Nutshell
See Also
Checklist
Get Thinking
Mull It Over
Getting Personal
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
Mull It Over
Getting Personal
VI. VIEW FROM THE TOP
22. RECIPE FOR A PROGRAM
Programming Styles
Structured Programming
Object-Oriented Programming
Functional Programming
Logic Programming
Recipes: The How and the What
Development Processes
Ad Hoc
Waterfall Model
SSADM and PRINCE
V Model
Prototyping
Iterative and Incremental Development
Spiral Model
Agile Methodologies
Other Development Processes
Enough, Already!
Pick a Process
In a Nutshell
See Also
Get Thinking
Mull It Over
Getting Personal
23. THE OUTER LIMITS
Applications Programming
Shrink-Wrap Software
Custom Applications
Games Programming
Systems Programming
Embedded Programming
Distributed Programming
Web Application Programming
Enterprise Programming
Numerical Programming
So What?
In a Nutshell
See Also
Get Thinking
Mull It Over
Getting Personal
24. WHERE NEXT?
But What Now?
A. Answers and Discussion
Chapter 1
Mull It Over
Getting Personal
Chapter 2
Mull It Over
Getting Personal
Chapter 3
Mull It Over
Getting Personal
Chapter 4
Mull It Over
Getting Personal
Chapter 5
Mull It Over
Getting Personal
Chapter 6
Mull It Over
Getting Personal
Chapter 7
Mull It Over
Getting Personal
Chapter 8
Mull It Over
Getting Personal
Chapter 9
Mull It Over
Getting Personal
Chapter 10
Mull It Over
Getting Personal
Chapter 11
Mull It Over
Getting Personal
Chapter 12
Mull It Over
Getting Personal
Chapter 13
Mull It Over
Getting Personal
Chapter 14
Mull It Over
Getting Personal
Chapter 15
Mull It Over
Getting Personal
Chapter 16
Mull It Over
Chapter 17
Mull It Over
Getting Personal
Chapter 18
Mull It Over
Getting Personal
Chatper 19: Being Specific
Mull It Over
Getting Personal
Chapter 20
Mull It Over
Getting Personal
Chapter 21
Mull It Over
Getting Personal
Chapter 22
Mull It Over
Getting Personal
Chapter 23
Mull It Over
Getting Personal
BIBLIOGRAPHY
COLOPHON
← Prev
Back
Next →
← Prev
Back
Next →