03 Code Practices - Observatorio-do-Trabalho-de-Pernambuco/documentation GitHub Wiki

3. Code Practices

Guidelines on how we write, organize, and document our code.

3.1 Jupyter Notebooks naming conventions

Every Jupyter Notebook commited to the repository should follow these naming conventions:

  • Format: YYYY-MM-DD_initials_Purpose.ipynb (e.g., 2025-03-01_gsg_Polars_PoC.ipynb)
  • Date represents creation date
  • Initials should be lowercase and consistent for each team member
  • Purpose should be concise but descriptive

3.2 Notebook Structure (DISCUSS THIS TEMPLATE WITH TEAM)

Minimum Required Sections

  • Introduction, Examples, Conclusion

Organization Guidelines

  • Logical headers, clear code blocks
  • Comments for complex logic

3.3 Python Scripts Common Practices

File Organization

  • Group scripts by function or domain
  • Keep them short and focused

Logging and Error Handling

  • Use standard logging libraries
  • Graceful error handling with try/except

3.4 Code Documentation

Docstring Style Guide

  • NumPy or Google style (choose one consistently)
  • Minimum fields: description, parameters, returns

Module-Level Docs

  • Summarize purpose, highlight key functions or classes

Process documentation