According to "modern c++ design", "effective c++", boost and loki.
I believe that policy based design is very powerful(not mentioning about TMP yet).

The idea of policy is pretty straight forward and easy, you don't need to be
a template wizard or know TMP very well before you could use it(you don't need to
know it at all if I have no make a mistake). Yet it is not so common it the world of
C++, except of boost and haiku test unit(AFAIK).

The idea of policy based class design is very attractive, yet it is not so popular
in the real world. Whatever, every design patterns or techniques have it own
strengths and weaknesses. Policy based design do have defects, like how to make the
policies become orthogonal, how to reduce the number of the policies and so on. But
what is the major defect of policy based design which make this attractive idea
not so popular?

Is it because policy based design not a good option for large scale project?Thanks
a lot.

Edited 5 Years Ago by stereomatching: n/a

> The idea of policy based class design is very attractive,
> yet it is not so popular in the real world.

I think it is widely used in the real world; the idea of separating policy from infrastructure is fairly old. Goes under several names - strategy pattern, policy parameterization and so on.

Some real life examples would be:

  • locales (which contain facets) composed with iostreams.
  • allocators providing memory management policy for containers.
  • character traits providing policy for std::basic_string<>
  • the desktop environment providing ui policy and the X-server providing infrastructure.
  • lsass.exe providing the security policy and the NT kernel providing the infrastructure.

Thanks a lot, I am glad that this is a well known technique
Maybe in Taiwan strategy pattern would be much more familiar for us
So the policy based designed proposed by modern c++ design already
being used at large scale programming.

This article has been dead for over six months. Start a new discussion instead.