Question

It is not a programming question but instead more of a designing question.

Assuming data is stored in json.

For example, Get-Person "John" | Get-Employer or Get-Employer -Person "John"

Both way looks to return John's employer, the former one uses pipeline and later one uses inline parameter. I am sometimes confused: what is the advantage and disadvantage of each? When you guys are designing, what is your preference to use each of them?

For me, the only reason I come up with using the pipeline is that it saves us using variables if the value of the parameter needs to be evaluated.

Anyone has any thoughts on this question too?

Was it helpful?

Solution

There's no reason you need to pick one or the other. With proper parameter attributes and function design (use begin/process/end blocks) you can allow both options.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top