You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The instance resource code could do with some improvement to make it more readable. Do not do this until the test issue #330 has been implemented to ensure we don't introduce additional bugs as part of the refactoring process.
This ticket focuses on keeping the happy path left and avoiding nesting.
Most of the time else statements are not necessary. case is sometimes better, but even it is sometimes overused, so think carefully about the logic and avoid nesting as much as possible.
Also we should be careful not to next too many if statements on top of the other:
For example, this block starting here is very hard to read as it goes four levels in with if statements and I am pretty sure we can rewrite it for clarity.
Description
The instance resource code could do with some improvement to make it more readable. Do not do this until the test issue #330 has been implemented to ensure we don't introduce additional bugs as part of the refactoring process.
This ticket focuses on keeping the happy path left and avoiding nesting.
Most of the time else statements are not necessary.
case
is sometimes better, but even it is sometimes overused, so think carefully about the logic and avoid nesting as much as possible.Also we should be careful not to next too many if statements on top of the other:
For example, this block starting here is very hard to read as it goes four levels in with if statements and I am pretty sure we can rewrite it for clarity.
Then there are simpler examples like this:
Which can probably be rewritten like this without any adverse effects (verify this statement) and achieve the same result more elegantly:
This is not about NEVER using
else
, but I think in most cases you can totally do away with it.For more info, please read this:
https://dave.cheney.net/2020/02/23/the-zen-of-go#:~:text=Return%20early%20rather%20than%20nesting%20deeply
Acceptance Criteria
There is much that can be refactored, but to complete this ticket, I'd suggest we focus on refactoring to keep the happy path left, that is:
The text was updated successfully, but these errors were encountered: