DE Programming Ground Rules¶
- Always put code on GitHub, never use Google Drive or direct messaging.
- This means when working on a particular function, you will be working in a smaller team and contributing to a particular branch you set up together.
- Working on a branch in a small team (maybe 2-3) requires coordination so that you don’t create conflicts when pushing your changes to the branch.
- Remember to push changes to a branch, AND sync!
When writing Python, keep to the PEP8 Python styling guide.
This style guide is usually enabled in PyCharm to help you. This means you get a squiggle and a yellow/brown mark next to a violation (settings are in
Preferences > Editor > Inspections > Python). The key takeaways are:
- Naming conventions using: ClassNames, function_names, variable_names
- White space (PyCharm will give you help here)
- Tabs vs Space, PyCharm actually converts the tab key, and 4 spaces, into the same thing by default (so just don’t change this from default values, and you can use either).
- Comment your code! Plus see bullet 4.
- This can be in two main forms, inline or block. Again, keep to PEP8 to avoid differences between code. It’s the simplest one to keep to.
Document your code!
- This means that Sphinx (an automatic documentation generator) will work and display things properly.
- An example of this can be seen on GitHub. It has library, modules, and comments.
- UML Diagrams… USE THEM
- Handle errors properly with exceptions. If necessary, build your own errors for safety measures and use try..except..raise blocks in your code.
- Global variables are bad. Functions are better than types. Objects are likely to be better than complex data structures.
from X import *as much as possible. It’s much better to import a specific function
from X import Yor to use it in context of your code
import X; X.Y(arg). Otherwise we will need to start handling lists of import names.