4 ms·
Sometimes the comments are only required because the code is confusing. In this case the function both mutates the state, and renders the app. If using a frame
by ricardobeat 7y ago
Sometimes the comments are only required because the code is confusing.
In this case the function both mutates the state, and renders the app. If using a framework like React/Vue etc it might make perfect sense to call this function `move`, but here it has a lot more responsibility and would need a more representative name like update/setState/renderApp/etc. But I think it's pointless to debate as it breaks the single-responsibility principle and you're unlikely to find something like this in a large scale app anyway.
- bigmanwalter 7y agoIt could also be because the code is terse. In that case it makes sense to explain what's going on.