Monthly Archives: May 2012

Implementing the Observer Pattern in C++ – Part 2

In part 1 of this article I presented an Event/Callback library intended to support the Observer pattern and hinted that it had some limitations. The library was based on the following Event class template: template<typename Arg> class Event { public: … Continue reading

Posted in software | Tagged , | Leave a comment

Implementing the Observer Pattern in C++ – Part 1

Introduction The Observer design pattern is described in the “Gang of Four” book [Gamma] as a method of propagating state changes from a Subject to its Observers. The key feature of the pattern is that Observers register with the Subject … Continue reading

Posted in software | Tagged , | Leave a comment

Template Titbit – A Different Perspective

Background Oliver Schoenborn’s article, “Tiny Template Tidbit”, in Overload 47 illustrates some of the wonderful things you can do with templates. I particularly liked the way it described the thought processes Oliver went through when designing some curve-fitting software and … Continue reading

Posted in software | Tagged , | Leave a comment

C++ Exceptions and Linux Dynamic Libraries

A Cautionary Tale Once upon a time there was a bright young C++ programmer… Well, not so young, actually. And, sadly, not bright enough to know how to use C++ member functions in a Linux dynamic library. I’ll tell you … Continue reading

Posted in software | Tagged , | Leave a comment

Supporting Threads in Standard C++ – Addendum

During a conversation at the March Java and C/C++ Conference I promised not to inflict another article about threads on Overload readers. It is time to move on to other topics. However, Kevlin Henney raised some issues that are well … Continue reading

Posted in software | Tagged , | Leave a comment

Supporting Threads in Standard C++ – Part 3

Recap The previous articles in this series on threads offered two suggestions: Use a thread function interface class to separate the application-specific code from the thread library facilities (the Thread-Runs-Polymorphic-Object design). Use a Handle-and-Reference-Counted-Body technique to manage the lifetime of … Continue reading

Posted in software | Tagged , | Leave a comment

Supporting Threads in Standard C++ – Part 2

Recap The first part of this series of articles on threads addressed what I called the function signature mismatch problem. The thread library needs to allow an arbitrary user-defined function to be run asynchronously with respect to other threads. That … Continue reading

Posted in software | Tagged , | Leave a comment

Supporting Threads in Standard C++ – Part 1

Why Threads? Shortly after the C++ standard was announced I read an article explaining what the standardisation committee will do next. There is still work to do, it said. Although the standard is not allowed to change for 7 years … Continue reading

Posted in software | Tagged , | Leave a comment

The State Pattern – A New Implementation

Introduction In their book, Design Patterns, Elements of Reusable Object-Oriented Software, Gamma, Helm, Johnson and Vlissides describe a design pattern called State. The State pattern allows an object to change its behaviour when its internal state changes. For example, suppose … Continue reading

Posted in software | Tagged , | Leave a comment

DDT

A mosquito was heard to complain That the chemists had damaged his brain. The cause of his sorrow Was para-dichloro- Diphenyl-trichloro-ethane.

Posted in Uncategorized | Leave a comment