Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Unified Diff: sky/specs/style-guide.md

Issue 1209003002: Give rationale for style guide, suggest using more concise code when doing so doesn't harm readabil… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/specs/style-guide.md
diff --git a/sky/specs/style-guide.md b/sky/specs/style-guide.md
index 3fa309c04daf689e4e0e69169981139e897d45ae..e71ad84061b45cd04ecf1063bc5a20870abe350e 100644
--- a/sky/specs/style-guide.md
+++ b/sky/specs/style-guide.md
@@ -3,6 +3,10 @@ Sky Style Guide
In general, follow our [Design Principles](design.md) for all code.
+The primary goal of this style guide is to improve code readability so
+that everyone, whether reading the code for the first time or
+maintaining it for years, can quickly determine what the code does. A
+secondary goal is avoiding arguments when there are disagreements.
Dart
----
@@ -83,6 +87,26 @@ the expression, even if it is short. (Doing so makes it unobvious that
there is relevant code there. This is especially important for early
returns.)
+If a flow control structure has just one statement, then don't use
+braces around it except where doing so would help readability or avoid
+the dangling-else problem. Keeping the code free of boilerplate or
+redundant punctuation keeps it concise and readable.
+
+> For example,
+> ```dart
+> if (children != null)
+> for (RenderBox child in children)
+> add(child);
abarth-chromium 2015/06/25 17:17:12 The usual Google style for this situation is to pu
+> ```
+> ...rather than:
+> ```dart
+> if (children != null) {
+> for (RenderBox child in children) {
+> add(child);
+> }
+> }
+> ```
+
Use the most relevant constructor or method, when there are multiple
options.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698