Google Code Style Guide—StyleGuide

Google Code Style Guide—StyleGuide

2022-08-30 0 1,195
Resource Number 36594 Last Updated 2025-02-24
¥ 0USD Upgrade VIP
Download Now Matters needing attention
Can't download? Please contact customer service to submit a link error!
Value-added Service: Installation Guide Environment Configuration Secondary Development Template Modification Source Code Installation

A rigorous code style can give a good impression and better legibility, and in actual development, it is often encountered that it is your own code, and after a period of time you don’t know it at all. Therefore, for beginners, it is necessary to establish good programming habits, which includes code style, such as indenting the first line, adding spaces after keywords, camel nomenclature, etc., the Google open source project styleguide provides code styles including C++, C#, Java, Python and other 10 programming languages, and you can easily write high-quality code by referring to imitation.

 

Google Code Style Guide—StyleGuide插图

Example:

C++ style guide

Header file

All header files should be protected by #define to prevent multiple inclusions, and for uniqueness, they should be based on the full path in the project’s source tree

#ifndef FOO_BAR_BAZ_H_#define FOO_BAR_BAZ_H_…#endif // FOO_BAR_BAZ_H_

Naming conventions

Use a name that describes the object’s purpose or intent

class MyClass {public:int CountFooErrors(const std::vector<Foo>& foos) {int n = 0; Given a finite scope and context for (const auto& foo : foos) {…++n; } }return n; }void DoSomethingImportant() {std::string fqdn = …; The well-known abbreviation for fully qualified domain name }private:const int kMaxAllowedConnections = …; Be clear in context};

Function declarations and definitions

The return type is on the same line as the function name, and the parameters should be on the same line as much as possible

ReturnType ClassName::FunctionName(Type par_name1, Type par_name2) {DoSomething(); …}

Too many parameters can wrap lines

ReturnType LongClassName::ReallyReallyLongFunctionName( Type par_name1, // 4 spaces indented Type par_name2, Type par_name3) { DoSomething(); } 2 spaces indented…

}

 

Google Code Style Guide—StyleGuide插图1

  • Java style guide

    Package name

    Package names are all lowercase, and consecutive words are simply concatenated together (no underscores)

    Correct: com.example.deepspace Error: com.example.deepSpace or com.example.deep_space

    Class name

    Class names are nomenclated with large humps, usually nouns or noun phrases

    Character or ImmutableList

    The naming of test classes begins with the name of the class they are testing

    HashTest or HashIntegrationTest

    Method name

    Method names are nomenclature with small humps, usually verbs or verb phrases

    sendMessage or stop

 

Google Code Style Guide—StyleGuide插图2

  • JavaScript style guide

    Local variable declarations

    Local variables are not usually declared at the beginning of their containment block or block-like construction;

    Each local variable declares only one variable, and does not use let a = 1, b = 2; Such Statements

    Attribute annotations

    The property type must be documented, and the description of the private property can be omitted if the code provides sufficient documentation

    /** My class. */class MyClass {/** @param {string=} someString */constructor(someString = ‘default string’) {/** @private @const {string} */this.someString_ = someString; }}

 

Google Code Style Guide—StyleGuide插图3

Other:

Google Code Style Guide—StyleGuide插图4

资源下载此资源为免费资源立即下载
Telegram:@John_Software

Disclaimer: This article is published by a third party and represents the views of the author only and has nothing to do with this website. This site does not make any guarantee or commitment to the authenticity, completeness and timeliness of this article and all or part of its content, please readers for reference only, and please verify the relevant content. The publication or republication of articles by this website for the purpose of conveying more information does not mean that it endorses its views or confirms its description, nor does it mean that this website is responsible for its authenticity.

Ictcoder Free source code Google Code Style Guide—StyleGuide https://ictcoder.com/kyym/google-code-style-guide-styleguide.html

Share free open-source source code

Q&A
  • 1, automatic: after taking the photo, click the (download) link to download; 2. Manual: After taking the photo, contact the seller to issue it or contact the official to find the developer to ship.
View details
  • 1, the default transaction cycle of the source code: manual delivery of goods for 1-3 days, and the user payment amount will enter the platform guarantee until the completion of the transaction or 3-7 days can be issued, in case of disputes indefinitely extend the collection amount until the dispute is resolved or refunded!
View details
  • 1. Heptalon will permanently archive the process of trading between the two parties and the snapshots of the traded goods to ensure that the transaction is true, effective and safe! 2, Seven PAWS can not guarantee such as "permanent package update", "permanent technical support" and other similar transactions after the merchant commitment, please identify the buyer; 3, in the source code at the same time there is a website demonstration and picture demonstration, and the site is inconsistent with the diagram, the default according to the diagram as the dispute evaluation basis (except for special statements or agreement); 4, in the absence of "no legitimate basis for refund", the commodity written "once sold, no support for refund" and other similar statements, shall be deemed invalid; 5, before the shooting, the transaction content agreed by the two parties on QQ can also be the basis for dispute judgment (agreement and description of the conflict, the agreement shall prevail); 6, because the chat record can be used as the basis for dispute judgment, so when the two sides contact, only communicate with the other party on the QQ and mobile phone number left on the systemhere, in case the other party does not recognize self-commitment. 7, although the probability of disputes is very small, but be sure to retain such important information as chat records, mobile phone messages, etc., in case of disputes, it is convenient for seven PAWS to intervene in rapid processing.
View details
  • 1. As a third-party intermediary platform, Qichou protects the security of the transaction and the rights and interests of both buyers and sellers according to the transaction contract (commodity description, content agreed before the transaction); 2, non-platform online trading projects, any consequences have nothing to do with mutual site; No matter the seller for any reason to require offline transactions, please contact the management report.
View details

Related Article

make a comment
No comments available at the moment
Official customer service team

To solve your worries - 24 hours online professional service