实现细节的定义是什么? [英] What is the definition of an implementation detail?

查看:37
本文介绍了实现细节的定义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在互联网上经常看到这个词(实际上,在谷歌上输入它会返回很多结果).

I see this term on the internet a lot (in fact, typing it on google returns a lot of results).

实施细节"的确切定义是什么?

What is the exact definition of an "implementation detail"?

推荐答案

这是一种由代码产生的行为,它可能会被使用代码所依赖,尽管编写代码的规范并未指定该行为.因此,相同规范的其他实现可能不会表现出相同的行为,并且会破坏该消耗代码.这就是为什么依赖它们是不好的.

It's a behavior produced by code which may be relied on by consuming code, though that behavior is not specified by the spec the code is written to. Hence, other implementations of the same spec may not exhibit the same behavior, and will break that consuming code. That's why it's bad to rely on them.

例如,如果您要针对指定数组排序而不是它使用的算法的列表接口编写一些代码,并且您需要将 sort 方法设为 stable,并且您的代码版本与非稳定排序算法一起使用,那么您的代码就会崩溃.

For instance, if you were to write some code against a list interface which specified an array sort but not the algorithm it used, and you needed the sort method to be stable, and a version of your code was used with a non-stable sort algorithm, then your code would break.

这篇关于实现细节的定义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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