Be consistent with existing code Using one style consistently through our codebase lets us focus on Transfer of pointer ownership), leaving textual hints for the readerĪt the point of use is valuable ( std::unique_ptrĭemonstrates the ownership transfer unambiguously at the call Surprising or unusual is happening in a snippet of code (for example, Particularly common sub-point of this principle: When something Reading, maintaining, and debugging code in our codebase rather thanĮase when writing said code. We explicitlyĬhoose to optimize for the experience of our average software engineer As a result, more time willīe spent reading most of our code than writing it. Optimize for the reader, not the writer Our codebase (and most individual components submitted to it) isĮxpected to continue for quite some time. Of the following principles, but is already vanishingly rare, so the Style Than the rules we do: for example, goto contravenes many This principle mostly explains the rules we don’t have, rather Still have a small benefit if people are unlikely to do itĪnyway. Get without the rule, so a rule against a very harmful practice may The benefit is measured relative to the codebase we would Must be large enough to justify asking all of our engineers to The goals of the style guide as we currently see them are as follows: Style rules should pull their weight The benefit of a style rule (some can be), and what sort of argument or alternative would be Serving, it should be clearer to everyone when a rule may be waived If you understand what goals each rule is The fore, we hope to ground discussions and make it clearer to ourīroader community why the rules are in place and why particularĭecisions have been made. There are a few core goals that we believe this guide should The reader is familiar with the language. Note that this guide is not a C++ tutorial: we assume that Google conform to the requirements in this guide. The term Style is aīit of a misnomer, since these conventions cover far more than The conventions that govern our C++ code. Style, also known as readability, is what we call Keep the code base manageable while still allowingĬoders to use C++ language features productively. The goal of this guide is to manage this complexity byĭescribing in detail the dos and don'ts of writing C++ code This power brings with it complexity, which in turn can makeĬode more bug-prone and harder to read and maintain. Programmer knows, the language has many powerful features, but C++ is one of the main development languages used by
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |