PowerShell-Docs
PowerShell-Docs copied to clipboard
Expand on code reuse practices and considerations when scripting
Prerequisites
- [X] Existing Issue: Search the existing issues for this repository. If there is an issue that fits your needs do not file a new one. Subscribe, react, or comment on that issue instead.
- [X] Descriptive Title: Write the title for this issue as a short synopsis. If possible, provide context. For example, "Typo in
Get-Foo
cmdlet" instead of "Typo." - [X] Verify Version: If there is a mismatch between documentation and the behavior on your system, ensure that the version you are using is the same as the documentation. Check this box if they match or the issue you are reporting is not version specific.
Links
https://learn.microsoft.com/powershell/scripting/dev-cross-plat/performance/script-authoring-considerations
Summary
The section Avoid repeated calls to a function in PowerShell scripting performance considerations hits a good point. But there are quiet some situations were it is needed to (re)use the specific code block at several locations in a script as well, which leaves a dilemma:
- Should I create a quiet expensive function for a easier manageable DRY code, or
- Should I go for performance and copy the concerned piece of code block at several locations?
Therefore, I think it is good the supply a few alternatives to the expensive function calls.
- See: What is the best way to reuse static code
- related: #19318 Improve performance of static code reusage
Details
No response
Suggested Fix
No response