Sustainable Software Development With Clean C++
Sustainable Software Development With Clean C++

Retired

This book is no longer available for sale.

Sustainable Software Development With Clean C++

This book is 60% complete

Last updated on 2016-04-09

About the Book

This book has been retired!

After a full revision and completion during the last year, the completely revised and updated book will be published by Apress Media LLC under the title "Clean C++ - Sustainable Software Development With C++17" (http://www.apress.com/la/book/9781484227923). The publishing date will be approximately at the end of 2017/beginning of 2018. The book will be proofread and edited by professionals, thus it will provide a much better reading experience. Furthermore, it will be updated according to the latest developments in the C++ domain and takes also a few of the newest C++17 features into account.

I would like to take this opportunity to thank all readers for purchasing its predecessor here.

Best regards,

Stephan

(July 2017)

About the Author

Stephan Roth
Stephan Roth

Stephan is coach, consultant and trainer for systems and software engineering with German consultancy company oose Innovative Informatik eG located in Hamburg. Before he joined oose, he worked for many years as a software developer, software architect and systems engineer in the field of radio reconnaissance and communication intelligence systems. He has developed sophisticated applications, especially in a high performance system environment, and graphical user interfaces using C++ and other programming languages. Stephan is an active supporter of the Software Craftsmanship movement and is concerned with principles and practices of Clean Code Development (CCD).

Table of Contents

    • Foreword
    • About The Author
    • Introduction
      • Why C++?
      • Who this book is for
      • Conventions used in this book
        • Sidebars
        • Code samples
          • Coding style
        • Source code repository
        • UML diagrams
      • This book is work in progress
        • Outlook: upcoming chapters and topics
  • Part 1: Principles and Rules
    • 1. Build a safety net!
      • The need for testing
      • Introduction into testing
        • Unit Tests
        • What about QA?
        • Rules For Good Unit Tests
          • Test code quality
          • Unit test naming
          • Unit test independence
          • One assertion per test
          • Independent initialization of Unit Test environments
          • Exclude getters and setters
          • Exclude 3 party code
          • Exclude external systems
          • And what about the database?
          • Don’t mix test code with production code
          • Tests must run fast
        • Test doubles (Fake objects)
      • C++ Test frameworks
    • 2. Be principled
      • What is a principle?
      • Important basic principles
        • KISS
        • YAGNI
        • DRY
        • Information hiding
        • High cohesion
        • Loose coupling
        • Be careful with optimizations
        • Principle of Least Astonishment (PLA)
        • The Boy Scout Rule
    • 3. Basics of clean C++
      • Good names
        • Names should be self-explanatory
        • Choose names at an appropriate level of abstraction
        • Avoid redundancy when choosing a name
        • Avoid cryptic abbreviations
        • Avoid Hungarian notation and prefixes
        • Avoid using the same name for different purposes
      • Comments
        • Avoid comments
        • Do not comment obvious things
        • Documentation generation from source code
        • Don’t disable code with comments
        • Don’t write block comments
      • Functions
        • One thing, no more!
        • Let them be small
          • “But the call time overhead!”
        • Function naming
        • Use intention-revealing names
        • Arguments and return values
          • Number of arguments
          • Avoid flag arguments
          • Avoid output arguments
          • Don’t pass or return 0 (NULL, nullptr)
          • Strategies to avoid regular pointers
        • Const correctness
        • Write exception-safe code
      • Formatting
      • Don’t allow undefined behaviour
      • Resource management
        • Resource Acquisition Is Initialization (RAII)
          • STL smart pointers
      • About old C-style in C++ projects
        • Prefer C++ strings and streams over old C-style char*
          • Avoid using printf(), sprintf(), gets(), etc.
        • Prefer STL containers over simple C-style arrays
        • Use C++ casts instead of old C-style casts
          • reinterpret_cast and dynamic_cast are bad!
          • Avoid macros
      • Type-rich programming
      • Take advantage of <algorithm>
        • Sorting and output of a container
        • Comparing two sequences
      • Take advantage of Boost
      • Logging
    • 4. Object Orientation
      • Object-Oriented Thinking
      • Classes
      • Rules for good class design
        • Keep classes small
        • Single Responsibility Principle (SRP)
        • Open-Closed Principle (OCP)
        • Liskov Substitution Principle (LSP)
        • Interface Segregation Principle (ISP)
        • Dependency Inversion Principle (DIP)
      • Misuses of classes
  • Part 2: Practices and Patterns
    • 5. Test Driven Development
      • The workflow of TDD
      • TDD By Example: Roman Numerals
      • When we should not use TDD
    • 6. Design Patterns and Idioms
      • What is a design pattern?
      • Some patterns, and when to use them
        • Strategy
        • Template Method
        • Composite
        • Command
        • Command Processor
        • Decorator
        • State
        • Observer
        • Factory Method
        • Prototype
        • Adapter
        • Facade
        • Money Class
        • Special Case Object
        • Actor-Role
        • Fluent Interface
        • Pipeline
      • What is an idiom?
      • Common C++ Idioms
        • Function-like objects (Functor)
        • Virtual constructor
        • Traits
        • Curiously Recurring Template Pattern (CRTP)
        • (Private) Pointer To Implementation (PIMPL)
        • Resource Acquisition Is Initialization (RAII)
        • The Barton–Nackman trick
        • Non-copyable Mixin
    • Appendix A: Small UML Guide
      • Class Diagrams
        • Class
        • Interface
        • Association
        • Generalization
        • Dependency
      • Stereotypes
    • Bibliography

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Write and Publish on Leanpub

Authors, publishers and universities use Leanpub to publish amazing in-progress and completed books and courses, just like this one. You can use Leanpub to write, publish and sell your book or course as well! Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks. Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. It really is that easy.

Learn more about writing on Leanpub