Advanced C++ Articles from Dr Dobb Journal
-- Sponsered Links --
“Conversations” Column Archive – Main Index Page – Let me close with the story of “Conversations” Column Archive – Main Index Page
Conversations: Redirections - Redirecting IOStreams input or output is a relatively simple task. The only hitch is, you have to learn a little bit about streambufs to make it work. Once again, we have evidence that streambufs are not just an implementation detail of C++ IOStreams, to be studied only by “power users.” It behooves all C++ programmers to learn about them. Conversations: Redirections
Conversations: Manipulations - You may be a hot shot at implementing algorithms, but if you don’t provide a good interface nobody will want to use your code. Packaging is important. A case in point: if you have to do a little bit of text processing before sending text to a stream, where’s the best place to do it? Consider writing an iostream manipulator. Manipulators provide a simple, intuitive interface that enables users to “insert” the processing directly into a stream. And you don’t have to be a guru to write a manipulator – just follow the example in this installment. Conversations: Manipulations
Conversations: Roots - The C++ Standard is not much help in predicting the binary layout of a class; this is especially true in the presence of the keyword ‘virtual’. Assume too much and you are just asking for trouble. That’s what Bob did, and true to form, when his code broke he blamed someone else. As this installment shows, it pays to know something about your ancestors, in both the object world and the real world. More precisely, it pays to know how little about them you can take for granted. Conversations: Roots
Conversations: Abstract Factory, Template Style - Abstract class factories can be time-consuming and difficult to maintain. Many implementations rely on manually-maintained lookup tables, extensive use of macros, or non-portable idioms. This month, our authors present a generic, portable, abstract class factory. Conversations: Abstract Factory, Template Style
Conversations: How to Persist an Object - In this article, our narrator learns that object persistence can be easily implemented, especially when it’s hooked up to the factory method template. Conversations: How to Persist an Object
Conversations: The Bind That Ties - The standard library provides adaptors that extend the flexibility and power of the standard functions. While some of them may seem scary at first glance, they really are quite simple to use. Conversations: The Bind That Ties
Conversations: Back to Base-ics - When you are adding a new class to a project, and that class is very similar to an existing class, you will frequently have three options: publicly derive one class from the other, create a common base class from which both the new and existing classes will be derived, and implement one class in terms of the other class. What is the best way to choose among the three options? Conversations: Back to Base-ics
Conversations: Al-Go-Rithms - The Standard C library contains some functions that are still useful in C++. Sometimes, though, you need to find your own ‘rithm — algorithm, that is. Conversations: Al-Go-Rithms
Conversations: Hungarian wartHogs - What’s in a name? Plenty, if you use Hungarian notation. Too much, if you use Hungarian notation.? Conversations: Hungarian wartHogs
Conversations: I’d Hold Anything for You - There are occasions when you have a variable whose type you don’t know until run time. The common solution has been to use a union or a void pointer, both of which can have devastating effects if not used correctly. Now, thanks to the Boost library, there is a safe alternative. Conversations: I’d Hold Anything for You
Conversations #1: Re-membering auto_ptr – One of the Classic on Conversations #1: Re-membering auto_ptr
New Bases, - Converting a text-represented number from one base to another is pretty simple. But how extensible and reusable can the solution be to solve more than one problem, when there are also additional requirements? New Bases,
New Bases, Part 2 - Basic reading and writing from a standard stream sounds simple, but can harbor its share of little complexities. Here is a simple example, with notes about the kinds of complexity that can usually be deferred. New Bases, Part 2
Conversations: Template Specializations, Default Parameters, and Other Fun Stuff - Many people know how to partially specialize a template. But what happens when the base template has a template parameter with a default value? The answer may not be quite what Bob expected. Conversations: Template Specializations, Default Parameters, and Other Fun Stuff
Conversations: To Sleep, Perchance - Just how many threading and streaming mistakes can arise in one poor little dozen-line function? Quite a few, and that’s not even counting the magic… The effects of sleep deprivation can have an astonishing effect on the clarity of one’s code. Conversations: To Sleep, Perchance
Making a Real Hash of Things - This month, Bob gets an up-close and personal look at tree-based versus hash-based containers. Making a Real Hash of Things
Conversations:The Good, the Bad, and the Deprecated - What can go wrong when your code gives you a bit too much… er… static. Conversations:The Good, the Bad, and the Deprecated
Conversations:Getting to the Point - While the standard bauto_ptr/b provides a safer alternative to raw pointers, it has its limitations and some surprising behavior. The Guru helps out by giving the narrator a boost – library, that is. The Boost library has five smart pointers that provide a rich array of useful behavior. Conversations:Getting to the Point
Conversations:A Midsummer Night’s Madness - What’s the point of adding a pointer to a btypedef/b? The Guru puts in her thoughts on the matter. Conversations:A Midsummer Night’s Madness
Conversations: Baseless Exceptions - Implicit conversion sequences can be quite useful. But there are… well… exceptions to when they are applied. Conversations: Baseless Exceptions
Contracts, Promises, and Mere Semantics - What is a function saying when it takes a parameter by pointer, by reference, or by value? When interface idioms lie, sometimes there’s no good way to avoid the surprises. Contracts, Promises, and Mere Semantics
Conversations #2: Null References – All kinds of material on Conversations #2: Null References
Conversations:Truth or Consequences - What’s wrong with using bool as a parameter? There are usually better ways to express what you mean. This month we turn to an expert who died before Stroustrup was born. Conversations:Truth or Consequences
Conversations:It’s an Object-ful Lifetime - It is possible to bind a temporary object to a non-constant reference, at least indirectly. As with all unusual techniques (sometimes pronounced “hacks), you must pay close attention. In this case, object lifetimes play a significant role. Conversations:It’s an Object-ful Lifetime
Value Lessons - When will you learn to value the counsel of the prophets? Decide what type of object you’re defining and stay the course. Value Lessons
Points of Order - A poignant reminder that locks tend to be global, despite appearances to the contrary, and should be verified globally. Points of Order
Once Is Not Enough - Don’t let Singletons degenerate into global variables. Once Is Not Enough
Sharing Causes Contention - Serial killers lurking in your code: why they’re there and how to eradicate them. Sharing Causes Contention
Delegating Constructors? - A lesson on writing moral code. Delegating Constructors?
Imagine - Portability without #idefs? It’s (sort of) easy if you really try. Imagine
Factory Redux, - Adding generic persistence factories the modern C++ way. Factory Redux,
Factory Redux, Part 2 - Revisiting the Template Method factory, with a generic twist to it. This month: incorporating the PersistentStorage framework into your class hierarchy, and a summary of the pros and cons of this technique. Factory Redux, Part 2
Conversations #3: Genesis – The execution of examples described in Conversations #3: Genesis
From C++ to Shining C - See your way to handily exposing C++ objects to C. From C++ to Shining C
Self-Sufficient Headers - A good C++ (and C) coding standard is that every header file should be self-sufficient. But is it always so? Self-Sufficient Headers
Pointing in the Right Direction - If pointers are used improperly, they can lead to memory leaks. This month, the Guru shows how to avoid pointer problems that lead to leaks. Pointing in the Right Direction
Of Many Things - The Guru tackles std::string, magic numbers, and constness in references. Of Many Things
Virtually Misbehavin’ - Bahb’s your uncle, as the Guru takes on C++ implicit overriding to task. Virtually Misbehavin’
Im-Paired Programming - std::pair can make your life easier. But as with many things, moderation is the key: Excessive use can lead to unmanageable code. Im-Paired Programming
Using Me - This month, the Guru shares rules and guidelines that govern the use of the using directive. Using Me
Enumerations - As Stroustrup once wrote, “C enumerations constitute a curiously half-baked concept.” And C++ enumerations are only slightly better. Enumerations
Getting Abstractions - Are igetter/i, isetter/i, and Bob inherently evil, or are they just a little misunderstood? Getting Abstractions
Delete This Threat - On first glance, self-deleting objects may not appear to be thread-safe. Delete This Threat
Conversations: So Who’s the Portable Coder? - When it comes to writing portable code, knowing what’s standard is only half the battle. You might have to work around a few obstacles, including a guy named Bob. Conversations: So Who’s the Portable Coder?
Collecting Shared Objects - shared_ptr is becoming widely available and added to the Standard Library. Collecting Shared Objects
Typedefs and Iterators: If you’ve Got ‘Em, Use ‘Em - Typedefs and iterators-if you’ve got ‘em, use ‘em. Typedefs and Iterators: If you’ve Got ‘Em, Use ‘Em
Friendly Nesting - In well-formed programs, classes can’t declare a nested class to be a friend-but this might change in the Standard. Friendly Nesting
Adaptations - When there are no other solutions on the horizon, intermediate adaptors can be a good way to get the job done. Adaptations
Alias - When are two variables really two variables? Ask the Guru. Alias
Tagged Unions - Some of our C heritage is slim and fast-and fragile-in the name of performance. Unions are such beasts. Tagged Unions
Order, Order - Getting the order right for a standard associative container can take a bit of thought. Order, Order
Implicit Virtual - When it comes to implicit virtual, one man’s “bug” is another’s “feature.” Implicit Virtual
Polymorphic Exceptions - What do you do when you want to throw an exception, but all you have is a reference to the base class? Polymorphic Exceptions
Logically Shallow Views - The Guru takes on const. Logically Shallow Views
Conversations: By Any Other Name - When the pressure’s on, we overlook good solutions, and sometimes for trivial reasons. Guess which well-known pattern our hero is about to about to miss – and all because it’s poorly named. Conversations: By Any Other Name
Graceful Exits - When you detect an error or invalid state in a function, what’s the best way to handle it? Graceful Exits
Conversations: Virtually Yours - A good class designer can communicate how she intends a class to be used-often without writing a single comment-through intelligent use of access modifiers and virtual functions. But there’s more: a good class designer will also make virtual functions private whenever design considerations allow it. If you find this guideline surprising, read on to learn the rationale. Conversations: Virtually Yours
Conversations: Obelisk - Most programmers are aware that refactoring techniques, such as functional decomposition, can improve the overall quality of code. But there is another reason to refactor: if you’re maintaining some broken legacy code, refactoring it first may be your only hope in fixing it. Refactoring does require care, so as not to change the semantics of the code; and as our authors show, it requires extra special care when the “legacy” code was written last week, and the “legacy” programmer is still around. Conversations: Obelisk
Conversations: Access Restrictions - What do access restrictions have to do with efficiency? Either a little or a lot, depending on how well you understand compiler optimizations. Here’s a story about a guy who didn’t understand them very well. What’s sad is, a little profiling might have saved him from one of the deadly sins of optimization: solving a problem that does not exist. Conversations: Access Restrictions
Advanced C++ Articles from Dr Dobb Journal
Related Posts:
-- Sponsered Links --
Sarita Patil said,
October 7, 2007 @ 3:41 amSir,
Could you please send me C++ books and articles?
Thanks