Make the next change easier
Maintainable code helps someone understand what a feature does and change it without guessing. Start with names that describe the job: a function called calculateOrderTotal tells a reader more than one called processData.
Keep each function focused on a clear task. Make its inputs and returned value easy to understand, and make changes to shared data deliberate.
Leave useful explanations
Comments are most helpful when they explain a business rule or a surprising decision. A comment that repeats the next line of code adds little. When a rule changes, update the explanation with the implementation.
Check behaviour before shipping
For a bug fix, reproduce the original problem and confirm that the corrected behaviour works. Include an edge case that matters, such as an empty form or a missing record. Prefer a small, reviewable change to an unrelated rewrite.
