“Universal design principle”
In this video the presenter associates what he calls the Universal design principle to Scott Meyers. He also attributes him with the name. I can’t find another source on this but I have seen the principle passed around by others such as Robert C. Martin. The principle is, “Make interfaces hard to use incorrectly and easy to use correctly.” The presenter had a picture of a pestle and cup; the idea being that it’s really easy to use and can’t be used any other way.
That got me thinking and for the first time I think I believe that this principle is the wrong way to think about it. Why? Because being the kind of gutter thinker I am I immediately thought of other uses for that pestle…some places it could be stuck. I suppose this would be considered the “wrong” use and so it doesn’t follow the principle but wait!
What if you WANT to use it that way?
So I think that perhaps a more useful, a more defensive way of thinking about this principle is to say that, “The use of an interface in any way that works is ‘correct’.” In other words, regardless of the intention of the interface designer, if it can be used in a particular way then it’s a correct use of that interface. It then follows that it’s the duty of the designer to make sure that his or her intentions MUST be followed because they’re the only use that the interface supports.
We then get a sort of inversion of the principle that I think more clearly defines the intention of the principle: to make sure your interfaces are adequately specified and that implementations protect themselves from violations of that interface…BUT…your implementation must also handle correctly any correct use your interface allows. That way if someone decides they want to stick it where the sun doesn’t shine…then either it should not fit, or it at least shouldn’t break.
January 17, 2013 at 11:18 am
> then either it should not fit, or it at least shouldn’t break.
This is just a corollary of the “meyers principle”, both follow from “hard to use incorrectly”: If it would break, it would have been used incorrectly. So the principle – at least with the arguments you presented – doesn’t need refinement.
January 17, 2013 at 5:06 pm
It is a corollary but I think it gives us a better view of the meaning. If it would break, under my modification, doesn’t mean it was used incorrectly but that the implementation doesn’t adequately follow the interface. The wording may then change to, “Make your interfaces easy to implement correctly,” though I’m not sure what the first part would change to…hard to implement incorrectly? The main point being that ANY use of an interface is valid if it compiles…given a strongly typed language of course.