Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/more/library_reuse.htm @ 63

Last change on this file since 63 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

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