A precondition is the minimum requirement an operation needs to execute correctly. Make valid inputs and the consequences of invalid inputs explicit to prevent inconsistent execution and failures that surface far from their cause. section 3.2.1 section 3.2
For an operation such as addEmployee, accepting a null employee is a design decision, not an accident. Rejecting it with an exception stops execution when no safe next step is known, but requires clients to handle failure. Alternatively, handle null as an accepted case and return early; this reduces client work but makes the operation more tolerant of bad data. section 3.2.1
Keep preconditions distinct from business validation rules:
- Use preconditions for code-level minimums, such as a required non-null attribute or a value restricted to A, B, or C. section 3.2.2
- Use validation rules for business constraints, such as limiting how often an employee may take a course. section 3.2.2
- Let services control flows that require validation and consistency checks before an action; let entities perform the checks they can. section 3.2.2
Choosing a null policy
Before adding an employee to a course, decide whether null violates the operation’s contract. Throw an exception when continuing would be unsafe; return without action when null is intentionally supported. State that choice clearly so callers do not have to infer it from later crashes. section 3.2.1
Use the diagram to see how services, validation components, and entities divide responsibility for consistency checks before an action. section 3.2.2







