5:17 Aliases, that's what was doing my head in. Still learning, slowly and the amount of people that release their code with aliases is super annoying. I spend after the time working out what they mean. One script I wrote, as I know I'll forget, I even commented what ever single line was doing to make it even more readable. Obviously I know that's not possible for large scripts but still useful for me.
@krwhynot3 жыл бұрын
Thank you for this video, I have been using these "proper" Powershell grammar tips to my current scripts and it is helping clean them up. Thanks again!
@tonyme7426 Жыл бұрын
Got to love the question on camel case as that is the biggest discussion we have on projects with external developers. Naming conventions.
@HarmonicaMustang8 ай бұрын
Glad to see I follow most of these practices already, though I didn't know about the $array += optimisation, I went back to my old scripts and modified them, they run much better now.
@PhrontDoor Жыл бұрын
I half agree with the hungarian notation one (around 14:20ish). Sure you can put other things in the $strName than a string. But if the programmer made it an strName then he likely intends for you to keep it a string so if you change it to an array, you'll break stuff done later on.
@daviddow55915 жыл бұрын
For more clarification on the memory usage of the array += thing: arrays are fixed sized collections of a single type. Assume you have an array (let's call it A) with 100 integers. If you want to add another integer to it (lets call this i), then the computer needs to allocate a new chunk of memory (let's call this array B) with enough space for 101 integers, copy A over to B, and then tack on i. So, if you do something like: $array = @(); 1..100 | foreach-object { $array += $_ } then you're asking the computer to allocate new memory 100 times. It isn't bad for small chunks of data, but adding data to the ends of lists is much more performant. If you want to run a head to head comparison, here's a piece of powershell code you can run (tested on v6): $range = 1..1000; $IntList=[System.Collections.Generic.List[int]]::new(); $IntArray = @(); write-output "List method(ms): $((measure-command -expression { $range | %{ $IntList.Add($_)}}).TotalMilliseconds)"; write-output "Array method(ms): $((measure-command -expression {$range | % {$IntArray += $_}}).TotalMilliseconds)"
@daviddow55915 жыл бұрын
Also, don't write code in scripts like the spaghetti I just wrote lol
@Chad-Skillable11 ай бұрын
Chris talks about this at 22:12
@RPG_ash Жыл бұрын
Anybody know what the talk/video was about his comment at the end by a guy called Mike and WFP? I'd like to watch that.
@MuhammadBerki2 жыл бұрын
Great session thanks 🙂👍
@fuleo5 жыл бұрын
In vscode, there's "ms" command latency for every command he typed. How do I set that in vscode ?
@michaelo1475 жыл бұрын
Did you ever figure this out?
@citelao4 жыл бұрын
@@michaelo147 It's probably a custom prompt. If you grab and save the current time (globally) in the prompt, you can check that value the next time the prompt appears. If you subtract the two values, you get time elapsed. "Elapsed time PowerShell" and "custom PowerShell prompts" are good starting searches.
@michaelo1474 жыл бұрын
@@citelao I finally had some time for this and this was absolutely it. Thank you for teaching me something new.
@rpfrompr3 жыл бұрын
@@citelao, could you explain? Was that added to him PS prompt?
@TheStevenWhiting2 жыл бұрын
@@rpfrompr As mentioned it appears to be related to the Prompt function. Where you can set what the prompt looks like. No clue on the code to make it display the elapsed time though. Someone has probably written a script for it somewhere.
@Our1stPlanet3 жыл бұрын
All good stuff. Any chance of getting the source code on Github ?
@BrianLalonde5 жыл бұрын
Is "Select-Object" more readable than "select"? I don't think maximizing syntax increases readability. Zero aliases or positional params improves approachability for neophytes, but it's obscuring noise to anyone with experience trying to see the big picture.
@daviddow55915 жыл бұрын
Well, aliases are good for shorthand at the terminal too, but with powershell core, it looks like aliases are going to be going away to some extent
@gareginasatryan67614 жыл бұрын
I agree. In a copy command it’s pretty obvious what the positional parameters are. copy was probably one of my first commands when I was around 13.
@-dash2 жыл бұрын
I think the idea is if you adhere to the schema, there's very little chance for ambiguity and almost certainly does anyone revisiting the code a favor. "Select", at a quick glance, could be referring to Select-String, Select-Object, Select-XML, etc.
@gorge54124 жыл бұрын
Ouch. His . . . manner-of-speaking . . . is . . . very . . . difficult-to-understand. A few words gets spit out slowly; he stops, pausing, then races through the next fifteen words. Had to bail out after two minutes. IT TOTALLY DISTRACTS FROM CONCENTRATING ON MATERIAL.
@TheStevenWhiting2 жыл бұрын
American? He has an accent here in the UK, its probably that that's bothering you.
@geroffmilan33282 жыл бұрын
@@TheStevenWhiting sounded fine to me too.
@go-meditate Жыл бұрын
I am a non-native english speaker and I understood everything perfectly fine.