Hacker News new | ask | show | jobs
by DeathArrow 1190 days ago
An interface is a contract. It shouldn't be concerned with implementation details and it should contain the absolute minimum to do the work.

public ResultType ChangeOil(Car c, Oil oil = null); is enough.

In the actual implementation of the interface we can check if oil is null and if it is, provide own oil which fits car. If oil is not null, we can check if it is enough and if the type fits car type.

We also can return a car with changed oil and an error.

However the user of the interface shouldn't be concerned with actual implementation details. The same way an user of a Web API shouldn't be concerned with actual implementation detail.

1 comments

> It shouldn't be concerned with implementation details

And then, when some poor programmer finally comes to writing an actual implementation, he finds out that it's literally impossible without magic.