Google C + + style guide of the popular translation (copy, do not reprint)

Source: Internet
Author: User

Background
Background

C + + is the main development language used by many of Google ' s open-source projects. As every C + + programmer knows, the language have many powerful features, but this power brings with it complexity, which in Turn can make code more bug-prone and harder to read and maintain.
C + + features powerful C + + difficult to read difficult to maintain
Many of Google's open source projects use C + + as a programming language. Every C + + programmer knows that C + + has many powerful features, but the more powerful it is, the greater the difficulty of C + + becomes. The difficulty is a bug, and the code becomes difficult to read and difficult to maintain.

The goal of this are to manage this complexity by describing in detail the DOS and don ' ts of writing C + + code. These rules exist to keep the code base manageable and still allowing coders to use C + + language features productively.
This article will tell you what to do.
The goal of this guide is to tell you what to do and what not to do when you write C + + code, to control the difficulty of C + +. The significance of these guidelines is that the code base can be maintained while ensuring that programmers can use C + + features efficiently.

Style, also known as readability, is the "we call the conventions" that govern our C + + code. The term Style was a bit of a misnomer, since these conventions cover far more than just source file formatting. The definition of the
//code style is not limited to the format of the source code file. The
code style, or the so-called readability, is our convention to control C + + code. Because these conventions are not confined to the format of the source code file, the term style is a bit of a misnomer.

One on which we keep the code base manageable is by enforcing consistency. It is the very important that any programmer being able to look at another ' s code and quickly understand it. Maintaining a uniform style and following conventions means that we can further easily use ' pattern-matching ' to infer what V Arious symbols is and what invariants is true about them. Creating Common, required idioms and patterns makes code much easier to understand. In some cases there might is good arguments for changing certain style rules, but we nonetheless keep things as they is I n order to preserve consistency.
//Promote consistency, don't change style temporarily.
Enforcing consistency is a way for us to keep our code base manageable. It is important to make it easy for other programmers to understand your code. If we maintain a uniform style and follow the conventions, then we can use "pattern-match" to make it easier to infer: the real meaning of those variables and invariants. Creating common, necessary idioms and patterns makes the code more understandable. In some cases it would be better to change to a certain style, but let's keep these style guidelines as they are and make them consistent.

Another issue this guide addresses are that of C + + feature bloat. C + + is a huge language with many advanced features. In some cases we constrain, or even ban, use of certain features. We do the-keep code simple and to avoid the various common errors and problems that these features can cause. This guide lists these features and explains, why their are restricted.
Don't use the C + + advanced features casually
This guidance article will talk about another problem: abuse of C + + features. C + + has many advanced features and is a large-scale language. In some cases, we restrict or prohibit the use of certain features. This is done for the code to be simple, while avoiding various errors and problems. This guide article lists these features and explains why they should be restricted.

Open-source projects developed by Google conform to the requirements in this guide.
Google's open source projects are in line with the requirements of this text guide.

Note that this guide is a C + + Tutorial:we Assume that the reader was familiar with the language.
Note This article does not teach C + +: We assume that you are familiar with the language.

Google C + + style guide of the popular translation (copy, do not reprint)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.