Re:Ask HN: What's a mnemonic or concept that's helped your e...
by syndicatedjelly on Friday September 08, 2023 @10:41PM
(#37441695)
Legos interact with each other in a very well-defined manner. The circular interlocking portions must be manufactured to a tolerance of 10 micrometers so that the bricks lock as expected, but can be removed easily.
In a good interface (e.g. an API), the parameters passed around can be defined and characterized precisely, perhaps using input validation tools like a type system or escape hatches. The designer of an interface should know and handle all the permutations of data in and data out. If a surface-level function can't handle negative values, then the designer must know how the function will respond.
Back to Legos. despite their extraordinarily tight specifications, there is practically nothing that can't be built with Legos, in the precisely-defined Lego universe. Six 2x4 bricks fit together in 915,103,765 ways. I don't think any particular design decision by Lego enabled this, but it's almost like they build Turing-complete construction language out of Legos.
Similarly, good interfaces shouldn't unreasonably constrain the user.
Finally, and this may be stretching the analogy, Legos interfaces sort of act like a "black box". One can attach a Lego to any interface of an existing Lego project without concern for what color the bricks are, how many bricks are connected, even the types of all the other bricks involved. The interface is all that matters.
Likewise, a good interface doesn't require the user to dig into the source code to understand how to use the surface level connections.
In a good interface (e.g. an API), the parameters passed around can be defined and characterized precisely, perhaps using input validation tools like a type system or escape hatches. The designer of an interface should know and handle all the permutations of data in and data out. If a surface-level function can't handle negative values, then the designer must know how the function will respond.
Back to Legos. despite their extraordinarily tight specifications, there is practically nothing that can't be built with Legos, in the precisely-defined Lego universe. Six 2x4 bricks fit together in 915,103,765 ways. I don't think any particular design decision by Lego enabled this, but it's almost like they build Turing-complete construction language out of Legos.
Similarly, good interfaces shouldn't unreasonably constrain the user.
Finally, and this may be stretching the analogy, Legos interfaces sort of act like a "black box". One can attach a Lego to any interface of an existing Lego project without concern for what color the bricks are, how many bricks are connected, even the types of all the other bricks involved. The interface is all that matters.
Likewise, a good interface doesn't require the user to dig into the source code to understand how to use the surface level connections.
Reference: https://en.wikipedia.org/wiki/Lego