Synopses & Reviews
Rewire your brain
Examples in this book are written in C++, but will improve your ability to think like a programmer in any language.
The real challenge of programming isn't learning a language's syntax—it's learning to creatively solve problems so you can build something great. In this one-of-a-kind text, author V. Anton Spraul breaks down the ways that programmers solve problems and teaches you what other introductory books often ignore: how to Think Like a Programmer. Each chapter tackles a single programming concept, like classes, pointers, and recursion, and open-ended exercises throughout challenge you to apply your knowledge. You'll also learn how to:
- Split problems into discrete components to make them easier to solve
- Make the most of code reuse with functions, classes, and libraries
- Pick the perfect data structure for a particular job
- Master more advanced programming tools like recursion and dynamic memory
- Organize your thoughts and develop strategies to tackle particular types of problems
Although the book's examples are written in C++, the creative problem-solving concepts they illustrate go beyond any particular language; in fact, they often reach outside the realm of computer science. As the most skillful programmers know, writing great code is a creative art—and the first step in creating your masterpiece is learning to Think Like a Programmer.
Many programmers struggle to write programs, even though they understand their chosen programming language. Programming isn't about syntax—it's about problem solving, and all good programmers can solve problems. Unfortunately, most programming books focus on syntax and semantics, resulting in programmers who can't make the leap from reading programs to writing them. Think Like a Programmer bridges that gap, teaching readers how to solve problems systematically, offering numerous techniques and examples designed to demonstrate how to organize thoughts, discover solutions, and find strategies to solve certain classes of problems. Programming, and especially problem solving, is a creative activity, and although this book won't tell anyone precisely what to do in a given circumstance, it will help readers develop their latent problem-solving abilities so that they will know what they should do. Think Like a Programmer is designed to help readers become the programmers they were meant to be.
About the Author
V. Anton Spraul has taught introductory programming and computer science for more than 15 years. This book is a distillation of the techniques he has used and honed over many one-on-one sessions with struggling programers. He is also the author of Computer Science Made Simple (Broadway).
Table of Contents
Acknowledgments; Introduction; About This Book; Chapter 1: Strategies for Problem Solving; 1.1 Classic Puzzles; 1.2 General Problem-Solving Techniques; 1.3 Exercises; Chapter 2: Pure Puzzles; 2.1 Review of C++ Used in This Chapter; 2.2 Output Patterns; 2.3 Input Processing; 2.4 Tracking State; 2.5 Conclusion; 2.6 Exercises; Chapter 3: Solving Problems with Arrays; 3.1 Review of Array Fundamentals; 3.2 Solving Problems with Arrays; 3.3 Arrays of Fixed Data; 3.4 Non-scalar Arrays; 3.5 Multidimensional Arrays; 3.6 Deciding When to Use Arrays; 3.7 Exercises; Chapter 4: Solving Problems with Pointers and Dynamic Memory; 4.1 Review of Pointer Fundamentals; 4.2 Benefits of Pointers; 4.3 When to Use Pointers; 4.4 Memory Matters; 4.5 Solving Pointer Problems; 4.6 Conclusion and Next Steps; 4.7 Exercises; Chapter 5: Solving Problems with Classes; 5.1 Review of Class Fundamentals; 5.2 Goals of Class Use; 5.3 Building a Simple Class; 5.4 Classes with Dynamic Data; 5.5 Mistakes to Avoid; 5.6 Exercises; Chapter 6: Solving Problems with Recursion; 6.1 Review of Recursion Fundamentals; 6.2 Head and Tail Recursion; 6.3 The Big Recursive Idea; 6.4 Common Mistakes; 6.5 Applying Recursion to Dynamic Data Structures; 6.6 Wrapper Functions; 6.7 When to Choose Recursion; 6.8 Exercises; Chapter 7: Solving Problems with Code Reuse; 7.1 Good Reuse and Bad Reuse; 7.2 Review of Component Fundamentals; 7.3 Building Component Knowledge; 7.4 Choosing a Component Type; 7.5 Exercises; Chapter 8: Thinking Like a Programmer; 8.1 Creating Your Own Master Plan; 8.2 Tackling Any Problem; 8.3 Required Operations for Cheating at Hangman; 8.4 Learning New Programming Skills; 8.5 Conclusion; 8.6 Exercises; Colophon; Updates;