• Complain

Jason Turner - C++ Best Practices. 45ish Simple Rules with Specific Action Items for Better C++

Here you can read online Jason Turner - C++ Best Practices. 45ish Simple Rules with Specific Action Items for Better C++ full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2022, publisher: leanpub.com, genre: Home and family. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

No cover
  • Book:
    C++ Best Practices. 45ish Simple Rules with Specific Action Items for Better C++
  • Author:
  • Publisher:
    leanpub.com
  • Genre:
  • Year:
    2022
  • Rating:
    4 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 80
    • 1
    • 2
    • 3
    • 4
    • 5

C++ Best Practices. 45ish Simple Rules with Specific Action Items for Better C++: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "C++ Best Practices. 45ish Simple Rules with Specific Action Items for Better C++" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Jason Turner: author's other books


Who wrote C++ Best Practices. 45ish Simple Rules with Specific Action Items for Better C++? Find out the surname, the name of the author of the book and a list of all author's works by series.

C++ Best Practices. 45ish Simple Rules with Specific Action Items for Better C++ — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "C++ Best Practices. 45ish Simple Rules with Specific Action Items for Better C++" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
C Best Practices 45ish Simple Rules with Specific Action Items for Better C - photo 1
C++ Best Practices
45ish Simple Rules with Specific Action Items for Better C++
Jason Turner

This book is for sale at http://leanpub.com/cppbestpractices

This version was published on 2022-03-15

This is a Leanpub book Leanpub empowers authors and publishers with - photo 2

* * * * *

This is a Leanpub book. Leanpub empowers authors and publishers with the Lean Publishing process. Lean Publishing is the act of publishing an in-progress ebook using lightweight tools and many iterations to get reader feedback, pivot until you have the right book and build traction once you do.

* * * * *

2020 - 2022 Jason Turner

For my wife Jen, and her love of silly alpaca.

The cover picture was taken by my wife while visiting Red Fox Alpaca Ranch in Evergreen, Colorado.

Introduction

This is a special edition book printed for CppCon 2021 that contains all fixes in the current digital edition plus several new Work-In-Progress (WIP) chapters added to the end.

My goal as a trainer and a contractor (seems to be) to work me out of a job. I want everyone to:

  1. Learn how to experiment for themselves
  2. Not just believe me, but test it
  3. Learn how the language works
  4. Stop making the same mistakes of the last generation

Im thinking about changing my title from C++ Trainer to C++ Guide. I always adapt my courses and material to the class I currently have. We might agree on a class about X, but I change it to Y halfway through the first day to meet the organizations needs.

Along the way, we experiment and learn as a group. I often also learn while teaching. Every group is unique; every class has new questions.

Many of the questions I get in classes are the same ones repeatedly to the point where I get to look like a mind reader as I anticipate the next question that will be asked.

Hence, this book, and the Twitter thread that it came from, to help spread the word on the long-standing best practices.

I wrote the book I wanted to read. It is intentionally straightforward, short, to the point, and has specific action items.

About Best Practices

Best Practices, quite simply, are about

  1. Reducing common mistakes
  2. Finding errors quickly
  3. Without sacrificing (and often improving) performance
Why Best Practices?

First and foremost, lets get this out of the way:

Your Project Is Not Special

If you are programming in C++, you, or someone at your company, cares about performance. Otherwise, theyd probably be using some other programming language. Ive been to many companies who all tell me they are special because they need to do things fast!

Spoiler alert: they are all making the same decisions for the same reasons.

There are very few exceptions. The outliers who make different decisions: they are the organizations that are already following the advice in this book.

Whats The Worst That Can Happen?

I dont want to be depressing, but lets take a moment to ponder the worst-case scenario if your project has a critical flaw.

GameSerious flaws lead to remote vulnerability or attack vector.FinancialSerious flaws lead to large amounts of lost money, accelerating trades, market crash.AerospaceSerious flaws lead to lost spacecraft or human life.Your IndustrySerious flaws lead to Lost money? Lost jobs? Remote hacks? Worse?
Examples

Examples throughout this book use struct instead of class. The only difference between struct and class is that struct has all members and base classes by default public. Using struct makes examples shorter and easier to read.

Exercises

Each section has one or more exercises. Most do not have a right or wrong answer.

Exercise: Look for exercises

Throughout the following chapters, youll see exercises like this one. Look for them!

Exercises are:

  • Practical, and apply to your current code base to see immediate value.
  • Make you think and understand the language a little bit deeper by doing your own research.
Links and References

Ive made an effort to reference those who I learned from and link to their talks where possible. If Ive missed something, please let me know.

Use the Tools: Automated Tests

You need a single command to run tests.
If you dont have that, no one will run the tests.

  • Catch2 - popular and well supported testing framework from Phil Nash and Martin Hoeovsk
  • doctest - similar to catch2, but trimmed for compile-time performance
  • Google Test
  • Boost.Test - testing framework, boost style.

ctest is a test runner for CMake that can be used with any of the above frameworks. It is utilized via the add_test feature of CMake.

You need to be familiar with these tools, what they do, and pick from them.

Without automated tests, the rest of this book is pointless. You cannot apply the practical exercises if you cannot verify that you did not break the existing code.

Oleg Rabaev on CppCast stated:

  • If a component is hard to test, it is not properly designed.
  • If a component is easy to test, it is a good indication that it is properly designed.
  • If a component is properly designed, it is easy to test.
Exercise: Can you run a single command to run a suite of tests?
  • Yes: Excellent! Run the tests and make sure they all pass!
  • No: Does your program produce output?
    • Yes: Start with Approval Tests, which will give you the foundation you need to get started with testing.
    • No: Develop a strategy for how to implement some minimal form of testing.
Resources
  • CppCon 2018: Phil Nash Modern C++ Testing with Catch2
  • CppCon 2019: Clare Macrae Quickly Testing Legacy C++ Code with Approval Tests
  • C++ on Sea 2020: Clare Macrae Quickly and Effectively Testing Legacy C++ Code with Approval Tests
Use the Tools: Continuous Builds

Without automated tests, it is impossible to maintain project quality.

In the C++ projects I have worked on throughout my career, Ive had to support some combination of:

  • x86
  • x64
  • SPARC
  • ARM
  • MIPSEL

On

  • Windows
  • Solaris
  • MacOS
  • Linux

When you start to combine multiple compilers across multiple platforms and architectures, it becomes increasingly likely that a significant change on one platform will break one or more other platforms.

To solve this problem, enable continuous builds with continuous tests for your projects.

  • Test all possible combinations of platforms that you support
  • Test Debug and Release separately
  • Test all configuration options
  • Test against newer compilers than you support or require

If you dont require 100% tests passing, you will never know the codes state.

Exercise: Enable continuous builds

Understand your organizations current continuous build environment. If one does not exist, what are the barriers to getting it set up? How hard would it be to get something like GitLab, GitHub actions, Appveyor, or Travis set up for your projects?

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «C++ Best Practices. 45ish Simple Rules with Specific Action Items for Better C++»

Look at similar books to C++ Best Practices. 45ish Simple Rules with Specific Action Items for Better C++. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «C++ Best Practices. 45ish Simple Rules with Specific Action Items for Better C++»

Discussion, reviews of the book C++ Best Practices. 45ish Simple Rules with Specific Action Items for Better C++ and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.