Changes between Version 2 and Version 3 of BestPracticeHandbook


Ignore:
Timestamp:
May 4, 2015, 11:17:31 AM (7 years ago)
Author:
Niall Douglas
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BestPracticeHandbook

    v2 v3  
    1 = Links To Examples Of Best Practice For C++ 11/14 Boost Libraries =
     1= Links To Examples Of Best Practice For C++ 11/14 Libraries =
    22
    33''originally written by [http://www.nedprod.com/ Niall Douglas] May 2015''
    44
    5 As part of preparing my [http://cppnow.org/ C++ Now] 2015 presentation "[https://docs.google.com/presentation/d/1badtN7A4lMzDl5i098SHKvlWsQY-tsVcutpq_UlRmFI/pub?start=false&loop=false&delayms=3000 A review of C++ 11/14 only Boost libraries]" I examined ten C++ 11/14 mandatory libraries heading towards Boost. This wiki provides a shortlist of suggested best practices which Boost library authors may find useful when developing their own Boost libraries. To a large extent, this shortlist is mainly about achieving best practice in C++ 11/14 libraries of any kind and should be useful to anyone so interested.
     5As part of preparing my [http://cppnow.org/ C++ Now] 2015 presentation "[https://docs.google.com/presentation/d/1badtN7A4lMzDl5i098SHKvlWsQY-tsVcutpq_UlRmFI/pub?start=false&loop=false&delayms=3000 A review of C++ 11/14 only Boost libraries]" I examined ten C++ 11/14 mandatory libraries heading towards Boost which were:
     6
     7||= Name          =||= Authors                                 =||= Min C++ =||= Boost headers required =||= Entered Boost peer review queue =||= Description =||= Repository =||
     8|| Boost.Fiber     || Oliver Kowalke                            ||  14       ||  Context, Config         ||  Conditionally accepted     || a framework for micro-/userland-threads (fibers) scheduled cooperatively || https://github.com/olk/boost-fiber ||
     9|| Boost.AFIO      || Niall Douglas, Paul Kirth                 ||  11       ||  none                    ||  2013-10                    || strongly ordered portable asynchronous filesystem and file i/o extending ASIO || https://github.com/BoostGSoC13/boost.afio ||
     10|| Boost.DI        || Krzysztof Jusiak                          ||  14       ||  none                    ||  2015-01                    || provides compile time, macro free constructor dependency injection || https://github.com/krzysztof-jusiak/di ||
     11|| Boost.Hana      || Louis Dionne                              ||  14       ||  none                    ||  2015-04                    || functional programming in C++ based around transformations of heterogeneous collections of types. || https://github.com/ldionne/hana ||
     12|| Boost.Http      || Vinícius dos Santos Oliveira              ||  11       ||  asio, filesystem, system, datetime, utility ||  2015-04  || create applications that need to expose services through HTTP || https://github.com/BoostGSoC14/boost.http ||
     13|| Boost.APIBind   || Niall Douglas                             ||  11       ||  none                    ||  not submitted yet          || toolkit for modularizing Boost libraries, managing versioned API and ABI dependency binds, makes it easy for Boost libraries to switch between use of the C++ 11 STL and the Boost STL || https://github.com/ned14/Boost.BindLib ||
     14|| Boost.Expected  || Pierre Talbot, Vicente J. Botet Escriba   ||  11       ||  none                    ||  not submitted yet          || category and functional programming in C++ based around the monadic expected<T, E> || https://github.com/ptal/expected ||
     15|| Boost.Tick      || Paul Fultz II                             ||  11       ||  none                    ||  not submitted yet          || trait introspection and concept creator for C++11 || https://github.com/pfultz2/Tick ||
     16|| Boost.Fit       || Paul Fultz II                             ||  11       ||  none                    ||  not submitted yet          || provides utilities for functions and function objects || https://github.com/pfultz2/Fit ||
     17|| Boost.Sqlpp11   || Roland Bock                               ||  11       ||  none                    ||  not submitted yet          || A type safe embedded domain specific language for SQL queries and results in C++ || https://github.com/rbock/sqlpp11 ||
     18
     19There was very significant divergence in best practices between these libraries at the time of examination, and moreover the divergences were uneven possibly reflecting an uneven understanding of what best practice might be in C++ 11/14. Thence from my examination I have prepared the list below of what I felt were best practices in C++ 11/14 mandatory libraries with hyperlinks to the relevant source code files in the relevant libraries above. As what a "best practice" is or is not may vary according to opinion, I have attempted to provide a rationale for each of the suggestions below. It is up to library authors to weigh each suggestion and to decide whether to apply it, or not, to their library.
     20
     21One will note that the list below is much more C++ 11/14 focused than Boost focused. This is because it is derived from the first crop of C++ 11/14 mandatory Boost libraries. This is not a handbook for writing Boost libraries or even C++ 11/14 Boost libraries, if you want that [http://www.boost.org/development/requirements.html first start reading here] (note some of the guidelines on that page don't really apply to C++ 11/14 libraries) and [http://rrsd.com/blincubator.com/requirements/ then read here] and [http://rrsd.com/blincubator.com/advice/ here].
     22
     23I have tried to keep these points generic to all C++ 11/14 libraries in the hope that they are useful far outside Boost. I have also ordered them with what I consider the most important ("strongly consider") first and not as important ("consider") later.
    624
    725[[PageOutline]]
     
    1129All the Boost libraries are on github, and all the free tooling exampled below integrates easily with github. Choosing github makes your life much easier. Note that as git is a distributed source code control system, you can keep a canonical master copy anywhere and write a script which autorefreshes the github copy, thus triggering any of the free tooling you have integrated there.
    1230
    13 Github also provides free website hosting for HTML. Have a script automatically generate documentation and commit it to the gh-pages branch in your normal repo. This should present a copy of your HTML at http://''username''.github.io/''repository''.
     31Github also provides free website hosting for HTML. Have a script automatically generate documentation and commit it to the gh-pages branch in your normal repo. This should present a copy of your HTML at !http:// ''username''.github.io/''repository''.
    1432
    1533This is the script which generates the documentation for [http://boostgsoc13.github.io/boost.afio/ proposed Boost.AFIO], and indeed you can see the exact output generated by this script at http://boostgsoc13.github.io/boost.afio/. You may find it useful.
     
    6684
    6785
    68 == 2. Consider making it possible to use Boost.Test for the unit testing, even if not enabled by default ==
     86== 2. Consider making it possible to use an XML outputting unit testing framework, even if not enabled by default ==
    6987
    7088A very noticeable trend in C++ 11/14 mandatory Boost libraries is that less than half are able to use Boost.Test, and use alternative unit testing systems.
     
    7391
    7492TODO IN PROGRESS
     93
     94== 3. Consider trying your library on Microsoft Visual Studio 2015 ==
     95
     96== 4. Consider versioning your library's namespace ==
     97
     98== 5. Consider not doing compiler feature detection yourself ==