Modern C++ Design: Generic Programming and Design Patterns Applied 1st Edition by Debbie Lafferty (PDF)

6

 

Ebook Info

  • Published: 2001
  • Number of pages: 360 pages
  • Format: PDF
  • File Size: 1.62 MB
  • Authors: Debbie Lafferty

Description

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 flexibilityPartial template specializationTypelists―powerful type manipulation structuresPatterns such as Visitor, Singleton, Command, and FactoriesMulti-method enginesFor each generic component, the book presents the fundamental problems and design options, and finally implements a generic solution.

User’s Reviews

Editorial Reviews: From the Inside Flap You might be holding this book in a bookstore, asking yourself whether you should buy it. Or maybe you are in your employers library, wondering whether you should invest time in reading it. I know you dont have time, so Ill cut to the chase. If you have ever asked yourself how to write higher-level programs in C++, how to cope with the avalanche of irrelevant details that plague even the cleanest design, or how to build reusable components that you dont have to hack into each time you take them to your next application, then this book is for you. Imagine the following scenario. You come from a design meeting with a couple of printed diagrams, scribbled with your annotations. Okay, the event type passed between these objects is not char anymore; its int. You change one line of code. The smart pointers to Widget are too slow; they should go unchecked. You change one line of code. The object factory needs to support the new Gadget class just added by another department. You change one line of code. You changed the design. Compile. Link. Done. Well, there is something wrong with this scenario, isnt there? A much more likely scenario is this: You come from the meeting in a hurry because you have a pile of work to do. You fire a global search. You perform surgery on code. You add code. You introduce bugs. You remove the bugs . . . thats the way a programmers job is, right? Although this book cannot possibly promise you the first scenario, it is nonetheless a resolute step in that direction. It tries to present C++ as a newly discovered language for software architects. Traditionally, code is the most detailed and intricate aspect of a software system. Historically, in spite of various levels of language support for design methodologies (such as object orientation), a significant gap persisted between the blueprints of a program and its code because the code must take care of the ultimate details of the implementation and of many ancillary tasks. The intent of the design is, more often than not, dissolved in a sea of quirks. This book presents a collection of reusable design artifacts, called generic components, together with the techniques that make them possible. These generic components bring their users the well-known benefits of libraries, but in the broader space of system architecture. The coding techniques and the implementations provided focus on tasks and issues that traditionally fall in the area of design, activities usually done before coding. Because of their high level, generic components make it possible to map intricate architectures to code in unusually expressive, terse, and easy-to-maintain ways. Three elements are reunited here: design patterns, generic programming, and C++. These elements are combined to achieve a very high rate of reuse, both horizontally and vertically. On the horizontal dimension, a small amount of library code implements a combinatorialand essentially open-endednumber of structures and behaviors. On the vertical dimension, the generality of these components makes them applicable to a vast range of programs. This book owes much to design patterns, powerful solutions to ever-recurring problems in object-oriented development. Design patterns are distilled pieces of good designrecipes for sound, reusable solutions to problems that can be encountered in manycontexts. Design patterns concentrate on providing a suggestive lexicon for designs to be conveyed. They describe the problem, a time-proven solution with its variants, and the consequences of choosing each variant of that solution. Design patterns go above and beyond anything a programming language, no matter how advanced, could possibly express. By following and combining certain design patterns, the components presented in this book tend to address a large category of concrete problems. Generic programming is a paradigm that focuses on abstracting types to a narrow collection of functional requirements and on implementing algorithms in terms of these requirements. Because algorithms define a strict and narrow interface to the types they operate on, the same algorithm can be used against a wide collection of types. The implementations in this book use generic programming techniques to achieve a minimal commitment to specificity, extraordinary terseness, and efficiency that rivals carefully handcrafted code. C++ is the only implementation tool used in this book. You will not find in this book code that implements nifty windowing systems, complex networking libraries, or clever logging mechanisms. Instead, you will find the fundamental components that make it easy to implement all of the above, and much more. C++ has the breadth necessary to make this possible. Its underlying C memory model ensures raw performance, its support for polymorphism enables object-oriented techniques, and its templates unleash an incredible code generation machine. Templates pervade all the code in the book because they allow close cooperation between the user and the library. The user of the library literally controls he way code is generated, in ways constrained by the library. The role of a generic component library is to allow user-specified types and behaviors to be combined with generic components in a sound design. Because of the static nature of the technique used, errors in mixing and matching the appropriate pieces are usually caught during compile time. This books manifest intent is to create generic componentspreimplemented pieces of design whose main characteristics are flexibility, versatility, and ease of use. Generic components do not form a framework. In fact, their approach is complementarywhereas a framework defines interdependent classes to foster a specific object model, generic components are lightweight design artifacts that are independent of each other, yet can be mixed and matched freely. They can be of great help in implementing frameworks. Audience The intended audience of this book falls into two main categories. The first category is that of experienced C++ programmers who want to master the most modern library writing techniques. The book presents new, powerful C++ idioms that have surprising capabilities, some of which werent even thought possible. These idioms are of great help in writing high-level libraries. Intermediate C++ programmers who want to go a step further will certainly find the book useful, too, especially if they invest a bit of perseverance. Although pretty hard-core C++ code is sometimes presented, it is thoroughly explained. The second category consists of busy programmers who need to get the job done without undergoing a steep learning investment. They can skim the most intricate details of implementation and concentrate on using the provided library. Each chapter has an introductory explanation and ends with a Quick Facts section. Programmers will find these features a useful reference in understanding and using the components. The components can be understood in isolation, are very powerful yet safe, and are a joy to use. You need to have a solid working experience with C++ and, above all, the desire to learn more. A degree of familiarity with templates and the Standard Template Library (STL) is desirable. Having an acquaintance with design patterns (Gamma et al. 1995) is recommended but not mandatory. The patterns and idioms applied in the book are described in detail. However, this book is not a pattern bookit does not attempt to treat patterns in full generality. Because patterns are presented from the pragmatic standpoint of a library writer, even readers interested mostly in patterns may find the perspective refreshing, if constrained. Loki The book describes an actual C++ library called Loki. Loki is the god of wit and mischief in Norse mythology, and the authors hope is that the librarys originality and flexibility will remind readers of the playful Norse god. All the elements of the library live in the namespace Loki. The namespace is not mentioned in the coding examples because it would have unnecessarily increased indentation and the size of the examples. Loki is freely available; you can download it from awl/cseng/titles/0-201-70431-5. Except for its threading part, Loki is written exclusively in standard C++. This, alas, means that many current compilers cannot cope with parts of it. I implemented and tested Loki using Metrowerks CodeWarrior Pro 6.0 and Comeau C++ 4.2.38, both on Windows. It is likely that KAI C++ wouldnt have any problem with the code, either. As vendors release new, better compiler versions, you will be able to exploit everything Loki has to offer. Lokis code and the code samples presented throughout the book use a popular coding standard originated by Herb Sutter. Im sure you will pick it up easily. In a nutshell, Classes, functions, and enumerated types look LikeThis. Variables and enumerated values look likeThis. Member variables look likeThis_. Template parameters are declared with class if they can be only a user-defined type, and with typename if they can also be a primitive type. 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. –Herb SutterWhat’s left to say about C++ that hasn’t already been said? Plenty, it turns out. –From the Foreword by John VlissidesIn 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 flexibilityPartial template specializationTypelists–powerful type manipulation structuresPatterns such as Visitor, Singleton, Command, and FactoriesMulti-method enginesFor 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 About the Author Andrei Alexandrescu is the author of the award-winning book Modern C++ Design (Addison-Wesley, 2001) and is a columnist for C/C++ Users Journal. Read more

