From 24d2143b2daff7fd129614810f204243698c8b1d Mon Sep 17 00:00:00 2001 From: Nadia Ridko Date: Fri, 12 Jan 2018 10:59:02 +0200 Subject: [PATCH] Stylistic changes --- README.md | 77 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 170b60b..5ad554c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

- - Naming cheatsheet - + + Naming cheatsheet +

# Naming cheatsheet @@ -9,6 +9,7 @@ Naming things is hard. Let's make it easier. ## Guidelines * Pick **one** naming convention and follow it. Whether it is `likeThis`, or `like_this`, or anyhow else, it does not matter. What matters is consistency in your work. + ```js /* Bad */ const pages_count = 5; @@ -22,10 +23,12 @@ const shouldUpdate = true; const pages_count = 5; const should_update = true; ``` + * Name, whether of a variable, method, or something else, should be *short*, *descriptive* and *intuitive*: - * **Short**. Variable should not take long to type, and therefore to remember, - * **Descriptive**. Name of the variable should reflect what this variable possesses/does in the most efficient way, - * **Intuitive**. Name of the variable should read naturally, as close to common speach as possible + * **Short**. Variable should not take long to type and, therefore, to remember, + * **Descriptive**. Name of the variable should reflect what it does/possesses in the most efficient way, + * **Intuitive**. Name of the variable should read naturally, as close to the common speach as possible + ```js /* Bad */ const a = 5; // "a" could mean anything @@ -38,6 +41,7 @@ const shouldDisplayPagination = (postsCount > 10); ``` * Name should not duplicate the context when the latter is known, and when removing the context from the name does not decrease its readability: + ```js class MenuItem { /* Method name duplicates the context it is in (which is "MenuItem") */ @@ -48,6 +52,7 @@ class MenuItem { } ``` * Name should reflect the expected result: + ```js /* Bad */ const isEnabled = (itemsCount > 3); @@ -58,14 +63,15 @@ const isDisabled = (itemsCount <= 3); return (