build-image icon indicating copy to clipboard operation
build-image copied to clipboard

Source Review: Try Pattern implementation is not in line with convention or expectation

Open brcaswell opened this issue 3 years ago • 2 comments

https://github.com/tmds/build-image/blob/0f398a6b36362f4d295931d046dbdb2f1dbab1e6/src/build-image/ContainerEngine.cs#L40

We should be returning an integral value (bool or int) and using out param on the method.

Edit: I referenced link to the incorrect line.

brcaswell avatar Aug 07 '22 10:08 brcaswell

we can also refactor the method implementation at bit there as well,

  • quite a few of those operations (collection instance of ProcessStartInfo) aren't caller instance dependent (since they are manifested from Docker and Prodman const, respectfully) and could otherwise be static readonly initialized.
  • based on the behavior, we don't need to break out of the loop, we can return -- removing the need to declare the variable version and command outside of the loop.

brcaswell avatar Aug 07 '22 11:08 brcaswell

If you make a PR that improves the style and readability of the code, I'll take it.

I don't intend to change it myself unless I'm making functional changes in that area.

tmds avatar Aug 19 '22 21:08 tmds

Closing, as I have no plans to re-factor this code.

tmds avatar Oct 26 '22 14:10 tmds