Skip to content

Commit c0b6284

Browse files
authored
Implementing JayKul's feedback
1 parent 329e3cd commit c0b6284

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Style-Guide/Code-Layout-and-Formatting.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ end{}
8181

8282
You can always delete or ignore one of the blocks (or add the `begin` block), add parameters and so on, but you should avoid writing scripts or functions without CmdletBinding, and you should always at least _consider_ making it take pipeline input.
8383

84-
#### Follow the one-true-brace style.
85-
Open braces always go on the same line
84+
#### Brace yourself: Follow the one-true-brace style.
85+
Open braces always go on the same line.
86+
87+
This style really won in the PowerShell community partly because the style is one of two used in C languages --it's a variant of the K&R (Kernighan and Ritchie) style from their book The C Programming Language-- but also because for the first few years of PowerShell's existence, this was the only style that could be typed at the command line.
8688

8789
Code folding is nicer in many editors when a scriptblock is placed on the end of the same line, as in this example.
8890

@@ -97,8 +99,10 @@ function Get-Noun {
9799
}
98100
}
99101
````
100-
#### Closing braces always on their own line
101-
Note the above example again, community guidelines recommend placing your closing braces on their own line. This practice makes it easier to pair up matching opening and closing braces when looking to see where a particular scriptblock ends.
102+
#### Closing braces start a new line
103+
Note the above example again, community guidelines recommend following the ['One-True-Brace-Style'](https://www.wikiwand.com/en/Indentation_style#/K&R_style) placing your closing braces on their own line. This practice makes it easier to pair up matching opening and closing braces when looking to see where a particular scriptblock ends, and allows one to insert new lines of code between any two lines.
104+
105+
To reiterate, these are community best practices, and a lot of the code you'll find online from community leaders will follow these guidelines. That doesn't mean that those who follow different style guidelines are wrong. You may be the one to set the course for your company or your own project; we simply offer this guidance for your consideration.
102106

103107
#### Prefer: param() begin, process, end
104108
That's the order PowerShell will execute it in

0 commit comments

Comments
 (0)