泄漏抽象的含义? [英] 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.

也有更大的泄漏.如果发动机转速过快,可能会损坏发动机.如果发动机缸体太冷,则汽车可能无法启动或性能不佳.而且,如果您同时摇动收音机,前灯和AC,您会发现油耗降低了.

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天全站免登陆