Questions tagged [google-style-guide]

The Google Style Guide project holds the style guidelines googlers use for Google code.

Every major open-source project has its own style guide: a set of conventions (sometimes arbitrary) about how to write code for that project. It is much easier to understand a large codebase when all the code in it is in a consistent style.

“Style” covers a lot of ground, from “use camelCase for variable names” to “never use global variables” to “never use exceptions.” The Google Style Guide project holds the style guidelines we use for Google code. If you are modifying a project that originated at Google, you may be pointed to its page to see the style guides that apply to that project.

74 questions
3
votes
0 answers

clang-format reflowing comments incorrectly and is non repeatable

The following code snippet in C++, when formatted using clang-format-8, gives incorrect result in the first run (disrespecting ColumnWidth=80) and correct result in the second and subsequent runs. Note: the code contains tab in the comments…
cryptickey
  • 169
  • 8
3
votes
0 answers

How is it that a forward declaration can hide a dependency and cause user code to skip a necessary recompilation? (google style guide c++)

Forward declarations can hide a dependency, allowing user code to skip necessary recompilation when headers change. from https://google.github.io/styleguide/cppguide.html#Forward_Declarations I have learned recently there is some debate over…
Enigma22134
  • 532
  • 5
  • 12
3
votes
1 answer

IntelliJ IDEA seems to be ignoring code formatting

I've been attempting to get my Intellij IDEA to confirm to a google-like Java standard - however both imports and manual settings seem to be ignored. Here's how my indentations are currently set: However my code still formats at 4 spaces, and when…
Mathieson
  • 1,698
  • 2
  • 17
  • 19
3
votes
1 answer

Editing Google's C++ DISALLOW_COPY_AND_ASSIGN Preprocessor Macro for C++11 Move Semantics

I've been using Google's DISALLOW_COPY_AND_ASSIGN macro from their C++ Style Guide for a couple of months now, but it recently occurred to me that it would be useful to additionally disable the move constructor and move assignment. I haven't written…
SamuelMS
  • 1,116
  • 1
  • 11
  • 22
3
votes
1 answer

Why using "const" construction in JavaScript is a bad practice?

In Google Style guide for JavaScript written (prove link), that using a "const" construction is a bad practice, why?
NiLL
  • 13,645
  • 14
  • 46
  • 59
2
votes
1 answer

google style guide script or tool

Is there a script or tool that changes a code's style to google style not completely at least partially (maybe just syntax formatting)? We are reusing some of our C++ legacy code which is not formatted by google style standards and even just…
Chenna V
  • 10,185
  • 11
  • 77
  • 104
2
votes
0 answers

Do you have to type out numpy.ndarray in full for a type hint in a Google-style docstring, or can you just type np.ndarray?

I've been reading through this guide to writing Google-style and Numpy-style docstrings with type hints for numpy ndarrays. In the Numpy-style docstring example, type hints are abbreviated as "np.ndarray". However, in the corresponding Google-style…
2
votes
1 answer

Optional type hint in Google Style Guide

I have a doubt regarding Optional type hint in the Google Python Style Guide. In section 3.19.5, the following is shown as correct usage: def func(a: Optional[Text], b: Optional[Text] = None) -> Text: I don't understand a: Optional[Text]. Why is it…
Hari
  • 1,561
  • 4
  • 17
  • 26
2
votes
1 answer

What are the main differences between PEP8 and Google Python Style Guide?

most notably they use two spaces for indentation instead of 4. The CamelCase style for functions and methods instead of the camel_case style.
2
votes
0 answers

What does `application-specific imports` means in Google Python Style Guide

In the section, Imports Formatting, of Google Python Style Guide, the fourth point which is about application-specific imports is marked as deprecated in Nov. 2018. The example in the section does not provide enough information to understand what…
IvanaGyro
  • 598
  • 7
  • 25
2
votes
3 answers

Multiple imports according to google style guide

I do not understand what is written in Google Python Style Guide about multiple imports per line. Is it ok (according to Google Style Guide) to have it this way: from wagtail.wagtailimages.blocks import ImageChooserBlock, EmbedBlock or do I have to…
2
votes
1 answer

Is count a property or not?

In the official google style guide for objective c, it's mentioned that Dot notation is idiomatic style for Objective-C 2.0. It may be used when doing simple operations to get and set a @property of an object, but should not be used to invoke…
2
votes
0 answers

What are the key moments if create iOS project when we say about clear and clean architecture

The question is about structuring in iOS So I receive a message from a company where I passed a test and they say: "First of all I want to highlight that they said (developers who took my test) that they really liked how clean your code was. One…
Matrosov Oleksandr
  • 25,505
  • 44
  • 151
  • 277
1
vote
0 answers

System headers before other headers according to Google Style guide?

I was playing with cpplint and I got this warning: Found C++ system header after other header. Should be: transpose_square.h, c system, c++ system, other. The source is the Google Styleguide, that apparently says (said?) 1. associated .h/.hpp (if…
alfC
  • 14,261
  • 4
  • 67
  • 118
1
vote
0 answers

Avoiding static members and methods when following python googl-style-guide

I am writing a hierarchical tree containing management information. There is one tree instance per running program instance. In c++ I will keep root of the tree as a private pointer to a static object. And then have static methods to find/add/delete…
uuu777
  • 765
  • 4
  • 21