Skip to content

Instantly share code, notes, and snippets.

@Nathaniel100
Last active June 23, 2016 08:40
Show Gist options
  • Save Nathaniel100/640983d3052785cd152c6822e7178f47 to your computer and use it in GitHub Desktop.
Save Nathaniel100/640983d3052785cd152c6822e7178f47 to your computer and use it in GitHub Desktop.
For starters, here are a few high-level recommendations derived from the sections on design, learning, and history of C++:
  1. Represent ideas (concepts) directly in code, for example, as a function, a class, or an enu- meration; §1.2.
  2. Aim for your code to be both elegant and efficient; §1.2.
  3. Don’t overabstract; §1.2.
  4. Focus design on the provision of elegant and efficient abstractions, possibly presented as libraries; §1.2.
  5. Represent relationships among ideas directly in code, for example, through parameteriza- tion or a class hierarchy; §1.2.1.
  6. Represent independent ideas separately in code, for example, avoid mutual dependencies among classes; §1.2.1.
  7. C++ is not just object-oriented; §1.2.1.
  8. C++ is not just for generic programming; §1.2.1.
  9. Prefer solutions that can be statically checked; §1.2.1.
  10. Make resources explicit (represent them as class objects); §1.2.1, §1.4.2.1.
  11. Express simple ideas simply; §1.2.1.
  12. Use libraries, especially the standard library, rather than trying to build everything from scratch; §1.2.1.
  13. Use a type-rich style of programming; §1.2.2.
  14. Low-level code is not necessarily efficient; don’t avoid classes, templates, and standard- library components out of fear of performance problems; §1.2.4, §1.3.3.
  15. If data has an invariant, encapsulate it; §1.3.2.
  16. C++ is not just C with a few extensions; §1.3.3.

In general: To write a good program takes intelligence, taste, and patience. You are not going to get it right the first time. Experiment!

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