Konstantin2 wrote: |
---|
7. Why do you use this style? [...] More empty lines you have, less code you see on your screen. Why do you hide your code from yourself?
|
So many times, I've seen bugs enter code, because people write:
1 2
|
if (condition)
execute_a_single_command();
|
and then, later, they want to add more actions to the conditional block, but just add a line to the code and forget to add the braces, making:
1 2 3
|
if (condition)
execute_a_single_command();
do_something_else();
|
Putting the braces in straight away is good defensive practice. It makes it less likely you - or someone else - will introduce a bug later. I'd always advise people to do it. This isn't 1993, and we're not working on 13" VGA monitors any more. We have large, hi-def monitors that can show acres of code, so we can afford to lose a couple of lines from the display in pursuit of robustness and maintainability.
And there's no need to be snarky. If you want to know why someone did something, just ask them. Don't add snide comments - that's rude, and makes this forum a more unpleasant place for everyone.
ANproCUBE wrote: |
---|
3) I don't think that recursions are a big deal, only the variables shouldn't be redefined...
|
In general, there's nothing wrong with recursion. But calling main() from within your program is illegal in C++, and is undefined behaviour.
That's why I put them into global. |
Global variables are a bad habit, and can lead to all sorts of problems. I'd advise you to learn better, safer ways of passing data around your program ASAP, rather than to carry on reinforcing bad habits.