You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Best-Practices/Performance.md
+1-2Lines changed: 1 addition & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -65,5 +65,4 @@ This example reverts back to a native PowerShell approach, using commands and pa
65
65
66
66
You will generally find that it is possible to conform with the community's general aesthetic preferences while still maintaining a good level of performance. Doing so may require more work - such as writing PowerShell wrapper commands around underlying .NET Framework classes. Most would argue that, for a tool that is intended for long-term use, the additional work is a worthwhile investment.
67
67
68
-
The moral here is that both aesthetic and performance are important considerations, and without some work context, neither is inherently more important than the other. It is often possible, with the right technique, to satisfy both. As a general practice, you should avoid giving up on aesthetics solely because of performance concesrns - when possible, make the effort to satisfy both performance and aesthetics.
69
-
68
+
The moral here is that both aesthetic and performance are important considerations, and without some work context, neither is inherently more important than the other. It is often possible, with the right technique, to satisfy both. As a general practice, you should avoid giving up on aesthetics solely because of performance concerns - when possible, make the effort to satisfy both performance and aesthetics.
Copy file name to clipboardExpand all lines: Best-Practices/TODO.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -246,7 +246,7 @@ My choice: Configuration module. Otherwise, use clixml (or XAML) to persist to A
246
246
#### Provide aliases in your modules
247
247
You should feel free to create and use aliases within your modules. In some cases, you can even improve readability by using an alias without the verb, or shortening command names.
248
248
249
-
For exported aliases, follow the guidance of Microsoft ("ip" for import, "s" for set, "g" for get, "r" for remove, etc.), make up somethign for your nouns.
249
+
For exported aliases, follow the guidance of Microsoft ("ip" for import, "s" for set, "g" for get, "r" for remove, etc.), make up something for your nouns.
250
250
251
251
Use `New-Alias ... -ErrorAction SilentlyContinue` to avoid overwriting existing aliases.
252
252
@@ -293,7 +293,7 @@ Additionally, avoid using `[string]` with ParameterSets because anything can be
293
293
294
294
When passing on parameters to another command, you should be _at least_ as strongly typed as the other command, to avoid casting exceptions within your script.
295
295
296
-
One notable exception is when you could accept more than one type. In PowerShell you can speficy parameter set overloads, but you can't change the type of a parameter.
296
+
One notable exception is when you could accept more than one type. In PowerShell you can specify parameter set overloads, but you can't change the type of a parameter.
Copy file name to clipboardExpand all lines: LICENSE.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ This work is licensed under a [Creative Commons Attribution-ShareAlike 4.0 Inter
8
8
9
9
**Adapt** — remix, transform, and build upon the material
10
10
11
-
The authors encourage you to redistribute this content as widely as possible, but require that you give credit to the primary authors below, and that you notify us on github of any improvements you make.
11
+
The authors encourage you to redistribute this content as widely as possible, but require that you give credit to the primary authors below, and that you notify us on GitHub of any improvements you make.
12
12
13
13
14
14
#### Credits
@@ -29,6 +29,6 @@ Portions copyright (c) Joel Bennett, 2015
29
29
30
30
The *PowerShell Best Practices* are always evolving, and continue to be edited and updated as the language and tools (and our community understanding of them) evolve. We encourage you to check back for new editions at least twice a year, by visiting [https://github.com/PoshCode/PowerShellPracticeAndStyle](https://github.com/PoshCode/PowerShellPracticeAndStyle)
31
31
32
-
The *PowerShell Style Guide* in particular is in PREVIEW, and we are still actively working out our disagreements about the rules in the guide through the github issues system. Please don't be suprised if over then next few weeks we change rules to contradict what they say at this current moment.
32
+
The *PowerShell Style Guide* in particular is in PREVIEW, and we are still actively working out our disagreements about the rules in the guide through the GitHub issues system. Please don't be surprised if over then next few weeks we change rules to contradict what they say at this current moment.
Copy file name to clipboardExpand all lines: README.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ This work is licensed under a [Creative Commons Attribution-ShareAlike 4.0 Inter
12
12
13
13
**Adapt** — remix, transform, and build upon the material
14
14
15
-
The authors encourage you to redistribute this content as widely as possible, but require that you give credit to the primary authors below, and that you notify us on github of any improvements you make.
15
+
The authors encourage you to redistribute this content as widely as possible, but require that you give credit to the primary authors below, and that you notify us on GitHub of any improvements you make.
16
16
17
17
### What are Best Practices
18
18
@@ -52,7 +52,7 @@ Remember [what we mean by _Best Practices_](#what-are-best-practices)
52
52
53
53
The *PowerShell Best Practices* are always evolving, and continue to be edited and updated as the language and tools (and our community understanding of them) evolve. We encourage you to check back for new editions at least twice a year, by visiting [https://github.com/PoshCode/PowerShellPracticeAndStyle](https://github.com/PoshCode/PowerShellPracticeAndStyle)
54
54
55
-
The *PowerShell Style Guide* in particular is in PREVIEW, and we are still actively working out our disagreements about the rules in the guide through the github issues system.
55
+
The *PowerShell Style Guide* in particular is in PREVIEW, and we are still actively working out our disagreements about the rules in the guide through the GitHub issues system.
Copy file name to clipboardExpand all lines: Style-Guide/Code-Layout-and-Formatting.md
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -69,13 +69,13 @@ If you wish, you may use camelCase for variables within your functions (or modul
69
69
70
70
#### One True Brace Style
71
71
72
-
This guide recommends the so-called ["One True Brace Style" variant to K&R](https://github.com/PoshCode/PowerShellPracticeAndStyle/issues/81#issuecomment-285835313), which requires that every braceable _statement_ should have the opening brace on the _end of a line_, and the closing brace at the _beginning of a line_.
72
+
This guide recommends the so-called ["One True Brace Style" variant to K&R](https://github.com/PoshCode/PowerShellPracticeAndStyle/issues/81#issuecomment-285835313), which requires that every braceable _statement_ should have the opening brace on the _end of a line_, and the closing brace at the _beginning of a line_.
73
73
74
74
There is one notable exception when passing small scriptblocks to parameters (where K&R would allow leaving off the braces entirely), we allow putting the entire statement on a single line.
75
75
76
76
```powershell
77
77
enum Color {
78
-
Black,
78
+
Black,
79
79
White
80
80
}
81
81
@@ -88,7 +88,7 @@ function Test-Code {
88
88
if (10 -gt $ParameterOne) {
89
89
"Greater"
90
90
} else {
91
-
"Lesser"
91
+
"Lesser"
92
92
}
93
93
}
94
94
}
@@ -151,11 +151,11 @@ function Test-Code {
151
151
152
152
Limit lines to 115 characters when possible.
153
153
154
-
Keeping lines to a small width allows scripts to be read in _one_ direction (top to bottom) without scrolling back-and-forth horizontally. What, exactly, this width should be is a one of the favorite arguing points among developers on the internet (more splintered than emacs vs vi or gnu GPL vs MIT).
154
+
Keeping lines to a small width allows scripts to be read in _one_ direction (top to bottom) without scrolling back-and-forth horizontally. What, exactly, this width should be is a one of the favorite arguing points among developers on the internet (more splintered than emacs vs vi or gnu GPL vs MIT).
155
155
156
156
In this guide we use two particular sources for the maximum line width:
157
157
158
-
The PowerShell console is, by default, 120 characters wide, but it allows only 119 characters on output lines, and when entering multi-line text, PowerShell uses a line continuation prompt: `>>> ` and thus limits your line length to 116 anyway.
158
+
The PowerShell console is, by default, 120 characters wide, but it allows only 119 characters on output lines, and when entering multi-line text, PowerShell uses a line continuation prompt: `>>> ` and thus limits your line length to 116 anyway.
159
159
160
160
Github's current maximum line width varies between 121 and 126 depending on your browser and OS (and thus, font). However, the 115 line length suggested by PowerShell would be enough to even allow side-by-side diffs to be displayed without scrolling or wrapping on the current "standard" 1080p monitor.
161
161
@@ -175,7 +175,7 @@ Surround function and class definitions with _two_ blank lines.
175
175
176
176
Method definitions within a class are surrounded by a single blank line.
177
177
178
-
Blank lines may be ommitted between a bunch of related one-liners (e.g. empty functions)
178
+
Blank lines may be omitted between a bunch of related one-liners (e.g. empty functions)
179
179
180
180
Additional blank lines may be used sparingly to separate groups of related functions, or within functions to indicate logical sections (e.g. before a block comment).
White-space is (mostly) irrelevant to PowerShell, but its proper use is key to writing easily readable code.
223
+
White-space is (mostly) irrelevant to PowerShell, but its proper use is key to writing easily readable code.
224
224
225
225
Use a single space after commas and semicolons, and around pairs of curly braces.
226
226
@@ -241,7 +241,7 @@ Obviously, these rules should not be applied in such a way as to affect output.
241
241
242
242
PowerShell will not complain about extra semicolons, but they are unnecessary, and can get in the way when code is being edited or copy-pasted. They also result in extra do-nothing edits in source control when someone finally decides to delete them.
243
243
244
-
They are also unecessary when declaring hashtables if you are already putting each element on it's own line:
244
+
They are also unnecessary when declaring hashtables if you are already putting each element on its own line:
245
245
246
246
```PowerShell
247
247
# This is the preferred way to declare a hashtable if it extends past one line:
Copy file name to clipboardExpand all lines: Style-Guide/Documentation-and-Comments.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
Comments that contradict the code are worse than no comments. Always make a priority of keeping the comments up-to-date when the code changes!
4
4
5
-
Comments should be in English, and should be complete sentences. If the comment is short, the period at the end can be ommited.
5
+
Comments should be in English, and should be complete sentences. If the comment is short, the period at the end can be omitted.
6
6
7
7
Remember that comments should serve to your reasoning and decision-making, not attempt to explain what a command does. With the exception of regular expressions, well-written PowerShell can be pretty self-explanatory.
0 commit comments