Modern C++ Design: Applied Generic and Design Patterns (C++ in Depth)

Modern C++ Design: Applied Generic and Design Patterns (C++ in Depth) by Andrei Alexandrescu, John Vlissides and Scott Meyers

Modern C++ Design: Applied Generic and Design Patterns (C++ in Depth)

Binding:
Paperback
Number of Pages:
352
ISBN:
0201704315
Product Group:
book
Publisher:
Addison Wesley
Publication Date:
Feb. 22, 2001
BooksForGeeks.com ID:
2889

Demonstrates 'generic patterns' or 'pattern templates' as a way of creating extensible designs in C++. This book introduces the concept of generic components-reusable design templates that produce boilerplate code for compiler consumption, within C++.

Reviews for Modern C++ Design: Applied Generic and Design Patterns (C++ in Depth)

  1. Mind blowing

    Rated 5 out of 5 stars, February 12th, 2010

    I crawled through this book, but enjoyed every bit. The code presented here is cunning beyond belief.

    This is a must-have for any serious c++ developer.
  2. Clever, but of very limited utility.

    Rated 1 out of 5 stars, January 12th, 2010

    Modern C++ Design builds on some of the ideas presented in the classic Design Patterns book, and attempts to improve them specifically for C++. The examples fail to make a case for preferring Alexandrescu's patterns over the originals or other alternatives - while they are a clever use (some would say misuse) of templates, they result in unreadable, unmaintainable code. It's therefore quite disconcerting to see this book receive a number of glowing, uncritical reviews. Loki (the library that is described in the book), has not become a common tool for C++ programmers in the years since 2001 when one of the reviews on this page predicted it would. Instead, C++ programmers, compiler writers and standards committees have struggled to make templates usable for anything more than "containers of x". Perhaps that's where the experimentation should have ended, and we may have got an elegant library rather than the half baked Standard Template Library we have now.
  3. A great way to discover and understand advanced programming techniques

    Rated 5 out of 5 stars, March 12th, 2008

    An excellent book and a IMHO a MUST if you want to get a professional C++ (and not only) developer.
    It covers lots of practical topics, unveiling advanced techniques and "hidden" features of the C++ programming language.

    I would suggest to get a good knowledge of C++ first (e.g. read Stroustrup's TCPL bible) or you won't grasp most of the topics.

    I must admit that reading the book I was all "Wow! You can do that?!?".
    Sure, not a big deal if you are already a pro, but you won't be reading this review, I suppose.

    I would suggest this book even if you intend to move to another language as it really helped me thinking about things and understanding many language features and hardcore techniques.
  4. template metaphysics

    Rated 4 out of 5 stars, March 12nd, 2007

    This is 300 pages of the hardest of hardcore template metaprogramming you could currently hope to read. As a result, there is a risk you may find more to admire and speculate upon from afar, than to actually use. Various factors will decide this, from the robustness of your compiler, your comfort with far-out template wackiness, and your confidence in debugging and maintaining the result.

    One thing is not in doubt: C++ metaprogramming is devilishly clever. That's part of its appeal. It's also capable of producing flexible, efficient families of software. Modern C++ Design pushes the boundaries of TMP further than the more specialised matrix domain detailed in Czarnecki and Eisenecker's Generative Programming (a recommended prologue to this book). Here, the aim is implementing entire design patterns. This is a fairly bold claim, as the received wisdom on design patterns is that there isn't a canonical form that can be presented in code.

    And that still holds true. Instead, the code in Modern C++ Design is metacode built on two big ideas: policies and typelists, which are described in the opening chapters, along with some other useful tools. The hard intellectual work is done here, especially the typelist chapter, although previous exposure to the likes of Generative Programming definitely softens the blow. Policies are what Java programmers know as Dependency Injection, except one level of abstraction up (the relationship between classes and objects in DI is done with templates and classes with policies), and with the template instantiation and specialisation rules of C++ providing an extra layer of flexibility. Typelists are exactly as the name suggests - a list of types, but they exist only at compile time. They're fed to the TMP machinery, which spits out a class hierarchy based on the supplied list.

    With these tools in place, Andrei Alexandrescu then proceeds to show how they can be used to work some magic. Template versions of the command, visitor, abstract factory and factory method patterns are presented, along with other abstractions like smart pointers (perhaps the most orthodox chapter of the book), tuples, and multiple dispatch.

    The latter topic provides a connection to James Coplien's Advanced C++, which also discussed multimethods, albeit before templates entered the language. The books share a certain similarity, not so much in content, but in the spirit of stretching the boundaries of C++, and perhaps also in stretching its readability and maintainability.

    For all the virtuosity on display here (and in Coplien's book), I'm not sure if I'd to use these techniques in my own C++. This may just be down to my own mediocrity as a programmer, but TMP is more than just an idiomatic application of C++, it's really an entirely new language and not a very friendly one. When encoding error messages into class names is a best practice, you know you're pushing the envelope.

    There's no discussion in this book of where these designs are appropriate - I suspect the most rococo code will end up hidden safely behind frameworks and libraries such as the Loki library described in this book. Some discussion of these bigger picture strategic and cultural issues would have been handy, otherwise, a title like 'Modern C++ Design' suggests that herein lie techniques to sprinkle liberally throughout your code, and I suspect that this is not the case.

    If you, your co-workers, and any customers that need to look at your code are all template metagenii, this is going to be the most productive 300 pages you ever read. Lesser mortals will find much to wonder at and admire, and a whole new perspective on design patterns, but perhaps less to put into practice.
  5. Well worth buying.

    Rated 5 out of 5 stars, February 12th, 2005

    Despite the advanced concepts covered the book is very well written and quite readable, but it does require you to think! I was using concepts in this book in my applications almost immediately. 10/10

Our Network

BooksForGeeks.com is a participant in the Amazon Europe S.à r.l. Associates Programme, an affiliate advertising programme designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.co.uk