4 ms·
Indeed some deep nesting here. You made me remember a quickbasic program I wrote for a class back in early 90s, where I packed the whole program in a single do-
by ifdefdebug 11y ago
Indeed some deep nesting here. You made me remember a quickbasic program I wrote for a class back in early 90s, where I packed the whole program in a single do-loop with about 20 indent levels at it's deepest, and I loved it. But... the prof told me to never do that again :( Anyway, thanks a lot for the flashback :)
- RyanRies 11y agoAgreed, it's not the most elegant code, but it's so short and simple I haven't bothered reorganizing the code yet. I probably will start adding features like re-bindable pause key, etc., and I will untangle the mess a bit at that time.
- asddubs 11y agoquickest way to do it is to negate your if conditions in the loop something like this: if (ForegroundWindow) { ... } else { MessageBox(NULL, L"Unable to detect foreground window!", L"UniversalPauseButton Error", MB_OK | MB_ICONERROR); } becomes if (!ForegroundWindow) { MessageBox(NULL, L"Unable to detect foreground window!", L"UniversalPauseButton Error", MB_OK | MB_ICONERROR); break; } ...
- xytop 11y agoI've added a pull request which reduces nesting a bit: https://github.com/ryanries/UniversalPauseButton/pull/2 https://github.com/ryanries/UniversalPauseButton/pull/2
- paradite 11y agofor reference: https://github.com/ryanries/UniversalPauseButton/blob/master/Main.cpp#L172 https://github.com/ryanries/UniversalPauseButton/blob/master...
- meritt 11y agoDeep nesting always bugs me too. It's so much cleaner and easier to understand (for me anyway) to identify the else case ahead of time and stop processing immediately.
- melvinmt 11y agohttp://refactoring.com/catalog/replaceNestedConditionalWithGuardClauses.html http://refactoring.com/catalog/replaceNestedConditionalWithG...
- RyanRies 11y agoAlright, should be pretty much taken care of in version 1.0.1.