October 28, 2025Oct 28 In the last post, we built a templated observer framework that let any publisher push strongly-typed messages to its subscribers. This time we’ll push the design further by trying to let a single publisher handle multiple message types—and we’ll quickly see how that innocent goal invites ambiguity, boilerplate, and some surprising trade-offs. Discovering Observers - Part 2 by Sandor Dargo From the article: Last week, we took the observer pattern from a very simple example and evolved it into a more flexible, template-based implementation in C++. We ended up with abstracted publishers and subscribers, a templated message type for flexibility, and publishers controlling when and how updates are pushed. This week, we’re going to tackle the challenge of supporting multiple message types in a single publisher. First attempt: multiple inheritance of templated bases It’s tempting to provide different specializations for our templates so the same publisher can push different message types. View the full article
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.