google-style-guide

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

我的梦境 提交于 2020-03-14 05:31:58
问题 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 whether to use a forward declare or just include the header within the header itself. At work we forward declare our internal classes (not library code) and include the headers containing those classes in the corresponding .cpp . If the code in the .cpp

Google Style Guide properties for getters and setters

拥有回忆 提交于 2020-01-13 09:58:13
问题 I'm curious about one of the recommendations in the Google Python style guide concerning properties. In it, they give the following example: class Square(object): """A square with two properties: a writable area and a read-only perimeter. To use: >>> sq = Square(3) >>> sq.area 9 >>> sq.perimeter 12 >>> sq.area = 16 >>> sq.side 4 >>> sq.perimeter 16 """ def __init__(self, side): self.side = side def __get_area(self): """Calculates the 'area' property.""" return self.side ** 2 def ___get_area

How do I correctly install the Google Java Format plugin for IntelliJ IDEA?

点点圈 提交于 2020-01-03 16:52:07
问题 I want to install the Google Java Format plugin for IntelliJ IDEA. I have the latest 2016 community edition build (build #IC-163.11103.6, Jan 16th 2017), so version 1.2 of the plugin should be compatible. However, when I try to install it, I get an error: Plugin 'google-java-format' is incompatible with this version. Looking around for a solution, I found that this error is shown if the IntelliJ version isn't supported. However, the plugin page states that build 163, which is the one I have,

Google's style guide about input/output parameters as pointers

╄→尐↘猪︶ㄣ 提交于 2019-12-22 03:51:16
问题 The Google C++ Style Guide draws a clear distinction (strictly followed by cpplint.py) between input parameters(→ const ref, value) and input-output or output parameters (→ non const pointers) : Parameters to C/C++ functions are either input to the function, output from the function, or both. Input parameters are usually values or const references, while output and input/output parameters will be non-const pointers. And further : In fact it is a very strong convention in Google code that

VSCode configure syntax highlighting to match a style guide

元气小坏坏 提交于 2019-12-21 17:50:55
问题 How do I change the syntax highlighting in VSCode so that it adheres to a particular style guide? For example, I want to adhere to the Google C++ style guide where member variables are written as some_member_variable_ . When I use this convention, VSCode does not color that name differently from standard text. But I have some code that uses the mSomeMemberVariable convention, and that does get colored differently than other text. Is there a way to configure this better? 回答1: TL;DR >There is

Is using an unsigned rather than signed int more likely to cause bugs? Why?

不羁岁月 提交于 2019-12-20 08:13:53
问题 In the Google C++ Style Guide, on the topic of "Unsigned Integers", it is suggested that Because of historical accident, the C++ standard also uses unsigned integers to represent the size of containers - many members of the standards body believe this to be a mistake, but it is effectively impossible to fix at this point. The fact that unsigned arithmetic doesn't model the behavior of a simple integer, but is instead defined by the standard to model modular arithmetic (wrapping around on

Is using an unsigned rather than signed int more likely to cause bugs? Why?

大城市里の小女人 提交于 2019-12-20 08:13:34
问题 In the Google C++ Style Guide, on the topic of "Unsigned Integers", it is suggested that Because of historical accident, the C++ standard also uses unsigned integers to represent the size of containers - many members of the standards body believe this to be a mistake, but it is effectively impossible to fix at this point. The fact that unsigned arithmetic doesn't model the behavior of a simple integer, but is instead defined by the standard to model modular arithmetic (wrapping around on

Is using an unsigned rather than signed int more likely to cause bugs? Why?

淺唱寂寞╮ 提交于 2019-12-20 08:13:05
问题 In the Google C++ Style Guide, on the topic of "Unsigned Integers", it is suggested that Because of historical accident, the C++ standard also uses unsigned integers to represent the size of containers - many members of the standards body believe this to be a mistake, but it is effectively impossible to fix at this point. The fact that unsigned arithmetic doesn't model the behavior of a simple integer, but is instead defined by the standard to model modular arithmetic (wrapping around on

IntelliJ IDEA seems to be ignoring code formatting

与世无争的帅哥 提交于 2019-12-20 02:06:22
问题 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 I reformat it goes to 4 spaces as well. Thanks in advance! 回答1: This is the setting for your GoogleStyle scheme. But your project most likely doesn't use it. It's not enough to just select it in the combobox. You need to import this scheme into your