Skip to content
Sharp

Domain Modeling · interview question

Which option is the safer default when shipping code around instance methods?

Multiple choiceHardchapter-7-curatedpremiumdomain-modelinginstance-methods
python
from dataclasses import dataclass

@dataclass
class OrderLine:
    unit_price: float
    quantity: int

    def line_total(self) -> float:
        return self.unit_price * self.quantity
Choose one answer
Answer and explanation

Correct answer

A. Choose the simpler shape that keeps the rule obvious, validated, and easy to observe in logs or tests.

Why

The safest default is usually the one that lowers ambiguity and makes errors easier to diagnose.

Test yourself on Domain Modeling

A free test with instant, explained results. No account needed.

Start free test
All Domain Modeling questions →