Handling soft contracts
Sometimes, certain interface contracts are not absolutely required when a default behavior can be assumed by the interface. The functions that are not mandatory may be referred to as soft contracts.
Let's say we want to add a new function for landing a vehicle. Most vehicles have wheels, but some don't, especially high-tech ones! So, as part of the landing procedure, we must engage the wheels only when necessary.
How do we design a soft contract for an interface? In this case, we can assume that most future vehicles have no wheels and therefore the default behavior does not require engaging the wheels. Here, in the Vehicle module, we can add the engage_wheel! function to document and provide a default implementation, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access