rationale.qbk

来自「Boost provides free peer-reviewed portab」· QBK 代码 · 共 81 行

QBK
81
字号
[/    Boost.Config    Copyright (c) 2001 Beman Dawes    Copyright (c) 2001 Vesa Karvonen    Copyright (c) 2001 John Maddock    Distributed under the Boost Software License, Version 1.0.    (See accompanying file LICENSE_1_0.txt or copy at    http://www.boost.org/LICENSE_1_0.txt)][section Rationale]The problem with many traditional "textbook" implementations of configurationheaders (where all the configuration options are in a single "monolithic"header) is that they violate certain fundamental software engineeringprinciples which would have the effect of making boost more fragile, moredifficult to maintain and more difficult to use safely. You can find adescription of the principles from the __PRINCIPLES_AND_PATTERNS_ARTICLE__.[section The problem]Consider a situation in which you are concurrently developing on multipleplatforms. Then consider adding a new platform or changing the platformdefinitions of an existing platform. What happens? Everything, and this doesliterally mean everything, recompiles. Isn't it quite absurd that adding anew platform, which has absolutely nothing to do with previously existingplatforms, means that all code on all existing platforms needs to berecompiled?Effectively, there is an imposed physical dependency between platforms thathave nothing to do with each other. Essentially, the traditional solutionemployed by configuration headers does not conform to the Open-ClosedPrinciple:[: [*"A module should be open for extension but closed for modification."]]Extending a traditional configuration header implies modifying existing code.Furthermore, consider the complexity and fragility of the platform detectioncode. What if a simple change breaks the detection on some minor platform?What if someone accidentally or on purpose (as a workaround for some otherproblem) defines some platform dependent macros that are used by thedetection code? A traditional configuration header is one of the mostvolatile headers of the entire library, and more stable elements ofBoost would depend on it. This violates the Stable Dependencies Principle:[: [*"Depend in the direction of stability."]]After even a minor change to a traditional configuration header on one minorplatform, almost everything on every platform should be tested if we followsound software engineering practice.Another important issue is that it is not always possible to submit changesto `<boost/config.hpp>`. Some boost users are currently working on platformsusing tools and libraries that are under strict Non-Disclosure Agreements.In this situation it is impossible to submit changes to a traditionalmonolithic configuration header, instead some method by which the usercan insert their own configuration code must be provided.[endsect][section The solution]The approach taken by boost's configuration headers is to separateconfiguration into three orthogonal parts: the compiler, the standardlibrary and the platform. Each compiler/standard library/platform getsits own mini-configuration header, so that changes to one compiler'sconfiguration (for example) does not affect other compilers. In additionthere are measures that can be taken both to omit the compiler/standardlibrary/platform detection code (so that adding support to a new platformdoes not break dependencies), or to freeze the configuration completely;providing almost complete protection against dependency changes.[endsect][endsect]

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?