No code is ever perfect, and we must realize that throughout the act of writing code we will be making choices continually. As we mature as developers or scripters, we become more confident in our choices and will tend to make decisions that are more well-informed and lead to better, more stable solutions. As we look back on scripts that we wrote in the past, we will almost certainly find opportunities for improvement. Depending on the source, we might also find the same kinds of issues in code that we obtain from other sources such as the Internet. In this chapter, we will consider some of the things to look for in code that might indicate some improvements may be applicable. In particular, we will discuss the following:
What are code smells?
Language-agnostic code smells
Why are there PowerShell-specific code smells?
Missing
Param()
statementsHomegrown common parameters
Unapproved verbs
Accumulating output objects
Sequences of assignment statements
Using untyped...