The goal of this article is to show the differences in thinking that arise when you develop your application design using different languages and language paradigms. We will have a dynamic object-oriented language (Ruby), static object-oriented language (C#) and functional actor model-based dynamic language (Elixir). I may speculate that this might be interesting to people who know one or two of these languages.
Observer can be a really useful pattern when you need to notify other parts of your system about a state change or an event. The pattern is also known as publish/subscribe (pub/sub for short). Almost every GUI framework uses this pattern to receive notifications about button click or some other interaction with GUI. It is less common in server-side apps, but none the less, I’ve seen it be used in certain scenarios where it is a great fit.
Please, note that all examples will be canonical and by no means perfect or suitable for production use.
Also, I would like to mention that I will not implement the unsubscribing part here, because it will make my examples longer and won’t contribute to the understanding of the idea.
With that in mind, let’s begin!