Each function should do one thing well.
If you describe it with “and,” it likely does too much.
Use action verbs and domain-specific language.
Boolean functions should start with is, has, or can.
Use guard clauses to handle edge cases upfront.
Keeps the “happy path” clear and readable.
Too many parameters = cognitive overload.
Group related ones into objects to simplify calls.
Avoid side effects.
Pure functions are predictable, testable, and parallelizable.
They obscure intent and often signal dual responsibilities.
Use enums or split into separate functions.
Use the Result Pattern for expected errors.
Reserve exceptions for truly exceptional cases.
Extract constants and enums to improve readability and maintainability.
Clean functions are the foundation of clean code. They reduce bugs, speed up reviews, and make your software easier to evolve. Petar’s advice: Be pragmatic, not dogmatic.
1
12
1