English | MP4 | AVC 1280×720 | AAC 44KHz 2ch | 11h 1m | 1.79 GB
Learn how to handle errors, inefficiencies, and outdated paradigms by exploring the most common mistakes you’ll find in production C++ code.
100 C++ Mistakes and How To Avoid Them reveals the problems you’ll inevitably encounter as you write new C++ code and diagnose legacy applications, along with practical techniques you need to resolve them.
Inside 100 C++ Mistakes and How To Avoid Them you’ll learn how to:
- Design solid classes
- Minimize resource allocation/deallocation issues
- Use new C++ features
- Identify the differences between compile and runtime issues
- Recognize C-style idioms that miss C++ functionality
- Use exceptions well
100 C++ Mistakes and How To Avoid Them gives you practical insights and techniques to improve your C++ coding kung fu. Author Rich Yonts has been using C++ since its invention in the 1980s. This book distills that experience into practical, reusable advice on how C++ programmers at any skill level can improve their code. Unlike many C++ books that concentrate on language theory and toy exercises, this book is loaded with real examples from production codebases.
Over ten billion lines of C++ code are running in production applications, and 98-developers find and fix mistakes in them every day. Even mission-critical applications have bugs, performance inefficiencies, and readability problems. This book will help you identify them in the code you’re maintaining and avoid them in the code you’re writing.
100 C++ Mistakes and How To Avoid Them presents practical techniques to improve C++ code, from legacy applications to modern codebases that use C++ 11 and beyond. Author Rich Yonts provides a concrete example to illustrate each issue, along with a step-by-step walkthrough for improving readability, effectiveness, and performance. Along the way, you’ll even learn how and where to replace outdated patterns and idioms with modern C++.
What’s Inside
- Design solid classes
- Resource allocation/deallocation issues
- Compile and runtime problems
- Replace C-style idioms with proper C++
Table of Contents
Chapter 1. C++: With great power comes great responsibility
Chapter 1. Anatomy of a mistake
Chapter 1. Learning from our mistakes
Chapter 1. Where we’ll find mistakes
Chapter 1. A word about organization
Chapter 1. Summary
Part 1. Modern C++
Chapter 2. Better modern C++: Classes and types
Chapter 2. Mistake 2: Using empty exception specifications
Chapter 2. Mistake 3: Not using override on derived virtual functions
Chapter 2. Mistake 4: Writing simple or hiding unwanted supplied class members
Chapter 2. Mistake 5: Not using in-class initializers
Chapter 2. Mistake 6: Overusing index-based loops
Chapter 2. Mistake 7: Failing to use nullptr
Chapter 2. Mistake 8: Not using unique_ptrs for exclusive ownership
Chapter 2. Mistake 9: Not using shared_ptrs for shared ownership
Chapter 3. Better modern C++: General programming
Chapter 3. Mistake 11: Not using type inference for variables
Chapter 3. Mistake 12: Using typedef
Chapter 3. Mistake 13: Writing common algorithms
Chapter 3. Mistake 14: Not using uniform initialization
Chapter 3. Mistake 15: Failing to use emplacement
Chapter 3. Mistake 16: Failing to use tuples
Chapter 3. Mistake 17: Not using structured binding
Chapter 4. Better modern C++: Additional topics
Chapter 4. Mistake 19: Using global namespace enums
Chapter 4. Mistake 20: Not using new formatting functionality
Chapter 4. Mistake 21: Not using ranges with containers
Chapter 4. Mistake 22: Writing nonportable filesystem code
Chapter 4. Mistake 23: Writing excessive standalone functions
Chapter 4. Mistake 24: Using awkward constants
Chapter 4. Mistake 25: Writing pattern-matching code
Part 2. Transitional C++
Chapter 5. C idioms
Chapter 5. Mistake 27: Depending on macros
Chapter 5. Mistake 28: Misunderstanding NULL
Chapter 5. Mistake 29: Accessing disk files using FILE
Chapter 5. Mistake 30: Using integers for Boolean values
Chapter 5. Mistake 31: Using C-style casts
Chapter 5. Mistake 32: Converting text with atoi
Chapter 5. Mistake 33: Using C-style strings
Chapter 5. Mistake 34: Calling the exit function
Chapter 5. Mistake 35: Preferring arrays to vectors
Chapter 6. Better premodern C++
Chapter 6. Mistake 37: Overusing endl
Chapter 6. Mistake 38: Dynamic allocation with malloc and free
Chapter 6. Mistake 39: Using unions for type conversion
Chapter 6. Mistake 40: Using varargs for variable parameter lists
Chapter 6. Mistake 41: Incorrect class initialization order
Chapter 6. Mistake 42: Adding nonvalue types to containers
Chapter 6. Mistake 43: Favoring indexes over iterators
Part 3. Classic (premodern) C++
Chapter 7. Establishing the class invariant
Chapter 7. Mistakes in class design
Chapter 7. Mistake 44: Failing to maintain the class invariant
Chapter 7. Mistake 45: Not thinking of classes as data types
Chapter 7. Mistake 46: Not establishing a basis for methods
Chapter 7. Mistake 47: Failing to code the big 3
Chapter 7. Mistake 48: Using inheritance just for code reuse
Chapter 7. Mistake 49: Overusing default constructors
Chapter 7. Mistake 50: Failing to maintain the is-a relationship
Chapter 8. Maintaining the class invariant
Chapter 8. Mistake 51: Writing nonessential accessors
Chapter 8. Mistake 52: Providing trivial mutators
Chapter 8. Mistake 53: Overusing protected instance variables
Chapter 8. Mistake 54: Mistaking operator= and copy constructor semantics
Chapter 8. Mistake 55: Misunderstanding shallow and deep copy semantics
Chapter 8. Mistake 56: Failing to call base class operators
Chapter 8. Mistake 57: Failing to use virtual destructors in polymorphic base classes
Chapter 8. Mistake 58: Calling virtual functions in constructors and destructors
Chapter 8. Mistake 59: Attempting to use polymorphic array elements
Chapter 8. Mistake 60: Failing to initialize all instance variables
Chapter 9. Class operations
Chapter 9. Mistake 62: Allowing duplication of unique objects
Chapter 9. Mistake 63: Not coding for return value optimization
Chapter 9. Mistake 64: Not returning a reference from copy assignment operators
Chapter 9. Mistake 65: Forgetting to handle self-assignment
Chapter 9. Mistake 66: Misunderstanding prefix and postfix forms
Chapter 9. Mistake 67: Misleading implicit conversion operators
Chapter 9. Mistake 68: Overusing implicit conversion constructors
Chapter 9. Mistake 69: Focusing too much on standalone operators
Chapter 9. Mistake 70: Failing to mark nonmutating methods constant
Chapter 9. Mistake 71: Not properly marking class methods static
Chapter 9. Mistake 72: Incorrectly choosing between member and nonmember functions
Chapter 9. Mistake 73: Incorrectly returning strings from accessor methods
Chapter 10. Exceptions and resources
Chapter 10. Mistake 74: Not throwing exceptions from constructors
Chapter 10. Mistake 75: Throwing exceptions from destructors
Chapter 10. Mistake 76: Allowing resource leaks when using exceptions
Chapter 10. Mistake 77: Failing to use the RAII pattern
Chapter 10. Mistake 78: Using raw pointers to resources
Chapter 10. Mistake 79: Mixing new and delete forms
Chapter 10. Mistake 80: Trusting exception specifications
Chapter 10. Mistake 81: Failing to throw by value and catch by reference
Chapter 11. Functions and coding
Chapter 11. Mistake 82: Using overloaded functions instead of parameter defaulting
Chapter 11. Mistake 83: Failing to use assertions
Chapter 11. Mistake 84: Returning pointers or references to local objects
Chapter 11. Mistake 85: Using output parameters
Chapter 11. Mistake 86: Incorrect use of parameter types
Chapter 11. Mistake 87: Depending on parameter evaluation order
Chapter 11. Mistake 88: Passing excessive parameters
Chapter 11. Mistake 89: Overly long functions with multiple behaviors
Chapter 11. Mistake 90: Overly responsible functions
Chapter 12. General coding
Chapter 12. Mistake 92: Incorrectly using the continue keyword in loops
Chapter 12. Mistake 93: Failing to set deleted pointers to NULL
Chapter 12. Mistake 94: Failing to return directly computed Boolean values
Chapter 12. Mistake 95: Underusing expressions
Chapter 12. Mistake 96: Using extraneous else keywords
Chapter 12. Mistake 97: Not using helper functions
Chapter 12. Mistake 98: Wrongly comparing floating-point values
Chapter 12. Mistake 99: Floating-point to integer assignment
Chapter 12. Mistake 100: Ignoring compiler warnings
Resolve the captcha to access the links!