泄漏抽象的含义? [英] Meaning of Leaky Abstraction?

本文介绍了泄漏抽象的含义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

术语泄漏抽象"是什么意思?(请举例说明.我经常很难理解单纯的理论.)

What does the term "Leaky Abstraction" mean? (Please explain with examples. I often have a hard time grokking a mere theory.)

推荐答案

这里有一个 meatspace 示例:

汽车有司机的抽象.最纯粹的形式是方向盘、油门和刹车.这种抽象隐藏了很多引擎盖下的细节:发动机、凸轮、正时皮带、火花塞、散热器等.

Automobiles have abstractions for drivers. In its purest form, there's a steering wheel, accelerator and brake. This abstraction hides a lot of detail about what's under the hood: engine, cams, timing belt, spark plugs, radiator, etc.

这个抽象的巧妙之处在于,我们可以用改进的部分替换部分实现,而无需重新培训用户.假设我们用电子点火替换了分配器盖,我们用可变凸轮替换了固定凸轮.这些变化提高了性能,但用户仍然用方向盘转向并使用踏板来启动和停止.

The neat thing about this abstraction is that we can replace parts of the implementation with improved parts without retraining the user. Let's say we replace the distributor cap with electronic ignition, and we replace the fixed cam with a variable cam. These changes improve performance but the user still steers with the wheel and uses the pedals to start and stop.

这真的很了不起……一个 16 岁或 80 岁的人都可以操作这台复杂的机器,而并不真正了解它的内部工作原理!

It's actually quite remarkable... a 16 year old or an 80 year old can operate this complicated piece of machinery without really knowing much about how it works inside!

但是有泄漏.传输是一个小泄漏.在自动变速器中,您可以感觉到汽车在换档时会暂时失去动力,而在 CVT 中,您会一直感觉到平稳的扭矩.

But there are leaks. The transmission is a small leak. In an automatic transmission you can feel the car lose power for a moment as it switches gears, whereas in CVT you feel smooth torque all the way up.

还有更大的泄漏.如果发动机转速太快,可能会损坏它.如果发动机缸体过冷,汽车可能无法启动或性能不佳.如果您同时打开收音机、大灯和空调,您的油耗会下降.

There are bigger leaks, too. If you rev the engine too fast, you may do damage to it. If the engine block is too cold, the car may not start or it may have poor performance. And if you crank the radio, headlights, and AC all at the same time, you'll see your gas mileage go down.

这篇关于泄漏抽象的含义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