Changes between Initial Version and Version 1 of Guidelines/Requirements


Ignore:
Timestamp:
Feb 14, 2010, 11:37:10 AM (13 years ago)
Author:
Daniel James
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Guidelines/Requirements

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