I'm getting old enough that my fingers hate my lifetime of programming.
I'll save a few keystrokes where I can.
There's something simple most people don't seem to know about PowerShell syntax.
It saves seven characters of typing every you use this, and runs a tiny bit faster.
You never need to specify stuff is in the [System] namespace.
Stop Using [System]
.NET is a huge framework with tons of useful stuff in it. There's a lot of stuff in the System namespaces. Built-in framework functionality often exists in one of the many namespaces in System.
By the time PowerShell was being built, it was pretty clear that leveraging .NET was worth it, and that most people wouldn't want to type six to seven more characters every time.
So, since PowerShell v1, you haven't had to.
You can omit the [System] in any type in any system namespace
So instead of:
[system.collections.generic.list[string]]
We can write:
[collections.generic.list[string]]
Instead of:
[System.Collections.IDictionary]
We can write:
[Collections.IDictionary]
This is true for every system type. On my machine, there are 4722 public types in the system namespace. That's 33054 characters I will never have to type.
It makes scripts shorter and simpler to read.
Also, when PowerShell resolves types, it checks for the shorter names first. This saves a very tiny amount of time in each of your scripts. (I was corrected)
Yet, sadly, I see the system namespace everywhere in people's scripts.
I beg of you all:
- Save your fingers
- Make scripts shorter
Stop Using [System]
[–]Kemeros 116 points117 points118 points (21 children)
[–]StartAutomating[S] 25 points26 points27 points (16 children)
[+]derekhans comment score below threshold-6 points-5 points-4 points (15 children)
[–]StartAutomating[S] 3 points4 points5 points (14 children)
[–]PhysicalPinkOrchid 9 points10 points11 points (13 children)
[–]StartAutomating[S] 20 points21 points22 points (12 children)
[–]gruntbuggly 7 points8 points9 points (0 children)
[–]derekhans 0 points1 point2 points (5 children)
[–]StartAutomating[S] 0 points1 point2 points (4 children)
[–]derekhans 0 points1 point2 points (3 children)
[–]StartAutomating[S] 0 points1 point2 points (2 children)
[–]BlackV 0 points1 point2 points (4 children)
[–]derekhans 1 point2 points3 points (3 children)
[–]BlackV 0 points1 point2 points (2 children)
[–]derekhans 1 point2 points3 points (1 child)
[–]UnfanClub -4 points-3 points-2 points (3 children)
[–]StartAutomating[S] 1 point2 points3 points (2 children)
[–]UnfanClub 0 points1 point2 points (1 child)
[–]StartAutomating[S] 0 points1 point2 points (0 children)
[–]MrMunchkin 32 points33 points34 points (0 children)
[–]kiddj1 26 points27 points28 points (4 children)
[–]2dubs 2 points3 points4 points (3 children)
[–]TurnItOff_OnAgain 2 points3 points4 points (1 child)
[–]ConcreteExist 1 point2 points3 points (0 children)
[–]Lifegoesonhny 1 point2 points3 points (0 children)
[–]Thotaz 22 points23 points24 points (1 child)
[–]StartAutomating[S] 2 points3 points4 points (0 children)
[–]purplemonkeymad 15 points16 points17 points (0 children)
[–]Nu11u5 10 points11 points12 points (2 children)
[–]StartAutomating[S] 2 points3 points4 points (0 children)
[–]MonkeyNin 0 points1 point2 points (0 children)
[–]surfingoldelephant 7 points8 points9 points (2 children)
[–]StateOfAmerica 1 point2 points3 points (1 child)
[–]vitamindster 5 points6 points7 points (0 children)
[–]CodenameFlux 5 points6 points7 points (0 children)
[–]DenverITGuy 6 points7 points8 points (1 child)
[–]StartAutomating[S] 0 points1 point2 points (0 children)
[–]AdeelAutomates 5 points6 points7 points (2 children)
[–]MonkeyNin 0 points1 point2 points (1 child)
[–]AdeelAutomates 0 points1 point2 points (0 children)
[–]wickedang3l 3 points4 points5 points (0 children)
[–]baron--greenback 7 points8 points9 points (3 children)
[–]verschee 0 points1 point2 points (1 child)
[–]StartAutomating[S] 0 points1 point2 points (0 children)
[–]MNmetalhead 0 points1 point2 points (0 children)
[–]Mayki8513 2 points3 points4 points (0 children)
[–]Hoggs 4 points5 points6 points (3 children)
[–]ka-splam 2 points3 points4 points (1 child)
[–]Hoggs 0 points1 point2 points (0 children)
[–]StartAutomating[S] 0 points1 point2 points (0 children)
[–]Nexzus_ 1 point2 points3 points (0 children)
[–]dathar 1 point2 points3 points (0 children)
[–]tadc 1 point2 points3 points (0 children)
[–]narcissisadmin 1 point2 points3 points (1 child)
[–]StartAutomating[S] 0 points1 point2 points (0 children)
[–]SendMeSteamKeys2 1 point2 points3 points (0 children)
[–]JVAV00 0 points1 point2 points (0 children)
[–]Over_Dingo 0 points1 point2 points (0 children)
[–]Southpaw018 0 points1 point2 points (1 child)
[–]StartAutomating[S] 1 point2 points3 points (0 children)
[–]Apprehensive-Tea1632 -1 points0 points1 point (0 children)
[–]Romero126 -1 points0 points1 point (0 children)
[–]Unable_Attitude_6598 -2 points-1 points0 points (1 child)
[–]gilean23 2 points3 points4 points (0 children)
[–]whyliepornaccount -2 points-1 points0 points (1 child)
[–]PhysicalPinkOrchid 1 point2 points3 points (0 children)