creational patterns

Started by
10 comments, last by nobodynews 16 years, 2 months ago
Quote:Original post by nobodynews
I'm reading through Modern C++ Design, by Alexandrescu and it does contain a lot of interesting information. Though he probably could have left out the singleton stuff.


Agreed. I'm reading through that chapter now. I'm glad to have read it, but I'm still not convinced that the singleton pattern is any more useful than I previously thought. Then again, the book is a few years old now, and most everyone was more accepting of the pattern back then.

The worse part, IMO is that he made the small-object allocator from chapter 4 a singleton, and I don't believe that it necessarily requires it or that its even a good idea. The downsides are *slightly* lessened by the fact that the template parameterization creates different small-object allocator singletons for different policies -- eg, a small-object allocator<SingleThreaded> is a different object than a small-object allocator<MultiThreaded> -- but this is still unnecessarily restrictive. For example, what if one wants to have multiple multi-threaded allocators assigned to independently-threaded portions of the application? You can get around this by having, for example, MultiThreadedAI and MultiThreadedGUI policies, but they're probably just duplicates with different names, which doesn't strike me as a better solution than the alternative of simply having the small-object allocator as an object, rather than a singleton.

throw table_exception("(? ???)? ? ???");

Advertisement
Quote:Original post by Dragon_Strike
Quote:Original post by Sneftel
Abstract factory: An object with a lot of factories in it. This is a boring pattern.


why is it a boring pattern?


Heh. Just finished that chapter this morning in my book. One of the shorter chapters.

C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!

This topic is closed to new replies.

Advertisement