DS2002 Data Science Systems

Course materials and documentation for DS2002

View the Project on GitHub ksiller/ds2002-course

Best Practices for Readable and Maintainable Code

Use this page as a project checklist. You do not need to satisfy every item perfectly, but your code should reflect these principles where applicable.

General

Keep code easy to read

Comment with purpose

Organize project files

Make your project reproducible

Python

Use functions

if __name__ == "__main__":
    main()

Prefer a main() workflow

Handle external calls with try/except

Wrap calls to external services (e.g. boto3.client(), database clients, requests to URLs, file I/O) with try/except blocks so failures are understandable.

Use command-line arguments

Use command line arguments to allow users to pass configurables to the script. You can use sys.argv for this, or explore argparse (docs).

Use logging (not only print)

Keep imports clean

Bash

Safer shell scripts

Start scripts with:

set -euo pipefail

Write portable commands

Validate inputs early

Be explicit with cloud resources

Testing and verification

Test small, then full