- Buy this product and stream 90 days of Amazon Music Unlimited for free. E-mail after purchase. Conditions apply. Learn more
Modern C++ Design: Generic Programming and Design Patterns Applied: Applied Generic and Design Patterns (C++ in Depth) Paperback – 13 Feb 2001
|New from||Used from|
- Choose from over 13,000 locations across the UK
- Prime members get unlimited deliveries at no additional cost
- Find your preferred location and add it to your address book
- Dispatch to this address when you check out
Special offers and product promotions
Frequently bought together
Customers who viewed this item also viewed
Enter your mobile number or email address below and we'll send you a link to download the free Kindle App. Then you can start reading Kindle books on your smartphone, tablet, or computer - no Kindle device required.
To get the free app, enter your mobile phone number.
Would you like to tell us about a lower price?
If you are a seller for this product, would you like to suggest updates through seller support?
In Modern C++ Design, Andrei Alexandrescu opens new vistas for C++ programmers. Displaying extraordinary creativity and virtuosity, Alexandrescu offers a cutting-edge approach to software design that unites design patterns, generic programming, and C++, enabling programmers to achieve expressive, flexible, and highly reusable code. The book introduces the concept of generic components, reusable design templates that enable an easier and more seamless transition from design to application code, generate code that better expresses the original design intention, and support the reuse of design structures with minimal recoding. The author then shows how to apply this approach to recurring, real-world issues that C++ programmers face in their day-to-day activity. All code is available on the Web, along with Alexandrescu's downloadable Loki C++ library, which provides powerful out-of-the-box functionality for virtually any C++ project. For experienced C++ programmers who have at least some familiarity with the Standard Template Library (STL).
From the Back Cover
Modern C++ Designis an important book. Fundamentally, it demonstrates ‘generic patterns’ or ‘pattern templates’ as a powerful new way of creating extensible designs in C++–a new way to combine templates and patterns that you may never have dreamt was possible, but is. If your work involves C++ design and coding, you should read this book. Highly recommended.
What’s left to say about C++ that hasn’t already been said? Plenty, it turns out.
–From the Foreword by John Vlissides
In Modern C++ Design, Andrei Alexandrescu opens new vistas for C++ programmers. Displaying extraordinary creativity and programming virtuosity, Alexandrescu offers a cutting-edge approach to design that unites design patterns, generic programming, and C++, enabling programmers to achieve expressive, flexible, and highly reusable code.
This book introduces the concept of generic components–reusable design templates that produce boilerplate code for compiler consumption–all within C++. Generic components enable an easier and more seamless transition from design to application code, generate code that better expresses the original design intention, and support the reuse of design structures with minimal recoding.
The author describes the specific C++ techniques and features that are used in building generic components and goes on to implement industrial strength generic components for real-world applications. Recurring issues that C++ developers face in their day-to-day activity are discussed in depth and implemented in a generic way. These include:
- Policy-based design for flexibility
- Partial template specialization
- Typelists–powerful type manipulation structures
- Patterns such as Visitor, Singleton, Command, and Factories
- Multi-method engines
For each generic component, the book presents the fundamental problems and design options, and finally implements a generic solution.
In addition, an accompanying Web site, http://www.awl.com/cseng/titles/0-201-70431-5, makes the code implementations available for the generic components in the book and provides a free, downloadable C++ library, called Loki, created by the author. Loki provides out-of-the-box functionality for virtually any C++ project.
Get a value-added service! Try out all the examples from this book at www.codesaw.com. CodeSaw is a free online learning tool that allows you to experiment with live code from your book right in your browser.
0201704315B11102003 See all Product description
Customers who bought this item also bought
There was a problem filtering reviews right now. Please try again later.
The author describes his free multi-threading library, Loki where the textual errors have been removed.
This is a modern development of C++ by using templates and macros to improve the speed at runtime.
The macro processor is a completely programmable Turing machine so the templates can be executed statically at compile saving the time to do this dynamically at runtime.
These methods are only usable with ISO conformant C++ compilers so it is not much use for other languages except perhaps the D language.
There is a description of how to implement singleton, command, object factories, Abstract Factory and Visitor design patterns using policies, traits and typelists.
The author since about 2010 became a lead developer of the D language.
I first read this book about a decade ago as some light (ahem) holiday reading and I'll be the first to confess that I didn't 'get it' first time. There were many 'how the ...?' and 'what the ...?' moments. Now a decade and a lot more experience later I've re-read it and finally it makes sense.
Andrei taxes the language and the compilers to the maximum in ways that you may not want to do in production code as the number of people that will be able to maintain it will be small, but as an intellectual exercise this book should be up there with Knuth's classics.
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.
In all seriousness, the book introduces generic programming and template metaprogramming. The concepts of policy-based design are made clear with relevant examples throughout the book. This is a C++ classic that all should read.
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.