3 ms·
It's obvious with Color, but when you deal with more complex stuff, code like computation_service.set_status(ComputeStatus::NotEnoughMemory); system.se
by jeroenhd 2y ago
It's obvious with Color, but when you deal with more complex stuff, code like
computation_service.set_status(ComputeStatus::NotEnoughMemory);
system.set_state(SystemState::Failure);
is a lot clearer than
computation_service.set_state(.NotEnoughMemory);
system.set_state(.Failure);
in my opinion. Both objects/structs/whatevers can have a state type of their own but the shorthand form does not indicate whether or not the two can be used interchangeably. As a workaround, you could rename the setter to set_computation_state and set_system_state but then you're just repeating yourself in a different manner that's not as precise.
- WhereIsTheTruth 2y agoObviously, you should still have the choice to be verbose when the context requires it, pragmatism is the key In your example, to me, the value is obfuscated, I prefer conciseness, it's easier to read and it makes more sense Besides, it encourages developers to better name their variables/functions SwiftUI made me appreciate it more
- account42 2y agoI disagree about which one of your examples is clearer. The first has too much visual noise you need to parse before you can see what is going on.