Changes between Version 15 and Version 16 of BestPracticeHandbook


Ignore:
Timestamp:
May 7, 2015, 6:36:17 PM (7 years ago)
Author:
Niall Douglas
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BestPracticeHandbook

    v15 v16  
    101101// In other words you can declare your code in boost::afio::v1, and use it as if declared in boost::afio.
    102102
    103 // The other important new C++ 11 feature is namespace aliasing, so
     103// The other important C++ feature here is namespace aliasing, so
    104104namespace local { namespace afio = boost::afio; /* use afio::* and it all works */ }
    105105}}}
     
    195195Some fun extra things this technique enables:
    196196
    197 1. Something not so obvious above is that you can also ''stub out'' fake copies of dependencies where that dependency is missing in the current config. For example, imagine optional compression support where your config.hpp either namespace aliases to boost::foo::compression either a real compression library, or an internal stub copy which actually does nothing. Your code is then written to assume a compression library aliased at boost::foo::compression and need not consider if it's actually there or not. The advantages here for reducing coupling are very obvious.
     1971. Something not so obvious above is that you can also ''stub out'' fake copies of dependencies where that dependency is missing in the current config. For example, imagine optional compression support where your config.hpp either namespace aliases to boost::foo::compression either a real compression library, or an internal stub copy which actually does nothing. Your code is then written to assume a compression library aliased at boost::foo::compression and need not consider if it's actually there or not. The advantages here for reducing coupling are very obvious. This is covered in a separate recommendation below.
    1981982. This technique is highly extensible to allow ''dependency injection'' of STL11 vs Boost on a per-feature basis e.g. your user wants Boost.Thread instead of STL11 thread but only for threading, so your library can be so modular as to allow both options to end users. This is covered in a separate recommendation below.
    199199