Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing C++ the Right Way #175

Closed
lefticus opened this issue Oct 18, 2022 · 9 comments
Closed

Writing C++ the Right Way #175

lefticus opened this issue Oct 18, 2022 · 9 comments

Comments

@lefticus
Copy link
Owner

We are in a golden age of C++ tooling, many of them are even free!

  • add CI
  • setup tests (use something like approval tests if starting with existing code)
  • enable as many warnings as possible
  • turn on warnings as errors
  • add 2 (or more) compilers
  • enable more warnings
  • enable more warnings
  • use an IDE with real-time feedback of errors and analysis
  • (You might have to enable one at a time if you are starting on an existing code base)
  • add static analysis tools
  • enable runtime analysis
  • enable fuzzing
@lefticus
Copy link
Owner Author

We are in a golden age of C++ tools

If you are developing blindly, without any tool guidance, you are doing C++ wrong. Think of these tools like a backup camera in your car. Certainly you can back up without a camera, but having one gives you a second set of eyes, deeper into the action than is possible with your human eyes.

You need:

See more info about tools and specific compiler options and flags here: https://github.com/cpp-best-practices/cppbestpractices/blob/master/02-Use_the_Tools_Available.md

Using an IDE or plugin for your IDE can help integrate many of these things as well.

@lefticus
Copy link
Owner Author

Coming in episode 350

@daixtrose
Copy link

  • An organized testing framework

I find ut quite promising.

@njk42
Copy link

njk42 commented Nov 21, 2022

Very useful summary @lefticus!

One comment/request for future content... I hope this is an OK to post this: Many (all?) of the testing frameworks mentioned on C++ Weekly as well as numerous online conference presentations, v-blogs, etc. focus primarily on UNIT testing. It would be awesome to learn about some "higher-level testing" frameworks (i.e. component / integration / system) or Best Practices for using these available unit-testing frameworks in a higher-level fashion.

@JohelEGP
Copy link

I suggest opening a new issue about "testing beyond unit tests".

@laoshaw
Copy link

laoshaw commented Nov 22, 2022

Please some practical advice on fuzzing testing for c++ especially with g++(clang++ has its fuzzer lib but g++ does not, g++ is however quite ahead of clang++ on c++20)

@ladislas
Copy link

ladislas commented Jan 1, 2023

I find ut quite promising.

@daixtrose I really like it as well.

For our project, we started using Google Tests. But as we are doing embedded development, at some point we wanted to start running parts of our tests which are between unit tests and functional tests on the actual hardware.

We are using ut to do just that and we are very happy with the results

@ladislas
Copy link

ladislas commented Jan 1, 2023

@lefticus when you say:

As many compilers as you can

Does it make sense to try with different versions of each as well? Or is using the latest version enough?

@lefticus
Copy link
Owner Author

lefticus commented Jan 2, 2023

@lefticus when you say:

As many compilers as you can

Does it make sense to try with different versions of each as well? Or does using the latest version enough?

I would say latest version + whatever version you use for production. Often times that differs because of organizational constraints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants