top | item 42100554

(no title)

mariodiana | 1 year ago

OOP dweeb here. Since "Door" is an object, shouldn't the behavior be encapsulated and accessible to the client only via messaging? Then, we have "open", "close", "lock", and "unlock" -- and however this is implemented is the object's business, and implemented according to current business rules. The business rules may change, but the interface won't.

If we want to know the Door object's state, that's another set of messages.

If the door is open and locked, we don't know what's supposed to happen until we reference the business rules, which is what a lot of people on here are alluding to. Maybe we have a deadbolt, but maybe it's fine to assume that the user is going to unlock the door if necessary before closing it, and that the closed door is now in an unlocked state until the "lock" message is sent.

However this is implemented, our tests will only be on the Door object's interface, and we'll be testing the business rules.

discuss

order

No comments yet.