psguide icon indicating copy to clipboard operation
psguide copied to clipboard

Just a couple of questions

Open nightroman opened this issue 12 years ago • 5 comments

Nice job and a lot of good points!

I have a couple of questions though.

Aliases. I think that DSL commands in some cases should be exposed and used as aliases, not functions, unless they use Verb-Noun names. See my thoughts in the section "Aliases as DSL commands" here: https://github.com/nightroman/Invoke-Build/wiki/Design-Notes.

$ErrorActionPreference. Why should not it be changed? It is quite often useful to set it to Stop in scripts and functions. Otherwise it is too easy to miss serious issues like missing commands (and there is no other way to stop at missing commands and some other show stopping errors). Besides, one does not even have to care of restoring $ErrorActionPreference, it is a scoped variable.

But when a script or function is supposed to be dot-sourced then I agree, settings should not be changed, otherwise this may affect a caller.

I hope these thoughts may be useful. If you disagree then it would be interesting and useful to know your thoughts.

Happy coding! Roman

nightroman avatar Jun 02 '14 04:06 nightroman

And one more remark, the last one. I really like the rest of guidelines.

Avoid externalizing your help to MAML, except you want to provide multiple cultures.

This guideline is not clear. If one uses MAML for help (note that this is not even simple) then there are reasons, and multiple cultures is not the only one. Here is an example. The script Invoke-Build.ps1 is about 18kb and its help (text, not MAML, MAML is 50kb) Invoke-Build-Help.ps1 is about 27kb, i.e. larger than the source code. If help comments were in the script itself then it would be much more difficult to work on both the code and help. That is why help and code were separated.

Besides, the tool which generates MAML from Invoke-Build-Help.ps1 checks the help source for issues like misspelled names, missing documentation, etc. With built-in help comments this would not be so easy.

nightroman avatar Jun 02 '14 05:06 nightroman

Hi @nightroman, thanks for your thoughts. It's been a while, I know, but I think it's worth to have a discussion about your arguments.

I totally agree on your aliases argument. It's well worth pointing it out. Feel free to extend the psguide with a pull request.

Regarding $ErrorActionPreference, I tend to have a strict perspective. I would rather force myself (and strongly advice my colleagues) to unit test the scripts (functions) before resorting to $ErrorActionPreference. I always thought of $ErrorActionPreference as being a preference of the user of the scripts, not the developer of the scripts.

I agree with you on the "weakness" of the guidance for MAML as well. Feel free to extend it with a pull request.

Thanks indeed for your feedback. Hope it helps!

ilkerde avatar Sep 01 '14 14:09 ilkerde

Hi @ilkerde,

I do not really want to interfere with pull requests. I just passed by and made a few remarks with some reasoning already included. Feel free to take them into account in the guidelines (or not) and close the issue.

Hope this helps, Roman

nightroman avatar Sep 07 '14 08:09 nightroman

@nightroman I will extend the guide regarding your concerns on aliases and enhance the MAML part as well. Thanks for your valuable input.

ilkerde avatar Sep 08 '14 06:09 ilkerde

Closed with 892cc4e

ilkerde avatar Sep 13 '14 20:09 ilkerde