5 ms·
I'm glad I'm not the only one who pays attention to this. This is completely unsubstantiated and coming from a relatively inexperienced programmer, but it's bee
by saltyfamiliar 7y ago
I'm glad I'm not the only one who pays attention to this. This is completely unsubstantiated and coming from a relatively inexperienced programmer, but it's been my experience that better code tends to produce nicer shapes. An obvious example not mentioned in the article arises when code is nested too deeply and too thinly, creating jarring and disproportionate peaks.
- Thorrez 7y agoMicrosoft's docs have an interesting idea of what good nesting looks like: https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/bb776913(v=vs.85)?redirectedfrom=MSDN#basic-usage https://docs.microsoft.com/en-us/previous-versions/windows/d... Apparently 13 different indentation levels is good.
- reilly3000 7y agowow.
- jpz 7y agoI actually find that surprisingly readable, probably because of the indent size which clearly allows the eye to see the blocks - and the size of my very large monitor - but this code seems to indicate a religious dogma about avoiding early returns, which would otherwise straighten it up.
- a_t48 7y agoRefactoring it effectively needs some sort of scope guard, too, to run `pfd->Release();` and the like. It's just as much dogma to write C++ like C, avoiding RAII.
- DonHopkins 7y agoGood code should be tightly wrapped around the problem, and reflect the shape of the problem itself. But sometimes, the shape can be deceptive: https://www.youtube.com/watch?v=CAUxhXIeSc8 https://www.youtube.com/watch?v=CAUxhXIeSc8
- mtts 7y agoI review a lot of code for work and I agree with you that you can usually tell the quality of the code simply by looking at its outward appearance. Rough edges and bizarre shapes almost always indicate poor, unstructured thinking in the code itself. Not saying I go by shape alone, but if it looks messy, that's a warning flag.