The full guide of PowerShell that any developer needs to know – Naming Conventions


The full guide of PowerShell that any developer needs to know – INDEX

 

A naming conventions is a guide to write clean and maintainable code.

In PowerShell (PS) in general prefer to use full explicit names for commands and parameters rather than aliases or short forms.

Is important to use the universally known names rather your own aliases. In addition the most code programming tools highlight the common known commands and parameters.

For example, not use “gps -Name Explorer”, instead use “Get-Process -Name Explorer”.

Is very difficult to known all commands and parameters, so it’s important to be explicit about parameters.

For example, not use “Get-Process Explorer”, instead use “Get-Process -Name Explorer”.

When use paths, is very common to use “.” or “..” or some other options, but this is very difficult to find errors if you have problems with paths.  Avoid the use of “~”.

For example, not use “Get-Content .\README.md” or [System.IO.File]::ReadAllText(“.\README.md”), instead use “Get-Content -Path (Join-Path -Path $PSScriptRoot -ChildPath README.md)” or “[System.IO.File]::ReadAllText(“$PSScriptRoot\README.md”)”

 

The full guide of PowerShell that any developer needs to know – INDEX

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión /  Cambiar )

Google photo

Estás comentando usando tu cuenta de Google. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )

Conectando a %s