API documentation with executable examples

被引:19
作者
Hoffman, D
Strooper, P
机构
[1] Univ Victoria, Dept Comp Sci, Victoria, BC V8W 3P6, Canada
[2] Univ Queensland, Software Verificat Res Ctr, Sch Elect Engn & Comp Sci, Brisbane, Qld 4072, Australia
关键词
D O I
10.1016/S0164-1212(02)00055-9
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
The rise of component-based software development has created an urgent need for effective application program interface (API) documentation. Experience has shown that it is hard to create precise and readable documentation. Prose documentation can provide a good overview but lacks precision. Formal methods offer precision but the resulting documentation is expensive to develop. Worse, few developers have the skill or inclination to read formal documentation. We present a pragmatic solution to the problem of API documentation. We augment the prose documentation with executable test cases, including expected outputs, and use the prose plus the test cases as the documentation. With appropriate tool support, the test cases are easy to develop and read. Such test cases constitute a completely formal, albeit partial, specification of input/output behavior. Equally important, consistency between code and documentation is demonstrated by running the test cases. This approach provides an attractive bridge between formal and informal documentation. We also present a tool that supports compact and readable test cases; and generation of test drivers and documentation, and illustrate the approach with detailed case studies. (C) 2002 Elsevier Science Inc. All rights reserved.
引用
收藏
页码:143 / 156
页数:14
相关论文
共 42 条
[1]   Embracing change with extreme programming [J].
Beck, K .
COMPUTER, 1999, 32 (10) :70-+
[2]  
Beck K., 1999, EXTREME PROGRAMMING
[3]  
Chang KH, 1998, J SYST SOFTWARE, V42, P141, DOI 10.1016/S0164-1212(98)10005-5
[4]  
Cheng ZY, 1999, ELEC SOC S, V99, P207
[5]  
DALEY N, 2000, SOFTWARE PRACTICE EX, V32, P465
[6]  
DEVEAUX D, 2001, P 2001 AUSTR SOFTW E, P3
[7]  
ENGELMANN S, 1991, THEORY INSTR PRINC A
[8]   Measuring the comprehensibility of Z specifications [J].
Finney, K ;
Rennolls, K ;
Fedorec, A .
JOURNAL OF SYSTEMS AND SOFTWARE, 1998, 42 (01) :3-15
[9]   Mathematical notation in formal specification: Too difficult for the masses? [J].
Finney, K .
IEEE TRANSACTIONS ON SOFTWARE ENGINEERING, 1996, 22 (02) :158-159
[10]  
FOWLER M, 1999, REFACTORING IMPROVIN, pCH4