Reviews from Amazon users which were colected at the time this book was published on the website:

⭐Many years ago, I began to feel that the power of templates in C++ has not been fully exploited. In more recent years, the emergence of the STL has shown that templates can be used to great advantage for containers, allowing conceptually simple generic implementations to be reused in a wide variety of situations, with no run-time penalty. This advance only increased my sense that we haven’t yet seen the full power of templates.Alexandrescue’s remarkable work is, in my view, the most original and important advance in C++ since the STL. It has been an article of faith in the design patterns community that one can’t implement a reusable design patterns library in any language, because each pattern has dozens of important variations, and an unlimited number of custom variations, all seemingly interdependent. Alexandrescue’s work seriously challenges this assumption. He uses “policy classes” (explained in Chapter 1) together with many innovative template techniques to pull apart these interdependencies. The heart of the book describes in detail how he developed the “Loki” library containing many gang-of-four design pattern implementations. Loki’s SmartPtr, one of the high points of the book, puts to shame the Standard C++ auto_ptr, which has been the state of the art until now.Even before Alexandrescue’s work, templates provided C++ programmers with major advantages not available in “more modern” object-oriented languages such as Java and C#. Alexandrescue multiplies the existing advantages many times, facilitating dramatic increases in C++ programming productivity and quality. Isn’t that what high-level language programming is all about?The only negative comment I have is not really a criticism of Alexandrescue’s work, but of the deplorable state of C++ compiler implementations. Because many C++ compilers, especially the most popular ones, still do not fully support Standard C++, many of Alexandrescue’s techniques cannot yet be used in many practical situations. I would like to think that the importance of supporting Alexandrescue’s library will motivate compiler vendors to make the necessary, and long-overdue upgrades.

⭐Quality was beyond my expectations.

