18 Professional-grade scripting

 

We’re almost ready to call you a professional toolmaker in PowerShell—almost. Before you go around adding “PowerShell Toolmaker” to your résumé, we think you should make certain that you’re exhibiting the behaviors and patterns of a true PowerShell pro. With that in mind, this chapter provides essential guidelines and a list of best practices to follow to be recognized as a reliable and skilled professional in the PowerShell world.

18.1 Using source control

One hallmark of professional PowerShell scripters is their commitment to ensuring the longevity and maintainability of their code. Source control, discussed in detail in chapter 19, is pivotal in achieving these goals. While some might liken source control to filing taxes, modern tools have greatly streamlined its usage. Integrated seamlessly with platforms such as Visual Studio Code (VS Code), source control is as easy as saving a file and committing changes with a simple keystroke.

Recognize that source control isn’t just a chore but a mark of professionalism. Employing source control on your projects offers numerous benefits:

18.2 Code clarity

18.3 Effective comments

18.4 Formatting your code

18.5 Meaningful variable names

18.6 Avoiding aliases

18.7 Logic over complexity

18.8 Providing help

18.9 Avoiding Write-Host and Read-Host

18.10 Sticking with single quotes

18.11 Not polluting the global scope

18.12 Being flexible

18.13 Prioritizing security

18.14 Striving for elegance