参考实现

本页使用了标题或全文手工转换,现处于中国大陆简体模式
求闻百科,共笔求闻

软件开发过程中,参考实现(英语:Reference implenmentation,台湾作参考实作)是实现对应规范中所有要求的一种计算机程序,也偶尔被称作引用实装示例实现(sample implementation)或模型实现(model implementation)。参考实现通常伴随技术标准,演示了其他任何实现应做到的被视为“正确”的行为。

特征和例子

算法的参考实现(例如密码算法)通常来自标准化流程。在密码学领域,通常会将源代码作为公有领域软件发布。例如CERN httpd[1]Serpent密码、base64变种[2]、以及SHA-3[3]Openwall项目维护了一个包含多种算法的在公有领域下发布的参考实现源代码名单。[4]

参考实现可能达到或者未达到生产级质量。例如,夫琅和费协会MP3标准的参考实现通常无法与其他常见的实现(如LAME)在音质测试中相媲美[来源请求]。而Python编程语言的参考实现CPython则在生产中使用最为广泛[5]

测试

对参考实现进行软件测试可以提高规范的生产效率:

参考实现通常作为最终解释一个规范的实现(此定义有些大胆,但一般如此)。在一致性测试包的开发中,每个接口需要至少一个相对受信任的实现,以做到:(1) 发现规范中的错误和歧义,以及(2) 验证测试包的功能正确。[6]

参考实现的特征有:

  1. 与规范和测试包一同开发;
  2. 验证规范是可实现的;
  3. 确认测试包正常工作;
  4. 作为衡量其他实现的金标准;
  5. 一致性测试不充分时,有助于阐明规范的意图[7]

参考文献

  1. The birth of the web Licensing the web on cern.ch (2014)
  2. libb64 on sourceforge
  3. KeccakReferenceAndOptimized-3.2.zip mainReference.c "The Keccak sponge function, designed by Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche. For more information, feedback or questions, please refer to our website: http://keccak.noekeon.org/Implementation[永久失效链接] by the designers, hereby denoted as "the implementer". To the extent possible under law, the implementer has waived all copyright and related or neighboring rights to the source code in this file. https://creativecommons.org/publicdomain/zero/1.0/"
  4. Source code snippets and frameworks placed in the public domain on openwall.info
  5. Snow, Eric. PEP 421 -- Adding sys.implementation. Python.org. Python Software Foundation. 2012-01-26 [2017-01-06]. For a number of years now, the distinction between Python-the-language and CPython (the reference implementation) has been growing. 
  6. Dalci, Eric; Fong, Elizabeth; Goldfine, Alan (2003). Requirements for GSC-IS Reference Implementations. National Institute of Standards and Technology, Information Technology Laboratory. Requirements for GSC-IS Reference Implementations
  7. Curran, Patrick (2003). Conformance Testing: An Industry Perspective. Sun Microsystems. [1]