2 ms·
"What about unit-testing framework and some best practices?" A random collection of anecdotal stuff and opinions that comes to my head: For common utilities f
by fsloth 11y ago
"What about unit-testing framework and some best practices?"
A random collection of anecdotal stuff and opinions that comes to my head:
For common utilities for game development stb libraries are fantastic: https://github.com/nothings/stb https://github.com/nothings/stb
For general idea how to structure code you could google "data oriented design c++".
Try not to structure your solution around class hierarchies but prefer data pipelines.
Write your code so that it's easy to debug.
Prefer to structure your solutions around stl containers and stl algorithms.
Avoid using inheritance as long as it does not reduce code complexity. If you use inheritance prefer to use only abstract base classes. Do not use template metaprogramming unless you are absolutely sure it's the most simple way to solve your problem. Avoid multiple inheritance like the plague. Ignore my advice if your problem is such that they don't make sense.
Try not to solve any other problem than the one you have immediately in front of you, and solve it as fast and simply as possible. Do not try to create some "framework" to solve your problems but prefer simple code. Refactor your code as your program progresses. This point might be obvious - but for me personally has been the most difficult thing to learn - writing agressively simple code is the best thing I've learned. This does not mean that the abstractions that are implemented are necessarily simple - just that the implementation is as easy to read, easy to debug and easy to reason about it's dependencies, as possible.
If you can trade off complexity of dependency with a little bit more code, prefer little bit more code. I.e. if you have an itch to include a library because you need a single function, think hard about implementing or copy pasting the function to your codebase. Once you are confident enough that you know you need something, only then include it.
Learn some OCaml :) - really, I feel like much better C++ programmer after I understood how a properly designed language with a static type system works. (I hear "Real world OCaml" is a good book).
- Aeolos 11y ago> Learn some OCaml :) - really, I feel like much better C++ programmer after I understood how a properly designed language with a static type system works. (I hear "Real world OCaml" is a good book). This. Or F#.