Book Image

PowerShell Troubleshooting Guide

By : Mike Shepard
Book Image

PowerShell Troubleshooting Guide

By: Mike Shepard

Overview of this book

Table of Contents (15 chapters)
PowerShell Troubleshooting Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 8. PowerShell Code Smells

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() statements

  • Homegrown common parameters

  • Unapproved verbs

  • Accumulating output objects

  • Sequences of assignment statements

  • Using untyped...