Roth | Clean C++20 | E-Book | www2.sack.de
E-Book

E-Book, Englisch, 491 Seiten

Reihe: Professional and Applied Computing (R0)

Roth Clean C++20

Sustainable Software Development Patterns and Best Practices
2. Auflage 2021
ISBN: 978-1-4842-5949-8
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark

Sustainable Software Development Patterns and Best Practices

E-Book, Englisch, 491 Seiten

Reihe: Professional and Applied Computing (R0)

ISBN: 978-1-4842-5949-8
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark



Write maintainable, extensible, and durable software with modern C++. This book, updated for the recently released C++20 standard, is a must for every developer, software architect, or team leader who is interested in well-crafted C++ code, and thus also wants to save development costs. If you want to teach yourself about writing better C++ code, Clean C++20 is exactly what you need. It is written for C++ developers of all skill levels and shows by example how to write understandable, flexible, maintainable, and efficient C++ code. Even if you are a seasoned C++ developer, there are nuggets and data points in this book that you will find useful in your work.
If you don't take care with your codebase, you can produce a large, messy, and unmaintainable beast in any programming language. However, C++ projects in particular are prone to get messy and tend to slip into a maintenance nightmare. There is lots of C++ code out there that looksas if it was written in the 1980s, completely ignoring principles and practices of well-written and modern C++.
It seems that C++ developers have been forgotten by those who preach Software Craftsmanship and Clean Code principles. The web is full of C++ code examples that may be very fast and highly optimized, but whose developers have completely ignored elementary principles of good design and well-written code. This book will explain how to avoid this and how to get the most out of your C++ code. You'll find your coding becomes more efficient and, importantly, more fun.
What You Will Learn
  • Gain sound principles and rules for clean coding in C++
  • Carry out test-driven development (TDD)
  • Better modularize your C++ code base
  • Discover and apply C++ design patterns and idioms
  • Write C++ code in both object-oriented and functional programming styles
Who This Book Is For
Any C++ developer or software engineer with an interest in producing better code. 


Roth Clean C++20 jetzt bestellen!

Autoren/Hrsg.


Weitere Infos & Material


1;Table of Contents;5
2;About the Author;12
3;About the Technical Reviewer;13
4;Acknowledgments;14
5;Chapter 1: Introduction;15
5.1;Software Entropy;17
5.1.1;Why C++?;18
5.2;Clean Code;20
5.3;C++11: The Beginning of a New Era;20
5.4;Who This Book Is For;21
5.5;Conventions Used in This Book;22
5.5.1;Sidebars;23
5.5.2;Notes, Tips, and Warnings;23
5.5.3;Code Samples;23
5.5.3.1;Coding Style;24
5.5.3.2;C++ Core Guidelines;25
5.6;Companion Website and Source Code Repository;25
5.7;UML Diagrams;26
6;Chapter 2: Build a Safety Net;27
6.1;The Need for Testing;27
6.2;Introduction to Testing;30
6.3;Unit Tests;33
6.4;What About QA?;35
6.5;Rules for Good Unit Tests;36
6.5.1;Test Code Quality;36
6.5.2;Unit Test Naming;36
6.5.3;Unit Test Independence;38
6.5.4;One Assertion per Test;39
6.5.5;Independent Initialization of Unit Test Environments;40
6.5.6;Exclude Getters and Setters;41
6.5.7;Exclude Third-Party Code;41
6.5.8;Exclude External Systems;42
6.5.9;What Do We Do with the Database?;42
6.5.10;Don’t Mix Test Code with Production Code;43
6.5.11;Tests Must Run Fast;46
6.5.12;How Do You Find a Test’s Input Data?;47
6.5.12.1;Equivalence Partitioning;47
6.5.12.2;Boundary Value Analysis;49
6.5.13;Test Doubles (Fake Objects);50
7;Chapter 3: Be Principled;54
7.1;What Is a Principle?;54
7.2;KISS;55
7.3;YAGNI;56
7.4;DRY;57
7.4.1;It’s About Knowledge!;57
7.4.2;Building Abstractions Is Sometimes Hard;58
7.5;Information Hiding;61
7.6;Strong Cohesion;66
7.7;Loose Coupling;69
7.8;Be Careful with Optimizations;73
7.9;Principle of Least Astonishment (PLA);74
7.10;The Boy Scout Rule;75
7.10.1;Collective Code Ownership;76
8;Chapter 4: Basics of Clean C++;77
8.1;Good Names;78
8.1.1;Names Should Be Self-Explanatory;80
8.1.2;Use Names from the Domain;82
8.1.3;Choose Names at an Appropriate Level of Abstraction;84
8.1.4;Avoid Redundancy When Choosing a Name;85
8.1.5;Avoid Cryptic Abbreviations;86
8.1.6;Avoid Hungarian Notation and Prefixes;87
8.1.7;Avoid Using the Same Name for Different Purposes;88
8.2;Comments;89
8.2.1;Let the Code Tell the Story;89
8.2.2;Do Not Comment Obvious Things;90
8.2.3;Don’t Disable Code with Comments;91
8.2.4;Don’t Write Block Comments;92
8.2.4.1;Don’t Use Comments to Substitute Version Control;96
8.2.5;The Rare Cases Where Comments Are Useful;96
8.2.5.1;Documentation Generation from Source Code;98
8.3;Functions;101
8.3.1;One Thing, No More!;105
8.3.2;Let Them Be Small;106
8.3.2.1;“But the Call Time Overhead!”;107
8.3.3;Function Naming;108
8.3.4;Use Intention-Revealing Names;109
8.3.5;Parameters and Return Values;110
8.3.5.1;Number of Parameters;110
8.3.5.2;Avoid Flag Parameters;112
8.3.5.3;Avoid Output Parameters;115
8.3.5.4;Don’t Pass or Return 0 (NULL, nullptr);116
8.3.5.5;Strategies for Avoiding Regular Pointers;119
8.3.5.5.1;Choose simple object construction on the stack instead of on the heap;119
8.3.5.5.2;In a function’s argument list, use (const) references instead of pointers;122
8.3.5.5.3;If it is inevitable to deal with a pointer to a resource, use a smart one;123
8.3.5.5.4;If an API returns a raw pointer...;123
8.3.5.6;The Power of const Correctness;124
8.4;About Old C-Style in C++ Projects;126
8.4.1;Choose C++ Strings and Streams over Old C-Style char*;127
8.4.2;Avoid Using printf(), sprintf(), gets(), etc.;129
8.4.3;Choose Standard Library Containers over Simple C-Style Arrays;134
8.4.4;Use C++ Casts Instead of Old C-Style Casts;137
8.4.5;Avoid Macros;140
9;Chapter 5: Advanced Concepts of Modern C++;143
9.1;Managing Resources;144
9.1.1;Resource Acquisition Is Initialization (RAII);146
9.1.2;Smart Pointers;147
9.1.2.1;Unique Ownership with std::unique_ptr



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.