-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code Formatting Epic: Use accepted best practices in code formatting to produce safe software #11
Comments
Well, believe me, I feel you, but this code was basically written in one day for POC, the one who wrote it just had to add more features as the time went by and he did not keep in mind code readability, flexibility, etc. The idea of open source is for you guys to not just use this project as is, but to also improving it. I will keep this issue open so more ppl will understand that this code is far from perfect and maybe even help improve this code. |
you are correct. maorfr re-arranged the code beautifully and it is now the latest ver |
Now that I know you're willing to accept feedback and merge PRs from others, I'll see if I can find some time one of these evenings to go through it myself and keep on improving things. Thanks all. |
PR #46 resolves a tiny portion of this issue |
I was just skimming your Arduino source code here, for instance: https://github.com/AmboVent/AmboVent/blob/master/.Software/Arduino%20Code/ventilation_machine/ventilation_machine.ino#L208
and I notice your formatting doesn't follow best practices to maximize for readability, maintainability, and safety. I recommend you change the code now and follow best practices as you write new code to minimize changes in the future. Here's a few examples:
if
statement or any type of loop.Instead of:
Do:
But instead of that, even better, replace numbers and do this. Notice there's not a single "magic number" anymore. Everything is now named.
Instead of this:
Do this:
Those are just a few of dozens and dozens of examples. This is really important to avoid safety pitfalls in the software, accidental mistakes and bugs. Additionally, it makes the code easier for outsiders to contribute and learn.
Note also that as you code and learn, many many many MANY things will be preferences, and there are multiple good ways to do things. However, many things have established "best practices" which avoid bad patterns and unsafe code. Frequently, multiple best practices exist. The things I point out above are best practices and produce safer code. Some of the formatting regarding putting the opening curly brace on a new line or on the same line, and how many spaces to use when indenting, are personal preferences but should be standardized in a code base. Whatever you do, please follow best practices.
The text was updated successfully, but these errors were encountered: