Changes between Initial Version and Version 1 of Guidelines/Reuse


Ignore:
Timestamp:
Feb 14, 2010, 12:06:54 PM (13 years ago)
Author:
Daniel James
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Guidelines/Reuse

    v1 v1  
     1[[PageOutline]]
     2
     3= Boost Library reuse: cost versus benefit trade-offs = #intro
     4
     5A Boost library '''should not''' use libraries
     6other than Boost or the C++ Standard Library.
     7
     8A Boost library '''should''' use other Boost
     9Libraries or the C++ Standard Library, but only when the
     10benefits outweigh the costs.
     11
     12The benefits of using components from other libraries may
     13include clearer, more understandable code, reduced development
     14and maintenance costs, and the assurance which comes from
     15reusing well-known and trusted building blocks.
     16
     17The costs may include undesirable coupling between
     18components, and added compilation and runtime costs. If the
     19interface to the additional component is complex, using it may
     20make code less readable, and thus actually increase development
     21and maintenance costs.
     22
     23Negative effects of coupling become obvious when one library
     24uses a second library which uses a third, and so on. The worst
     25form of coupling requires the user understand each of the
     26coupled libraries. Coupling may also reduce the portability of
     27a library - even in case when all used libraries are
     28self-sufficient (see example of questionable usage of
     29<iostream> library below).
     30
     31'''Example where another boost component should
     32certainly be used:''' boost::noncopyable (in
     33[http://www.boost.org/doc/libs/release/boost/utility.hpp boost/utility.hpp])
     34has considerable benefits; it simplifies code, improves
     35readability, and signals intent. Costs are low as coupling is
     36limited; noncopyable itself uses no other classes and its
     37header includes only the lightweight headers
     38<boost/config.hpp> and <cstddef>. There are no
     39runtime costs at all. With costs so low and benefits so high,
     40other boost libraries should use boost::noncopyable when the
     41need arises except in exceptional circumstances.
     42
     43'''Example where a standard library component might
     44possibly be used:''' Providing diagnostic output as a
     45debugging aid can be a nice feature for a library. Yet using
     46Standard Library <iostream> can involves a lot of
     47additional cost, particularly if <iostream> is unlikely
     48to be use elsewhere in the application. In certain GUI or
     49embedded applications, coupling to <iostream> would be a
     50disqualification. Consider redesign of the boost library in
     51question so that the user supplies the diagnostic output
     52mechanism.
     53
     54'''Example where another boost component should not be
     55used:''' The boost dir_it library has considerable
     56coupling and runtime costs, not to mention portability issues
     57for unsupported operating systems. While completely appropriate
     58when directory iteration is required, it would not be
     59reasonable for another boost library to use dir_it just to
     60check that a file is available before opening. C++ Standard
     61Library file open functionality does this at lower cost. Don't
     62use dir_it just for the sake of using a boost library.