⭐Finally I picked up “modern C++ design”. It was on my list for a long time. Last years I’ve been diving more in Java, Groovy, Ruby and other languages. So, this book was back to C++ for me.I found the book well written, even almost funny at times. The code was clear and it was all easy to understand for me. So, well done since it’s always difficult to explain fairly advanced concepts in simple language.The book consists of 2 parts. The first part describes concepts like policy-based design and typelists. I liked the concept parts and this was my first encounter with typelists, thus I was quite amazed.The second part of the book describes how to design generic patterns. I liked them, however, I felt that making some of these patterns generic is not really worth it. The amount of duplicate code removed, is not very high. The complexity added by the generic implementation, however is high.An example is chapter 7, smart pointers. I’ve designed some libraries in the past and as library designer we agreed on 3 different types of smart pointers. We write three different classes and that’s it. Is it worth making a generic implementation which can cover all of these three types. In my opinion, no. However, as an exercise of what you can all do with templates in C++, it was very interesting!I’m now and then working with developers who develop in C++. They already struggle with the complexity of the language, the environment and the tools. Giving them generic programming in C++, would probably increase their struggle and wouldn’t really gain much. Maybe a new language need to be created with better generic programming support instead?Anyways, for any C++ fanatic or programming fanatic, this is a fantastic book. For “the normal developer” it’s probably overkill.

⭐Although this book is now six-plus years old, compilers have finally caught up with the implementation allowing the techniques outlined in the book to be used in production code. Alexandrescu infuses what could be a dry topic with humor, and does a great job of explaining fairly esoteric ideas with enough grounding in concrete implementation to be approachable by a wide range of readers.The book does a great job of outlining factory classes, which are often given a hand-waving description with no explanation of how to deal with the ‘start up’ problem of populating the factory with the set of classes it should be creating. This usually leads to lots of boiler-plate, hard-coded linkage between different pieces of the system, but Alexandrescu outlines techniques to automate this process.If you have been chafing at some of the restrictions imposed by the C++ standard after being exposed to more dynamics languages like Objective C, Ruby, etc., you may find a few tricks that will enable you to achieve your goals.

⭐Despite years of programming in C++, templates is the one area I have not mastered past a simple “Add two numbers” example, I bought this book based on the publishers review and Author comments knowing it would be an advanced level book due to the use of templates and was hoping to learn more, despite reading large chunks of the book I am still learning, it has pushed my knowledge boundary higher and its encouraged me to read more works on templates to fill questions I have asked myself.Its not a beginners book nor a book for novice programmers, it seams to be aimed at more advanced programmers and if you proficient at templates you will love it.I will be reading it again and again till I master it so it will be a book I reference through my programming career for sure!

⭐1st Indian subcontinent 2007 edition, 2017 printing. For ISO C++98 standard so not compatible with MS Visual Studio/C++ 6 or 7.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.

⭐This book is about template metaprogramming. Even if you can’t see a use for that technique, merely reading this book will tax your brain to the maximum and expand your programming horizons.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.

⭐Up so far, the book is milk&honey smooth to read and a real pleasure. I’m an experienced developer with 10 years of C++ and many things I read in the book confirm my earlier observations and provide some good answers. No redundant paragraphs (which I’d hate); going in-depth on relevant examples; good grammar and precise wording; … All in all, an actual intellectual wrote this book, no doubt. Very happy with it.

⭐One of the best c++ book. Though its not suitable for begineers but if someone really want to know template, its for them. It require you have some idea on template, but you’ll find yourself thinking in templates. Genious template tricks. If read carefully you’ll learn design, best c++ practice, and patterns. Just get template idea before reading this book. Andrie is genious.

⭐in diesem Sachbuch werden viele spezielle Techniken vermittelt (so zB. generische Policies über Templates), die selbst einem erfahrenem C++ Entwickler noch einiges abverlangen werden. Meiner Meinung nach eine verpflichtende Lektüre für jeden C++ Entwickler, wer denkt C++ als Programmiersprache verstanden zu haben wird in diesem Buch von Herrn Alexandrescu eines besseren belehrt werden und das auf einen sehr angenehme Art (jeder der schon einmal einen Vortrag von Herrn Alexandrescu beiwohnen durfte und seine hurmorvolle Art kennt, wird hier positiv Überrascht sein).

Keywords

Free Download Modern C++ Design: Generic Programming and Design Patterns Applied 1st Edition in PDF format
Modern C++ Design: Generic Programming and Design Patterns Applied 1st Edition PDF Free Download
Download Modern C++ Design: Generic Programming and Design Patterns Applied 1st Edition 2001 PDF Free
Modern C++ Design: Generic Programming and Design Patterns Applied 1st Edition 2001 PDF Free Download
Download Modern C++ Design: Generic Programming and Design Patterns Applied 1st Edition PDF
Free Download Ebook Modern C++ Design: Generic Programming and Design Patterns Applied 1st Edition

Previous articleAlgebra and Coalgebra in Computer Science: 4th International Conference, CALCO 2011, Winchester, UK, August 30 – September 2, 2011, Proceedings by Andrea Corradini (PDF)
Next articleBlood Meridian: Or the Evening Redness in the West (Vintage International) by Cormac McCarthy (EPUB)