Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/more/library_reuse.htm @ 14

Last change on this file since 14 was 12, checked in by landauf, 17 years ago

added boost

File size: 4.4 KB
Line 
1<html>
2
3<head>
4<meta http-equiv="Content-Language" content="en-us">
5<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
6<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
7<meta name="ProgId" content="FrontPage.Editor.Document">
8<title>Boost Library Reuse</title>
9</head>
10
11<body bgcolor="#FFFFFF" text="#000000">
12
13<table border="1" bgcolor="#007F7F" cellpadding="2">
14  <tr>
15    <td bgcolor="#FFFFFF"><img src="../boost.png" alt="boost.png (6897 bytes)" width="277" height="86"></td>
16    <td><a href="../index.htm"><font face="Arial" color="#FFFFFF"><big>Home</big></font></a></td>
17    <td><a href="../libs/libraries.htm"><font face="Arial" color="#FFFFFF"><big>Libraries</big></font></a></td>
18    <td><a href="../people/people.htm"><font face="Arial" color="#FFFFFF"><big>People</big></font></a></td>
19    <td><a href="faq.htm"><font face="Arial" color="#FFFFFF"><big>FAQ</big></font></a></td>
20    <td><a href="index.htm"><font face="Arial" color="#FFFFFF"><big>More</big></font></a></td>
21  </tr>
22</table>
23&nbsp;
24<h1>Boost Library reuse: cost versus benefit trade-offs</h1>
25<p>A Boost library <b>should not</b> use libraries other than Boost or the C++
26Standard Library.</p>
27<p>A Boost library <b>should</b> use other Boost Libraries or the C++ Standard
28Library, but only when the benefits outweigh the costs.&nbsp;</p>
29<p>The benefits of using components from other libraries may include clearer,
30more understandable code, reduced development and maintenance costs, and the
31assurance which comes from reusing well-known and trusted building blocks.</p>
32<p>The costs may include undesirable coupling between components, and added
33compilation and runtime costs.&nbsp; If the interface to the additional
34component is complex, using it may make code less readable, and thus actually
35increase development and maintenance costs.</p>
36<p>Negative effects of coupling become obvious when one library uses a second
37library which uses a third, and so on. The worst form of coupling requires the
38user understand each of the coupled libraries. Coupling may also reduce the
39portability of a library - even in case when all used libraries are
40self-sufficient (see example of questionable usage of &lt;iostream&gt; library
41below).</p>
42<p><b>Example where another boost component should certainly be used:</b>&nbsp;
43boost::noncopyable (in <a href="../boost/utility.hpp">boost/utility.hpp</a>) has
44considerable benefits; it simplifies code, improves readability, and signals
45intent.&nbsp; Costs are low as coupling is limited;&nbsp; noncopyable itself
46uses no other classes and its header includes only the lightweight headers
47&lt;boost/config.hpp&gt; and &lt;cstddef&gt;.&nbsp; There are no runtime costs
48at all. With costs so low and benefits so high, other boost libraries should use
49boost::noncopyable when the need arises except in exceptional circumstances.</p>
50<p><b>Example where a standard library component might possibly be used:</b>
51Providing diagnostic output as a debugging aid can be a nice feature for a
52library. Yet using Standard Library &lt;iostream&gt; can involves a lot of
53additional cost, particularly if &lt;iostream&gt; is unlikely to be use
54elsewhere in the application.&nbsp; In certain GUI or embedded applications,
55coupling to &lt;iostream&gt; would be a disqualification.&nbsp;&nbsp;&nbsp;
56Consider redesign of the boost library in question so that the user supplies the
57diagnostic output mechanism.</p>
58<p><b>Example where another boost component should not be used:</b>&nbsp; The
59boost dir_it library has considerable coupling and runtime costs, not to mention
60portability issues for unsupported operating systems.&nbsp; While completely
61appropriate when directory iteration is required, it would not be reasonable for
62another boost library to use dir_it just to check that a file is available
63before opening.&nbsp; C++ Standard Library file open functionality does this at
64lower cost.&nbsp; Don't use dir_it just for the sake of using a boost library.</p>
65<hr>
66<p>Revised <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B %Y" startspan -->02 October 2003<!--webbot bot="Timestamp" endspan i-checksum="32277" --></p>
67<p>© Copyright Beman Dawes 2000</p>
68<p> Use, modification, and distribution are subject to the Boost Software
69License, Version 1.0. (See accompanying file <a href="../LICENSE_1_0.txt">
70LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
71www.boost.org/LICENSE_1_0.txt</a>)</p>
72
73</body>
74
75</html>
Note: See TracBrowser for help on using the repository browser.