1 | <html> |
---|
2 | <head> |
---|
3 | <title>Boost Library Requirements and Guidelines</title> |
---|
4 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
5 | <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> |
---|
6 | <meta name="ProgId" content="FrontPage.Editor.Document"> |
---|
7 | <meta name="Microsoft Border" content="none, default"> |
---|
8 | </head> |
---|
9 | <body bgcolor="#ffffff" text="#000000"> |
---|
10 | <table border="1" bgcolor="#007f7f" cellpadding="2"> |
---|
11 | <tr> |
---|
12 | <td bgcolor="#ffffff"><img src="../boost.png" alt="boost.png (6897 bytes)" width="277" height="86"></td> |
---|
13 | <td><a href="../index.htm"><font face="Arial" color="#ffffff"><big>Home</big></font></a></td> |
---|
14 | <td><a href="../libs/libraries.htm"><font face="Arial" color="#ffffff"><big>Libraries</big></font></a></td> |
---|
15 | <td><a href="../people/people.htm"><font face="Arial" color="#ffffff"><big>People</big></font></a></td> |
---|
16 | <td><a href="faq.htm"><font face="Arial" color="#ffffff"><big>FAQ</big></font></a></td> |
---|
17 | <td><a href="index.htm"><font face="Arial" color="#ffffff"><big>More</big></font></a></td> |
---|
18 | </tr> |
---|
19 | </table> |
---|
20 | <h1 align="left">Boost Library Requirements and Guidelines</h1> |
---|
21 | <p align="left"><a href="#Introduction">Introduction</a><br> |
---|
22 | <a href="#Requirements">Requirements</a><br> |
---|
23 | <a href="#License">License requirements</a><br> |
---|
24 | <a href="#Portability">Portability requirements</a><br> |
---|
25 | <a href="#Ownership">Ownership</a><br> |
---|
26 | <a href="#Guidelines">Guidelines</a><br> |
---|
27 | <a href="#Design_and_Programming">Design and programming</a><br> |
---|
28 | <a href="#Directory_structure">Directory structure and |
---|
29 | filenames</a><br> |
---|
30 | <a href="#Naming­_consistency">Naming consistency</a><br> |
---|
31 | <a href="#Documentation">Documentation</a><br> |
---|
32 | <a href="#Rationale">Rationale</a><br> |
---|
33 | <a href="#Exception-specification">Exception-specification |
---|
34 | rationale</a><br> |
---|
35 | <a href="#Naming">Naming conventions rationale</a><br> |
---|
36 | <a href="#code_fonts">Source code fonts rationale</a><br> |
---|
37 | <a href="#Tabs">Tabs rationale</a><br> |
---|
38 | <a href="#JavaScript">ECMAScript/JavaScript rationale</a><br> |
---|
39 | <a href="#Rationale_rationale">Rationale rationale</a><br> |
---|
40 | <a href="#Acknowledgements">Acknowledgements rationale</a></p> |
---|
41 | <h2 align="left"><a name="Introduction">Introduction</a></h2> |
---|
42 | <p align="left">This page describes requirements and guidelines for the content of |
---|
43 | a library submitted to Boost.</p> |
---|
44 | <p align="left">See the <a href="submission_process.htm">Boost Library Submission |
---|
45 | Process</a> page for a description of the process involved.</p> |
---|
46 | <h2 align="left"><a name="Requirements">Requirements</a></h2> |
---|
47 | <p>To avoid the frustration and wasted time of a proposed library being rejected, |
---|
48 | it must meets these requirements:</p> |
---|
49 | <ul> |
---|
50 | <li> |
---|
51 | The license must meet the <a href="#License">license requirements</a> |
---|
52 | below. Restricted licenses like the GPL and LGPL are not acceptable. |
---|
53 | <li> |
---|
54 | The copyright <a href="#Ownership">ownership</a> |
---|
55 | must be clear. |
---|
56 | <li> |
---|
57 | The library must be generally useful and not restricted to a narrow problem |
---|
58 | domain. |
---|
59 | <li> |
---|
60 | The library must meet the <a href="#Portability">portability requirements</a> |
---|
61 | below. |
---|
62 | <li> |
---|
63 | The library must come reasonably close to meeting the <a href="#Guidelines">Guidelines</a> |
---|
64 | below. |
---|
65 | <ul> |
---|
66 | <li> |
---|
67 | <a href="#Design_and_Programming">Design and Programming</a> |
---|
68 | <li> |
---|
69 | <a href="#Directory_structure">Directory Structure</a> |
---|
70 | <li> |
---|
71 | <a href="#Documentation">Documentation</a></li> |
---|
72 | </ul> |
---|
73 | <li> |
---|
74 | The author must be willing to participate in discussions on the mailing list, |
---|
75 | and to refine the library accordingly.</li> |
---|
76 | </ul> |
---|
77 | <p>There's no requirement that an author read the mailing list for a time before |
---|
78 | making a submission. It has been noted, however, that submissions which begin |
---|
79 | "I just started to read this mailing list ..." seem to fail, often |
---|
80 | embarrassingly.</p> |
---|
81 | <h3 align="left"><a name="License">License</a> requirements</h3> |
---|
82 | <p>The preferred way to meet the license requirements is to use the <a href="../LICENSE_1_0.txt"> |
---|
83 | Boost Software License</a>. See <a href="license_info.html">license information</a>. |
---|
84 | If for any reason you do not intend to use the Boost Software License, please |
---|
85 | discuss the issues on the Boost <a href="mailing_lists.htm#main">developers |
---|
86 | mailing list</a> first.</p> |
---|
87 | <p>The license requirements:</p> |
---|
88 | <ul> |
---|
89 | <li> |
---|
90 | Must be simple to read and understand. |
---|
91 | <li> |
---|
92 | Must grant permission without fee to copy, use and modify the software for any |
---|
93 | use (commercial and non-commercial). |
---|
94 | <li> |
---|
95 | Must require that the license appear on all copies of the software source code. |
---|
96 | <li> |
---|
97 | Must not require that the license appear with executables or other binary uses |
---|
98 | of the library. |
---|
99 | <li> |
---|
100 | Must not require that the source code be available for execution or other |
---|
101 | binary uses of the library. |
---|
102 | <li> |
---|
103 | May restrict the use of the name and description of the library to the standard |
---|
104 | version found on the Boost web site.</li> |
---|
105 | </ul> |
---|
106 | <h3 align="left"><a name="Portability">Portability</a> requirements</h3> |
---|
107 | <ul> |
---|
108 | <li> |
---|
109 | <p align="left">A library's interface must portable and not restricted to a |
---|
110 | particular compiler or operating system.</p> |
---|
111 | <li> |
---|
112 | <p align="left">A library's implementation must if possible be portable and not |
---|
113 | restricted to a particular compiler or operating system. If a portable |
---|
114 | implementation is not possible, non-portable constructions are acceptable if |
---|
115 | reasonably easy to port to other environments, and implementations are provided |
---|
116 | for at least two popular operating systems (such as UNIX and Windows).</p> |
---|
117 | <li> |
---|
118 | <p align="left">There is no requirement that a library run on C++ compilers which |
---|
119 | do not conform to the ISO standard. </p> |
---|
120 | <li> |
---|
121 | <p align="left">There is no requirement that a library run on any particular C++ |
---|
122 | compiler. Boost contributors often try to ensure their libraries work |
---|
123 | with popular compilers. The boost/config.hpp <a href="../libs/config/config.htm"> |
---|
124 | configuration header</a> is the preferred mechanism for working around |
---|
125 | compiler deficiencies.</p> |
---|
126 | </li> |
---|
127 | </ul> |
---|
128 | <p align="left">Since there is no absolute way to prove portability, many boost |
---|
129 | submissions demonstrate practical portability by compiling and executing |
---|
130 | correctly with two different C++ compilers, often under different operating |
---|
131 | systems. Otherwise reviewers may disbelieve that porting is in fact |
---|
132 | practical.</p> |
---|
133 | <h3 align="left"><a name="Ownership">Ownership</a></h3> |
---|
134 | <p align="left">Are you sure you own the library you are thinking of |
---|
135 | submitting? "How to Copyright Software" by MJ Salone, Nolo Press, |
---|
136 | 1990 says:</p> |
---|
137 | <blockquote> |
---|
138 | <p align="left">Doing work on your own time that is very similar to programming |
---|
139 | you do for your employer on company time can raise nasty legal problems. |
---|
140 | In this situation, it's best to get a written release from your employer in |
---|
141 | advance.</p> |
---|
142 | </blockquote> |
---|
143 | <p align="left">Place a copyright notice in all the important files you submit. |
---|
144 | Boost won't accept libraries without clear copyright information.</p> |
---|
145 | <h2 align="left"><a name="Guidelines">Guidelines</a></h2> |
---|
146 | <p align="left">Please use these guidelines as a checklist for preparing the |
---|
147 | content a library submission. Not every guideline applies to every |
---|
148 | library, but a reasonable effort to comply is expected.</p> |
---|
149 | <h3><a name="Design_and_Programming">Design and Programming</a></h3> |
---|
150 | <ul> |
---|
151 | <li> |
---|
152 | Aim first for clarity and correctness; optimization should be only a secondary |
---|
153 | concern in most Boost libraries.</li> |
---|
154 | </ul> |
---|
155 | <ul> |
---|
156 | <li> |
---|
157 | Aim for ISO Standard C++. Than means making effective use of the standard |
---|
158 | features of the language, and avoiding non-standard compiler extensions. It |
---|
159 | also means using the C++ Standard Library where applicable.</li> |
---|
160 | </ul> |
---|
161 | <ul> |
---|
162 | <li> |
---|
163 | Headers should be good neighbors. See the <a href="header.htm">header policy</a>. |
---|
164 | See <a href="#Naming­_consistency">Naming consistency</a>.</li> |
---|
165 | </ul> |
---|
166 | <ul> |
---|
167 | <li> |
---|
168 | Follow quality programming practices. See, for example, "Effective C++" 2nd |
---|
169 | Edition, and "More Effective C++", both by Scott Meyers, published by Addison |
---|
170 | Wesley.</li> |
---|
171 | </ul> |
---|
172 | <ul> |
---|
173 | <li> |
---|
174 | Use the C++ Standard Library or other Boost libraries, but only when the |
---|
175 | benefits outweigh the costs. Do not use libraries other than the C++ |
---|
176 | Standard Library or Boost. See <a href="library_reuse.htm">Library reuse</a>.</li> |
---|
177 | </ul> |
---|
178 | <ul> |
---|
179 | <li> |
---|
180 | Read <a href="imp_vars.htm">Implementation Variation</a> to see how to supply |
---|
181 | performance, platform, or other implementation variations.</li> |
---|
182 | </ul> |
---|
183 | <ul> |
---|
184 | <li> |
---|
185 | Read the <A href="separate_compilation.html">guidelines for libraries with |
---|
186 | separate source</A> |
---|
187 | to see how to ensure that compiled link libraries meet user expectations. |
---|
188 | </li> |
---|
189 | </ul> |
---|
190 | <ul> |
---|
191 | <LI> |
---|
192 | Use the naming conventions of the C++ Standard Library (See <a href="#Naming">Naming |
---|
193 | conventions rationale</a>): |
---|
194 | <br> |
---|
195 | <ul> |
---|
196 | <li> |
---|
197 | Names (except as noted below) should be all lowercase, with words separated by |
---|
198 | underscores. |
---|
199 | <li> |
---|
200 | Acronyms should be treated as ordinary names (e.g. <code>xml_parser</code> instead |
---|
201 | of <code>XML_parser</code>). |
---|
202 | <li> |
---|
203 | Template parameter names begin with an uppercase letter. |
---|
204 | <li> |
---|
205 | Macro (gasp!) names all uppercase and begin with BOOST_.</li> |
---|
206 | </ul> |
---|
207 | </LI> |
---|
208 | </ul> |
---|
209 | <ul> |
---|
210 | <li> |
---|
211 | Choose meaningful names - explicit is better than implicit, and readability |
---|
212 | counts. There is a strong preference for clear and descriptive names, even if |
---|
213 | lengthy.</li> |
---|
214 | </ul> |
---|
215 | <ul> |
---|
216 | <li> |
---|
217 | Use exceptions to report errors where appropriate, and write code that is safe |
---|
218 | in the face of exceptions.</li> |
---|
219 | </ul> |
---|
220 | <ul> |
---|
221 | <li> |
---|
222 | Avoid exception-specifications. See <a href="#Exception-specification">exception-specification |
---|
223 | rationale</a>.</li> |
---|
224 | </ul> |
---|
225 | <ul> |
---|
226 | <li> |
---|
227 | Provide sample programs or confidence tests so potential users can see how to |
---|
228 | use your library.</li> |
---|
229 | </ul> |
---|
230 | <ul> |
---|
231 | <li> |
---|
232 | Provide a regression test program or programs which follow the <a href="test_policy.htm"> |
---|
233 | Test Policies and Protocols</a>.</li> |
---|
234 | </ul> |
---|
235 | <ul> |
---|
236 | <li> |
---|
237 | Although some boost members use proportional fonts, tabs, and unrestricted line |
---|
238 | lengths in their own code, boost's widely distributed source code should follow |
---|
239 | more conservative guidelines: |
---|
240 | <ul> |
---|
241 | <li> |
---|
242 | Use fixed-width fonts. See <a href="#code_fonts">fonts rationale</a>. |
---|
243 | <li> |
---|
244 | Use spaces rather than tabs. See <a href="#Tabs">tabs rationale</a>. |
---|
245 | <li> |
---|
246 | Limit line lengths to 80 characters.</li> |
---|
247 | </ul> |
---|
248 | </li> |
---|
249 | </ul> |
---|
250 | <ul> |
---|
251 | <li> |
---|
252 | End all documentation files (HTML or otherwise) with a copyright message and a |
---|
253 | licensing message. See the <a href="#Copyright">end of this file</a> for an |
---|
254 | example of the preferred form.</li> |
---|
255 | </ul> |
---|
256 | <ul> |
---|
257 | <li> |
---|
258 | Begin all source files (including programs, headers, scripts, etc.) with: |
---|
259 | <br> |
---|
260 | <ul> |
---|
261 | <li> |
---|
262 | A comment line describing the contents of the file.<br> |
---|
263 | |
---|
264 | <li> |
---|
265 | Comments describing copyright and licensing. The preferred form is:<br> |
---|
266 | <br> |
---|
267 | <code>// Copyright Jane Programmer 2002. Use, modification, and distribution |
---|
268 | are<br> |
---|
269 | // subject to the Boost Software License, Version 1.0. (See accompanying<br> |
---|
270 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)<br> |
---|
271 | </code> |
---|
272 | <br> |
---|
273 | Please leave an empty line before and after the copyright and license comments. |
---|
274 | It is fine if the copyright and license messages are on different lines, but |
---|
275 | there should be no other intervening text. Do not include "All rights reserved" |
---|
276 | in the copyright message.<br> |
---|
277 | <br> |
---|
278 | See <a href="license_info.html">license information page</a> for more |
---|
279 | information about the Boost Software License.<br> |
---|
280 | <br> |
---|
281 | Note that developers should not include a copy of <code>LICENSE_1_0.txt</code> in |
---|
282 | their libraries; Boost distributions already include a copy in the Boost root |
---|
283 | directory.<br> |
---|
284 | |
---|
285 | <li> |
---|
286 | A comment line referencing your library on the Boost web site. For example:<br> |
---|
287 | <br> |
---|
288 | <code>// See http://www.boost.org/libs/foo for library home page.</code><br> |
---|
289 | <br> |
---|
290 | where <code>foo</code> is the directory name (see below) for your library. As |
---|
291 | well as aiding users who come across a Boost file detached from its |
---|
292 | documentation, some of Boost's automatic tools depend on this comment to |
---|
293 | identify which library header files belong to.</li> |
---|
294 | </ul> |
---|
295 | </li> |
---|
296 | </ul> |
---|
297 | <ul> |
---|
298 | <li> |
---|
299 | Make sure your code compiles in the presence of the <code>min()</code> and <code>max()</code> |
---|
300 | macros. Some platform headers define <code>min()</code> and <code>max()</code> macros which |
---|
301 | cause some common C++ constructs to fail to compile. Some simple tricks can protect your code |
---|
302 | from inappropriate macro substitution:<br> |
---|
303 | <ul> |
---|
304 | <li> |
---|
305 | If you want to call <code>std::min()</code> or <code>std::max()</code>:<br> |
---|
306 | <ul> |
---|
307 | <li> |
---|
308 | If you do not require argument-dependent look-up, use <code>(std::min)(a,b)</code>. |
---|
309 | </li> |
---|
310 | <li> |
---|
311 | If you do require argument-dependent look-up, you should:<br> |
---|
312 | <ul> |
---|
313 | <li><code>#include <boost/config.hpp></code></li> |
---|
314 | <li>Use <code>BOOST_USING_STD_MIN();</code> to bring <code>std::min()</code> into |
---|
315 | the current scope.</li> |
---|
316 | <li>Use <code>min BOOST_PREVENT_MACRO_SUBSTITUTION (a,b);</code> to make an |
---|
317 | argument-dependent call to <code>min(a,b)</code>.</li> |
---|
318 | </ul> |
---|
319 | </li> |
---|
320 | </ul> |
---|
321 | </li> |
---|
322 | <li> |
---|
323 | If you want to call <code>std::numeric_limits<int>::max()</code>, use |
---|
324 | <code>(std::numeric_limits<int>::max)()</code> instead.<br> |
---|
325 | </li> |
---|
326 | <li> |
---|
327 | If you want to call a <code>min()</code> or <code>max()</code> member function, |
---|
328 | instead to doing <code>obj.min()</code>, use <code>(obj.min)()</code>.<br> |
---|
329 | </li> |
---|
330 | <li> |
---|
331 | If you want to declare or define a function or a member function named <code>min</code> |
---|
332 | or <code>max</code>, then you must use the <code>BOOST_PREVENT_MACRO_SUBSTITUTION</code> |
---|
333 | macro. Instead of writing <code>int min() { return 0; }</code> you should write |
---|
334 | <code>int min BOOST_PREVENT_MACRO_SUBSTITUTION () { return 0; }</code> This is true |
---|
335 | regardless if the function is a free (namespace scope) function, a member function or a |
---|
336 | static member function, and it applies for the function declaration as well as the |
---|
337 | function definition.<br> |
---|
338 | </li> |
---|
339 | </ul> |
---|
340 | </li> |
---|
341 | </ul> |
---|
342 | <h3><a name="Directory_structure">Directory Structure</a> and Filenames</h3> |
---|
343 | <ul> |
---|
344 | <li> |
---|
345 | File and directory names must contain only <b>lowercase</b> ASCII letters , numbers, |
---|
346 | underscores, and a period. Leading character must be alphabetic. Maximum |
---|
347 | length 31. Only a single period is permitted. These requirements ensure |
---|
348 | file and directory names are relatively portable. |
---|
349 | <li> |
---|
350 | Files intended to be processed by a C++ compiler as part |
---|
351 | of a translation unit should have <b>a three-letter |
---|
352 | extension ending in "pp"</b>. Other files should |
---|
353 | <i>not</i> use extensions ending in "pp". This |
---|
354 | convention makes it easy to identify all of the C++ source |
---|
355 | in Boost.</li> |
---|
356 | <li> |
---|
357 | All libraries have at their highest level a primary directory named for the |
---|
358 | particular library. See <a href="#Naming­_consistency">Naming consistency</a>. |
---|
359 | The primary directory may have sub-directories. |
---|
360 | <li> |
---|
361 | For very simple libraries implemented entirely within the library header, all |
---|
362 | files go in the primary directory (except headers, which go in the boost header |
---|
363 | directory).</li> |
---|
364 | </ul> |
---|
365 | <blockquote> |
---|
366 | <p><b>Boost standard sub-directory names</b></p> |
---|
367 | <table border="1" cellpadding="5"> |
---|
368 | <tr> |
---|
369 | <td><b>Sub-directory</b></td> |
---|
370 | <td><b>Contents</b></td> |
---|
371 | <td><b>Required</b></td> |
---|
372 | </tr> |
---|
373 | <tr> |
---|
374 | <td><code>build</code></td> |
---|
375 | <td>Library build files such as a Jamfile.</td> |
---|
376 | <td>If any build files.</td> |
---|
377 | </tr> |
---|
378 | <tr> |
---|
379 | <td><code>doc</code></td> |
---|
380 | <td>Documentation (HTML) files.</td> |
---|
381 | <td>If several doc files.</td> |
---|
382 | </tr> |
---|
383 | <tr> |
---|
384 | <td><code>example</code></td> |
---|
385 | <td>Sample program files.</td> |
---|
386 | <td>If several sample files.</td> |
---|
387 | </tr> |
---|
388 | <tr> |
---|
389 | <td><code>src</code></td> |
---|
390 | <td>Source files which must be compiled to build the library. </td> |
---|
391 | <td>If any source files.</td> |
---|
392 | </tr> |
---|
393 | <tr> |
---|
394 | <td><code>test</code></td> |
---|
395 | <td>Regression or other test programs or scripts.</td> |
---|
396 | <td>If several test files.</td> |
---|
397 | </tr> |
---|
398 | </table> |
---|
399 | </blockquote> |
---|
400 | <h4><a name="Redirection">Redirection</a></h4> |
---|
401 | <p>The primary directory should always contain a file named index.html (or |
---|
402 | index.htm). Authors have requested this so that they can publish URL's in the |
---|
403 | form <i>http://www.boost.org/libs/lib-name</i> with the assurance a |
---|
404 | documentation reorganization won't invalidate the URL. Boost's internal tools |
---|
405 | are also simplified by knowing that a library's documentation is always |
---|
406 | reachable via the simplified URL.</p> |
---|
407 | <p>If the documentation is in a doc sub-directory, the primary directory |
---|
408 | index.html file should just do an automatic redirection to the doc |
---|
409 | subdirectory:</p> |
---|
410 | <blockquote> |
---|
411 | <pre><html> |
---|
412 | <head> |
---|
413 | <meta http-equiv="refresh" content="0; URL=doc/index.html"> |
---|
414 | </head> |
---|
415 | <body> |
---|
416 | Automatic redirection failed, please go to |
---|
417 | <a href="doc/index.html">doc/index.html</a> |
---|
418 | </body> |
---|
419 | </html></pre> |
---|
420 | </blockquote> |
---|
421 | <h3><a name="Naming­_consistency">Naming consistency</a></h3> |
---|
422 | <p>As library developers and users have gained experience with Boost, the |
---|
423 | following consistent naming approach has come to be viewed as very helpful, |
---|
424 | particularly for larger libraries that need their own header subdirectories |
---|
425 | and namespaces.</p> |
---|
426 | <p>Here is how it works. The library is given a name that describes the contents |
---|
427 | of the library. Cryptic abbreviations are strongly discouraged. Following the |
---|
428 | practice of the C++ Standard Library, names are usually singular rather than |
---|
429 | plural. For example, a library dealing with file systems might chose the |
---|
430 | name "filesystem", but not "filesystems", "fs" or "nicecode".</p> |
---|
431 | <ul> |
---|
432 | <li> |
---|
433 | The library's primary directory (in parent <i>boost-root/libs</i>) is given |
---|
434 | that same name. For example, <i>boost-root/libs/filesystem</i>.<br> |
---|
435 | |
---|
436 | <li> |
---|
437 | The library's primary header directory (in parent <i>boost-root/boost</i>) is |
---|
438 | given that same name. For example, <i>boost-root/boost/filesystem</i>.<br> |
---|
439 | |
---|
440 | <li> |
---|
441 | The library's primary namespace (in parent <i>::boost</i>) is given that same |
---|
442 | name, except when there's a component with that name (e.g., <i>boost::tuple</i>), in which case the namespace name is pluralized. For example, <i>::boost::filesystem</i>.</li> |
---|
443 | </ul> |
---|
444 | |
---|
445 | <p>When documenting Boost libraries, follow these conventions (see also the following section of this document): |
---|
446 | <ul> |
---|
447 | <li>The library name is set in roman type.</li> |
---|
448 | <li>The library name is capitalized.</li> |
---|
449 | <li>A period between "Boost" and the library name (e.g., Boost.Bind) is used if and only if the library name is not followed by the word "library".</li> |
---|
450 | <li>The word "library" is not part of the library name and is therefore lowercased.</li> |
---|
451 | </ul> |
---|
452 | <p>Here are a few examples of how to apply these conventions: |
---|
453 | <ul> |
---|
454 | <li>Boost.Bind was written by Peter Dimov.</li> |
---|
455 | <li>The Boost Bind library was written by Peter Dimov.</li> |
---|
456 | <li>I regularly use Bind, a Boost library written by Peter Dimov.</li> |
---|
457 | </ul> |
---|
458 | |
---|
459 | <h3><a name="Documentation">Documentation</a></h3> |
---|
460 | <p>Even the simplest library needs some documentation; the amount should be |
---|
461 | proportional to the need. The documentation should assume the readers |
---|
462 | have a basic knowledge of C++, but are not necessarily experts.</p> |
---|
463 | <p>The format for documentation should be HTML, and should not require an advanced |
---|
464 | browser or server-side extensions. Style sheets are acceptable. |
---|
465 | ECMAScript/JavaScript is not acceptable. The documentation entry point should |
---|
466 | always be a file named index.html or index.htm; see <a href="#Redirection">Redirection</a>.</p> |
---|
467 | <p>There is no single right way to do documentation. HTML documentation is often |
---|
468 | organized quite differently from traditional printed documents. Task-oriented |
---|
469 | styles differ from reference oriented styles. In the end, it comes down to the |
---|
470 | question: Is the documentation sufficient for the mythical "average" C++ |
---|
471 | programmer to use the library successfully?</p> |
---|
472 | <p>Appropriate topics for documentation often include: |
---|
473 | <ul> |
---|
474 | <li> |
---|
475 | General introduction to the library. |
---|
476 | <li> |
---|
477 | Description of each class. |
---|
478 | <li> |
---|
479 | Relationship between classes. |
---|
480 | <li> |
---|
481 | For each function, as applicable, description, requirements (preconditions), |
---|
482 | effects, post-conditions, returns, and throws. |
---|
483 | <li> |
---|
484 | Discussion of error detection and recovery strategy. |
---|
485 | <li> |
---|
486 | How to use including description of typical uses. |
---|
487 | <li> |
---|
488 | How to compile and link. |
---|
489 | <li> |
---|
490 | How to test. |
---|
491 | <li> |
---|
492 | Version or revision history. |
---|
493 | <li> |
---|
494 | Rationale for design decisions. See <a href="#Rationale">Rationale rationale</a>. |
---|
495 | <li> |
---|
496 | Acknowledgements. See <a href="#Acknowledgements">Acknowledgments rationale.</a></li> |
---|
497 | </ul> |
---|
498 | <p>If you need more help with how to write documentation you can check out the |
---|
499 | article on <a href="writingdoc/index.html">Writing Documentation for Boost</a>.</p> |
---|
500 | <h2><a name="Rationale">Rationale</a></h2> |
---|
501 | <p>Rationale for some of the requirements and guidelines follows.</p> |
---|
502 | <hr> |
---|
503 | <h3><a name="Exception-specification">Exception-specification</a> rationale</h3> |
---|
504 | <p>Exception specifications [ISO 15.4] are sometimes coded to indicate what |
---|
505 | exceptions may be thrown, or because the programmer hopes they will improved |
---|
506 | performance. But consider the following member from a smart pointer:</p> |
---|
507 | <pre> T& operator*() const throw() { return *ptr; }</pre> |
---|
508 | <p>This function calls no other functions; it only manipulates fundamental data |
---|
509 | types like pointers Therefore, no runtime behavior of the |
---|
510 | exception-specification can ever be invoked. The function is completely |
---|
511 | exposed to the compiler; indeed it is declared inline Therefore, a smart |
---|
512 | compiler can easily deduce that the functions are incapable of throwing |
---|
513 | exceptions, and make the same optimizations it would have made based on the |
---|
514 | empty exception-specification. A "dumb" compiler, however, may make all kinds |
---|
515 | of pessimizations.</p> |
---|
516 | <p>For example, some compilers turn off inlining if there is an |
---|
517 | exception-specification. Some compilers add try/catch blocks. Such |
---|
518 | pessimizations can be a performance disaster which makes the code unusable in |
---|
519 | practical applications.</p> |
---|
520 | <p>Although initially appealing, an exception-specification tends to have |
---|
521 | consequences that require <b>very</b> careful thought to understand. The |
---|
522 | biggest problem with exception-specifications is that programmers use them as |
---|
523 | though they have the effect the programmer would like, instead of the effect |
---|
524 | they actually have.</p> |
---|
525 | <p>A non-inline function is the one place a "throws nothing" |
---|
526 | exception-specification may have some benefit with some compilers.</p> |
---|
527 | <hr> |
---|
528 | <h3><a name="Naming">Naming</a> conventions rationale</h3> |
---|
529 | <p>The C++ standard committee's Library Working Group discussed this issue in |
---|
530 | detail, and over a long period of time. The discussion was repeated again in |
---|
531 | early boost postings. A short summary:</p> |
---|
532 | <ul> |
---|
533 | <li> |
---|
534 | Naming conventions are contentious, and although several are widely used, no |
---|
535 | one style predominates. |
---|
536 | <li> |
---|
537 | Given the intent to propose portions of boost for the next revision of the C++ |
---|
538 | standard library, boost decided to follow the standard library's conventions. |
---|
539 | <li> |
---|
540 | Once a library settles on a particular convention, a vast majority of |
---|
541 | stakeholders want that style to be consistently used. |
---|
542 | </li> |
---|
543 | </ul> |
---|
544 | <hr> |
---|
545 | <h3>Source <a name="code_fonts">code fonts</a> rationale</h3> |
---|
546 | <p>Dave Abrahams comments: An important purpose (I daresay the primary purpose) of |
---|
547 | source code is communication: the documentation of intent. This is a doubly |
---|
548 | important goal for boost, I think. Using a fixed-width font allows us to |
---|
549 | communicate with more people, in more ways (diagrams are possible) right there |
---|
550 | in the source. Code written for fixed-width fonts using spaces will read |
---|
551 | reasonably well when viewed with a variable-width font, and as far as I can |
---|
552 | tell every editor supporting variable-width fonts also supports fixed width. I |
---|
553 | don't think the converse is true.</p> |
---|
554 | <hr> |
---|
555 | <h3><a name="Tabs">Tabs</a> rationale</h3> |
---|
556 | <p>Tabs are banned because of the practical problems caused by tabs in |
---|
557 | multi-developer projects like Boost, rather than any dislike in principle. See <a href="mailing_lists.htm#archive"> |
---|
558 | mailing list archives</a>. Problems include maintenance of a single source |
---|
559 | file by programmers using tabs and programmers using spaces, and the difficulty |
---|
560 | of enforcing a consistent tab policy other than just "no tabs". Discussions |
---|
561 | concluded that Boost files should either all use tabs, or all use spaces, and |
---|
562 | thus the decision to stick with spaces.</p> |
---|
563 | <hr> |
---|
564 | <h3>ECMAScript/<a name="JavaScript">JavaScript</a> rationale</h3> |
---|
565 | <p>Before the 1.29.0 release, two Boost libraries added ECMAScript/JavaScript |
---|
566 | documentation. Controversy followed (see <a href="mailing_lists.htm#archive">mailing |
---|
567 | list archives</a>), and the developers were asked to remove the |
---|
568 | ECMAScript/JavaScript. Reasons given for banning included:</p> |
---|
569 | <ul> |
---|
570 | <li> |
---|
571 | Incompatible with some older browsers and some text based browsers. |
---|
572 | <li> |
---|
573 | Makes printing docs pages difficult. |
---|
574 | <li> |
---|
575 | Often results in really bad user interface design. |
---|
576 | <li> |
---|
577 | "It's just annoying in general." |
---|
578 | <li> |
---|
579 | Would require Boost to test web pages for ECMAScript/JavaScript compliance. |
---|
580 | <li> |
---|
581 | Makes docs maintenance by other than the original developer more difficult.</li> |
---|
582 | </ul> |
---|
583 | <hr> |
---|
584 | <h3><a name="Rationale_rationale">Rationale rationale</a></h3> |
---|
585 | <p>Rationale is defined as "The fundamental reasons for something; basis" by the |
---|
586 | American Heritage Dictionary.</p> |
---|
587 | <p>Beman Dawes comments: Failure to supply contemporaneous rationale for |
---|
588 | design decisions is a major defect in many software projects. Lack of accurate |
---|
589 | rationale causes issues to be revisited endlessly, causes maintenance bugs when |
---|
590 | a maintainer changes something without realizing it was done a certain way for |
---|
591 | some purpose, and shortens the useful lifetime of software.</p> |
---|
592 | <p>Rationale is fairly easy to provide at the time decisions are made, but very |
---|
593 | hard to accurately recover even a short time later.</p> |
---|
594 | <hr> |
---|
595 | <h3><a name="Acknowledgements">Acknowledgements</a> rationale</h3> |
---|
596 | <p>As a library matures, it almost always accumulates improvements suggested to |
---|
597 | the authors by other boost members. It is a part of the culture of |
---|
598 | boost.org to acknowledge such contributions, identifying the person making the |
---|
599 | suggestion. Major contributions are usually acknowledged in the |
---|
600 | documentation, while minor fixes are often mentioned in comments within the |
---|
601 | code itself.</p> |
---|
602 | <hr> |
---|
603 | <p>Revised |
---|
604 | <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan --> |
---|
605 | 04 November, 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p> |
---|
606 | <p> |
---|
607 | © <a name="Copyright">Copyright</a> Beman Dawes 2003.</p> |
---|
608 | <p> Distributed under the Boost Software License, Version 1.0. |
---|
609 | (See accompanying file <a href="../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or |
---|
610 | copy at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>) |
---|
611 | </p> |
---|
612 | </body> |
---|
613 | </html> |
---|