rationale.qbk 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. [/
  2. Boost.Config
  3. Copyright (c) 2001 Beman Dawes
  4. Copyright (c) 2001 Vesa Karvonen
  5. Copyright (c) 2001 John Maddock
  6. Distributed under the Boost Software License, Version 1.0.
  7. (See accompanying file LICENSE_1_0.txt or copy at
  8. http://www.boost.org/LICENSE_1_0.txt)
  9. ]
  10. [section Rationale]
  11. The problem with many traditional "textbook" implementations of configuration
  12. headers (where all the configuration options are in a single "monolithic"
  13. header) is that they violate certain fundamental software engineering
  14. principles which would have the effect of making boost more fragile, more
  15. difficult to maintain and more difficult to use safely. You can find a
  16. description of the principles from the __PRINCIPLES_AND_PATTERNS_ARTICLE__.
  17. [section The problem]
  18. Consider a situation in which you are concurrently developing on multiple
  19. platforms. Then consider adding a new platform or changing the platform
  20. definitions of an existing platform. What happens? Everything, and this does
  21. literally mean everything, recompiles. Isn't it quite absurd that adding a
  22. new platform, which has absolutely nothing to do with previously existing
  23. platforms, means that all code on all existing platforms needs to be
  24. recompiled?
  25. Effectively, there is an imposed physical dependency between platforms that
  26. have nothing to do with each other. Essentially, the traditional solution
  27. employed by configuration headers does not conform to the Open-Closed
  28. Principle:
  29. [: [*"A module should be open for extension but closed for modification."]]
  30. Extending a traditional configuration header implies modifying existing code.
  31. Furthermore, consider the complexity and fragility of the platform detection
  32. code. What if a simple change breaks the detection on some minor platform?
  33. What if someone accidentally or on purpose (as a workaround for some other
  34. problem) defines some platform dependent macros that are used by the
  35. detection code? A traditional configuration header is one of the most
  36. volatile headers of the entire library, and more stable elements of
  37. Boost would depend on it. This violates the Stable Dependencies Principle:
  38. [: [*"Depend in the direction of stability."]]
  39. After even a minor change to a traditional configuration header on one minor
  40. platform, almost everything on every platform should be tested if we follow
  41. sound software engineering practice.
  42. Another important issue is that it is not always possible to submit changes
  43. to `<boost/config.hpp>`. Some boost users are currently working on platforms
  44. using tools and libraries that are under strict Non-Disclosure Agreements.
  45. In this situation it is impossible to submit changes to a traditional
  46. monolithic configuration header, instead some method by which the user
  47. can insert their own configuration code must be provided.
  48. [endsect]
  49. [section The solution]
  50. The approach taken by boost's configuration headers is to separate
  51. configuration into three orthogonal parts: the compiler, the standard
  52. library and the platform. Each compiler/standard library/platform gets
  53. its own mini-configuration header, so that changes to one compiler's
  54. configuration (for example) does not affect other compilers. In addition
  55. there are measures that can be taken both to omit the compiler/standard
  56. library/platform detection code (so that adding support to a new platform
  57. does not break dependencies), or to freeze the configuration completely;
  58. providing almost complete protection against dependency changes.
  59. [endsect]
  60. [endsect]