Knowledgebase

Maintainable Code: Everything That Matters, Briefly Print

  • python, errors, guide, howto, solution, zillionkinghost, hosting, support
  • 0

The summary.

FOLLOW THE COMMUNITY STYLE AND ADOPT A FORMATTER

Style then never gets debated, and any Python programmer can read your code immediately.

COMMENTS SHOULD EXPLAIN WHY, NOT WHAT

The code already says what. A comment restating it adds nothing and goes stale.

Confusing code should be rewritten, not annotated.

CATCH SPECIFIC ERRORS, NEVER EVERYTHING

Catching indiscriminately hides genuine bugs, and silencing an error produces wrong results instead of visible failures.

VALIDATE AT THE BOUNDARY

Check data where it enters, then trust it internally.

Assume anything from outside is wrong until checked.

KEEP SECRETS OUT OF CODE AND OUT OF VERSION CONTROL

Set up the ignore file before the first commit.

If a secret was ever committed, rotate it. Removing it from history is not enough.

PIN YOUR DEPENDENCIES AND UPDATE DELIBERATELY

Not updating accumulates vulnerabilities; updating carelessly breaks things. Schedule it and test after.

THE TEST FOR MAINTAINABILITY

Could a competent person set this up and change something safely, from the repository alone?

Set it up yourself from scratch following your own instructions. That reveals every step you forgot to write down.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot