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
Get familiar with C++ #2
Comments
Michael VanLoon “STL Algorithms in Action ”Every C++ developer should strive to learn and use STL to its maximum capability.
In STL, algorithms can be divided into:
In the end, using STL ensure that the developer's code is neat, short and works as expected even in cases that the developer might not have been aware of. Also, multiple STL algorithms can be combined to perform very complicated instructions with relative ease. |
T. Winters & H. Wright “All Your Tests are Terrible..."Tests are integral to not only maintaining a project but also for further expanding it. Tests ensure that the development of the project can continue without depending on the original developers. A test must follow 5 properties to be considered a "good" test:
CorrectnessThe test must verify that the system requirements are actually met. Tests that depend on known bugs or faults in the system must not be included. ReadabilityTests should not contain excessive boilerplate code. It must be easy to read and understand for a user. CompletenessTests should not be created with the intention of them passing.
Furthermore, completeness does not imply test every API call. They must only test the API which they are working on. DemonstrabilityWhile the developers have a deeper understanding of the code than common users, they must not use shortcuts or complicated examples as tests. A test is useless if a user cannot understand what it is trying to do. ResilienceA test failure must imply a problem in the system and should not be due to unrelated causes. We need to ensure that our tests are free from outside effects and can stand strong on their own.
In the end, a project can quickly spiral down if it lacks effective tests. |
Kate Gregory “Stop Teaching C"The premise of this talk is not about whether C is good language or not, but rather "Stop Teaching C When You Want to Teach C++". It is a common misconception that C is a pre-requisite to C++. In fact, C-Style coding is a bad practice in C++.
It is better to teach core C++ concepts directly rather than at the end.
With C++ taught first, beginners need not go through the complicated usage of printf, char* [], memory handling etc to understand the core concepts. |
Bjarne Stroustrup “Writing Good C++14”Modern C++ 11/14/17 is almost completely different than the old C++. It is:
However, even with many new advanced features, many people still prefer using C++ in archaic styles or get lost in the details of the language. One way to prevent this is to have 'rules' on writing code.
Therefore, we need to specify "good" rules. A structure of a good rule would be:
Some properties of a good rule set are:
However, a rule set cannot be too large because people will not be able to apply all of them. Therefore, a set of "core" rules should exist. ISO C++ has these core rules that one should follow for writing good C++.
Since there are quite a lot of rules, a person cannot be expected to remember all of them. Instead, tools should be able to know these rules and should be able to point them out. It is not optimal to try building a new language out of these rules since competing with C++ is extremely hard and could split the CPP community. Therefore, good C++ code can be written by following the guidelines of ISO C++. |
Herb Sutter "Back to the Basics! Essentials of Modern C++ Style"To have a good understanding of Modern C++, the speaker recommends the book " A Tour of C++ " By Bjarne Stroustrup. Some aspects of the modern C++ coding style:
LoopsRange-based for loops exist in modern C++ and should be used when iterating over collections rather than a typical iteration-based loop. However, if early termination is required, an iteration-based loop is still a good choice. Pointers & ReferencesIn modern C++, there is a tendency to overuse smart pointers rather than the raw * and &. However, this is not always the best practice since there is a performance cost to using smart pointers. Some guidelines for using pointers are:
Variable DeclarationIt is good practice to use the auto keyword where ever possible.
It is also to be noted that it is very rare that the usage of auto results in a performance drop. Parameter PassingIn old C++, return-by-value was rarely used due to costly copy operations. In short, the defaults of C++ work better than we expect and we should try to adopt them more in our code. |
Bjarne Stroustrup - The Essence of C++When C++ was created, it had the goals of :
It was created by combining the concepts borrowed from C and Simula. Modern C++ places a large amount of value on resource management. Template Metaprogramming has also become a part of C++ due to its popularity. In C++ 11, constexpr was implemented to replace the misuse of template metaprogramming to generate constant values at compile time. |
The text was updated successfully, but these errors were encountered: