DE Programming Ground Rules

  1. Always put code on GitHub, never use Google Drive or direct messaging.
  1. 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.
  2. 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.
  3. Remember to push changes to a branch, AND sync!
  1. 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:

  1. Naming conventions using: ClassNames, function_names, variable_names
  2. White space (PyCharm will give you help here)
  3. 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).
  1. Comment your code! Plus see bullet 4.
  1. 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.
  1. Document your code!

    Use the PEP257 docstring convention and keep to it well - you can read the short version PEP257, or the complete PEP257.

  1. This means that Sphinx (an automatic documentation generator) will work and display things properly.
  2. An example of this can be seen on GitHub. It has library, modules, and comments.
  1. UML Diagrams… USE THEM
  2. Handle errors properly with exceptions. If necessary, build your own errors for safety measures and use try..except..raise blocks in your code.
  3. Global variables are bad. Functions are better than types. Objects are likely to be better than complex data structures.
  4. Avoid from X import * as much as possible. It’s much better to import a specific function from X import Y or to use it in context of your code import X; X.Y(arg). Otherwise we will need to start handling lists of import names.