6 ms·
My coding philosophy is centered around simple interfaces. I think of power sockets and plugs. The simpler the socket/plug design, the easier it is to plug in.
by jongjong 4y ago
My coding philosophy is centered around simple interfaces.
I think of power sockets and plugs.
The simpler the socket/plug design, the easier it is to plug in.
It's easier to connect a European plug which has 2 round pins than it is to connect a UK plug which has 3 rectangular pins at different angles.
You can imagine how difficult it would be to connect a plug with 10 pins; it would be difficult to get the alignment right and you would have to push hard and fiddle quite a bit to get it all the way in.
If you can get a module to do the same thing with a simpler interface, then that's generally a better module; it's typically a sign of good separation of concerns. Complex interfaces are often a sign that the module encourages micromanagement of its internal state; a leaky abstraction.
A module should be trusted to do its job. The only reason a module would provide complex interfaces is to provide flexibility... But modules don't need to provide flexibility because the whole point of a module is that it can be easily replaced with other modules when requirements change.
- xcambar 4y agoI love the socket/plug analogy. It's even better than it looks in Europe: there are actuality 3 contact points but only 2 are salient which allows for 2 easily pluggable positions (rotate 180deg). The ground is positioned twice for that matter. Only France has a variation around that to my knowledge, that is still compatible across Europe. And no one notices and just plugs in and out without thinking twice about it. There are some unsung heroes here.
- lock-the-spock 4y agoA tiny bit more complex: the German/European plug has the ground at the sides and so goes in both ways. The French/Belgian plug has instead a ground pin that goes from the socket into the plug (so the opposite of the other two). That means generally you'll be able to combine both and most products have a plug that allows to connect to both varieties. But there are some (especially Chinese and American) products which miss this diversity and either only fit in one of the two or produce local varieties for either one when it would well be feasible to produce a single version that fits both.
- afiori 4y agoThe EU has a huge variety of plugs and sockets, what people often call the EU plug are variation of the schuko[0] design. The standard EU plug is the Europlug[1] which is compatible with most (but not all) sockets in Europe and only handles low amperage. AFAIK Italy is the major outlier in having widespread sockets[2] that do not accept the Europlug [0] https://en.wikipedia.org/wiki/Schuko https://en.wikipedia.org/wiki/Schuko [1] https://en.wikipedia.org/wiki/Europlug https://en.wikipedia.org/wiki/Europlug [2] https://en.wikipedia.org/wiki/AC_power_plugs_and_sockets#Italy_(Type_L) https://en.wikipedia.org/wiki/AC_power_plugs_and_sockets#Ita... the one on the left, rated for 16A.
- 29athrowaway 4y agohttps://www.youtube.com/watch?v=baY3SaIhfl0 https://www.youtube.com/watch?v=baY3SaIhfl0
- irjustin 4y ago> It's easier to connect a European plug which has 2 round pins than it is to connect a UK plug which has 3 rectangular pins at different angles. Speaking strictly on plugs - while I agree it is simpler/easier - I disagree that EU plug is better. For the bulk and lack of directionality - significantly safer (pin lengths, shielded to tip), requires a ground pin even if dummy, carries 13A easy! The safety aspects are incredible[0]. I do not worry about my small children at all. Lived in HK where the EU (China) and UK (HK) are pretty common in one household. [0] https://www.youtube.com/watch?v=UEfP1OKKz_Q https://www.youtube.com/watch?v=UEfP1OKKz_Q
- laumars 4y agoThe thing with electrical plus is that they should be designed around safety first, rather than convenience. And the U.K. plug is a lot more safety focused than many other plug standards. The advantage of the U.K. plug is that live pins are physically blocked and only released when the Earth pin is present. This is why the Earth pin is slightly longer on U.K. plugs and why insulated devices have a plastic Earth pin rather than no pin at all. The advantage of this is so you cannot jam things into them (either accidentally or intentionally) without the Earth pin. Thus making the plug much safer. I’ve found U.K. plugs to be much more secure inside the socket too. US plugs often come away from the wall when there is a little bit of weight or tension on the plug. U.K. plugs require a great deal more pressure to come loose from the socket. If I were to bring this back to types I’d say one needs to evaluate what the requirements are: safety or convenience.
- brabel 4y agoI don't think the discussion really was about plugs.
- laumars 4y agoOriginally, no. But discussions evolved
- mirekrusin 4y agoWhen I was a kid before we had legos we had some soviet alternative called constructor or something. Everything was made from metal, crews etc. obviously as a kid one of the first “hello world” things you will build is “plug” that you can insert into those holes in the wall. My older brother was lucky when he did it as the fuse in the house went off. My younger brother did the same about a decade later but holding in his hand two metal pins. He was also lucky that my dad was just passing through corridor and pushed him out. He got away with just burned skin on the fingers and a bit of shock.
- fennecfoxy 4y agoSounds like a more dangerous version of meccano
- j1elo 4y agoUSB-C would be a nice looking single-argument function... but parameterized with every possible generic template meta-programming feature in the language.