|
|
|
|
|
by alexjarvis
3820 days ago
|
|
I agree that you can split validation parts into separate functions but this is conflating two concerns, for example the rewriting of the guard statement from guard item.count > 0 else {
throw VendingMachineError.OutOfStock
}
to if count == 0 {
throw VendingMachineError.OutOfStock
}
only proves that you can refactor the code to not use guard whereas the article starts by talking about small functions, where you could in fact still use guard in this case. |
|