Which way is correct?

This is just a philosophical discussion around the common answer of ‘it depends’, or ‘it’s a choice’. ‘Which way should the toilet paper roll go in your house?’

This is very analogous to all of the ongoing debates in history: Coke vs. Pepsi, VHS vs. Beta, BlueRay vs. HDDVD, Visual Studio Code vs. ISE, and the list goes on and on.

The paten submitted and approved for the toilet paper roll scenario, has the feed coming over the top. However, if you have cats or kittens, you’ll quickly realize, that it might be better to have the roll feed out the bottom. Think scratching post.

Personal, I don’t care, as long as the toilet paper roll isn’t empty when needed. Why not on a vertical post, like the new Boeing 737’s? Then you can discuss ‘clockwise’ vs. ‘counter-clockwise’. Sigh, will the madness never end!

This discussion continues with other ‘best practices’, or ‘preferred methods’. There are lots of options and sometimes, it just doesn’t matter. You’ll need to be aware of the situation and see if there is a standard or a norm.

Take formatting of a function in PowerShell. There are a list of approved verbs and when you are supposed to use one over the other and not use more than listed. The subject skews very quickly with the Noun in a cmdlet/function. One guidance is, when you create a function at a company, to use a consistent ID or prefix. One common suggestion is, the stock ticket of the company, MSFT for Microsoft for example.

Why ensure the noun is different? Well, let’s say you’re going to create a function for new users. New-User comes to mind, but that’s already taken. How about just New-Mailbox? Well, already taken. New-MSFTUser would be a better separator of any known cmdlets or potential future cmdlets.

The other reason this becomes important is, there is a command precedence or tie-breaker when it comes to PowerShell. Think deck of cards and poker hands: https://en.wikipedia.org/wiki/List_of_poker_hands  

A similar rule of command precedence is used to break ties in PowerShell:

  • Full path (c:\file.ps1) beats an alias
  • An alias beats a Function
  • A function beats a cmdlet
  • A cmdlet beats an external command

In other words, if you define a function as ‘Ping’, then the function of Ping will not let the external command of ping.exe run.

Another common concern is the formatting of the noun, New-ContosoMailboxUser. Where should the capital letters go? ‘Camal’ formatting (or camel case) says, lower case, until the second word. Pascal formatting claims that all first letters of the words should be capitalized. Again, no one correct way, just normal conversions.

And don’t get me started on how many spaces an ‘indent’ is supposed to be, WOW, talk about almost a religious war over 2 vs. 4 vs. 5 whitespaces. I’ll stay away from that one as long as I can.

So there you go, a short discussion on which way should the ‘X’ value be? Be it toilet paper, noun formatting, indents, or a drink you like. If you’re adhering to consistency within yourself, any change is easy to adapt if you’re required to, based on the convention you’re currently working within.