Skip to content

Instantly share code, notes, and snippets.

@jrwarwick
Created May 19, 2022 14:45
Show Gist options
  • Save jrwarwick/0e388602d6b40b5a477bdc445ae7736d to your computer and use it in GitHub Desktop.
Save jrwarwick/0e388602d6b40b5a477bdc445ae7736d to your computer and use it in GitHub Desktop.
PowerShell Coding Conventions Guidance
## bry PowerShell Corporate Coding Conventions ##
"Largely, respecting: https://docs.microsoft.com/en-us/powershell/scripting/developer/cmdlet/strongly-encouraged-development-guidelines?view=powershell-7.2"
"Perhaps a few extensions and modifications."
"Also try to include this: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_comment_based_help?view=powershell-7.2#comment-based-help-for-a-script"
## Major Sections Double-Crunch, Capitalized, and Doublespaced ##
"For clarity, uniformity, ease of navigation, and grepability/searchability."
## File Naming Conventions ##
#Module File Names
CapitalizedCamelCaseNoSpacesUnderscoresHyphens.psm1
#Script File Names
lower_case_underscores.ps1
SpecialAutoloadingQuasiCmdletUtilityHasSuffixOf_function.ps1
## Variable Naming Conventions ##
#Script Parameters
CapitalizedCamelCase
AKApascalCase #though note here, an embedded abbreviation that is capitalized causes the following word to *omit* capitalization!
UsuallySingular
ButPluralIsOkIfYouMeanItAndReallyNeedIt # (delimited strings, actual syntatical list, arrays)
EmailRecipientList #Though sometimes using a collective noun like "List" avoids a "plural per se"
BooleansAsSwitchType
#local variables and function parameters
uncapitalizedCamelCase
affixesAreVeryRare
#Special Affixes (should very rarely be used)
G_* truly global variable
_DEFAULT only for sane-but-crappy fallbacks
#script functions
uncapitalizedCamelCase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment