-
Is your code clear? If you had to go back to it in a month, would you be happy to? If someone else had to contribute to it, would they be able to?
A few suggestions:
-
Make your variable names descriptive and use the same naming conventions throughout the code.
-
For more complex pieces of logic, consider putting a comment, and maybe an example.
-
In the comments, focus on describing why the code does what it does, rather than describing what it does. The reader can most likely read the code, but not necessarily understand why it was necessary.
-
Don't overdo it in the comments. The code should be clear enough to speak for itself. Stale comments that no longer reflect the intent of the code can hurt code comprehension.
-
- Don't repeat yourself. Any time you see that the same piece of logic can be applied in multiple places, factor it out into a function, or variable, and reuse that code.
- Scan your code for expensive operations (large computations, DOM queries, React re-renders). Have you done your possible to limit their impact? If not, it is going to slow your app down.
- Can you think of cases where your current code will break? How are you handling errors? Should the user see them as notifications? Should your app try to auto-correct them for them?
- The Dash team uses integration tests extensively, and we highly encourage you to write tests for the main functionality of your component. In the
tests
folder of the boilerplate, you can see a sample integration test. By launching it, you will run a sample Dash app in a browser. You can run the test with:python -m pytest
-
Take a last look at the external resources that your component is using. Are all the external resources used referenced in
MANIFEST.in
?