Skip to content
Sharp

Domain Modeling · interview question

A bug appears around instance methods. What is the strongest first debugging move?

Multiple choiceMediumchapter-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

D. Trace one concrete example, inspect the state transitions, and compare them to the intended rule before rewriting anything.

Why

That approach is reliable because it creates evidence. If every operation stays outside the object forever, the model can become a passive bag of fields.

Test yourself on Domain Modeling

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

Start free test
All Domain Modeling questions →