Author image

Event Queue, Message Bus and Dispatcher


NOTE: I will use the terms event and message interchangeably. In some contexts there may be a minor differentiation but for this discussion it will be ignored.

Event Queue or Message Bus

Definition:

Decouple when a message or event is sent from when it is processed. - R. Nystrom

What's the easiest way to manage the connections between event listeners and event producers? You guessed it, “Event Queues”.

When an event occurs, such as user input, or an entity sending an event to another entity, it needs to be stored somewhere such that it's not lost while in transit between the source that reported the event and when the program gets around to respond to it. That “somewhere” is a queue.

New events are added (aka enqueue) to a queue of unprocessed events. And at a later time when it's convenient in the application we...

Author image

Console on a Windows GUI Application


Provision Windows C++ GUI applications with a fully featured & functional console window that can be used for logging or whatever other purpose you deem useful.

I used Windows Visual Studio & C++17 to build the project.

Github

Github repository link.

Author image

Quadcopter Drone CC3200 Radio Telemetry Project


This was my Bachelor Thesis' Project (2016).

Nick Lazaridis, Technical University of Piraeus, Greece.

In short: Programmed Texas Instruments (T.I.) CC3200 wifi unit, to act as the telemetry intermediary between the Ground Control Station (GCS) and the APM Ardupilot flight controller on top of the QuadCopter/Drone.

The thesis is written in Greek. You can find it in Thesis_QuadcopterTelemetry_Nikos_Lazaridis_ppapag.pdf. If I get requests I may get motivated to translate it to English.

Most of the code has been written in Texas Instruments Code Composer Studio 6. I haven't tested it with updated CCS versions.

Showcase

Youtube video link.

Github

Github repository link.

Author image

C++ Vector Implementation


A C++17 ready, allocator_traits aware Vector similar to std::vector ; made to become familiar with the internals of C++ standard library containers.

TODO:

  • fix some obscure Iterator problems (perhaps add begin() and end() to it) - we'll see
  • shrinkToFit(#) : if current storage is larger than # Bytes, it shrinks it to # bytes
  • halfSize() shrink

I won't attempt to create a full tutorial on this, because LokiAstari has covered this in excruciating detail already - in a level I can't hope to match (check out acknowledgements section below).

I used Windows, Visual Studio & C++17 to...

Author image

Observer Design Pattern


Observer is a behavioral software design pattern, that is being extensively utilized in almost every single self-respecting codebase as a means to efficiently communicate between objects in an event-based fashion. It wouldn't be an understatement to say it is the foundation of event based programming.

In fact, underlying the ubiquitous, in network programming, “Model View Controller” (MVC) design pattern, is the observer pattern.

Observers are used in every single game engine - they're known there mostly as “Event dispatchers”.

Alternative terminology for this pattern includes the following: - Publish-Subscribe, Listener-Reporter.

Design

  • a class, called the Subject, maintains a list of...

Author image

Command Design Pattern


Definition:
Encapsulate a request as an object, thereby letting users parameterize clients with different requests, queue or log requests, and support undoable operations.

Breakdown:
You are not encapsulating the object that sends the request, or the object that receives the request, but encapsulate the actual request as an object with state. Of course, some commands can be stateless chunks of pure behavior (no data members).
The command pattern also makes undoable/redoable operations a piece of cake (they're considerably harder to implement without it). Derived Commands can leverage CRTP to be statically bound.

Note that the code executing the commands is responsible for freeing their memory.

Design

  • define a base abstract class Command that represents a triggerable...

Author image

Curiously Recurring Template Pattern


Curiously Recurring Template Pattern, or CRTP for short, is essentially a C++ idiom. It is also known as Static Polymorphism or Simulated polymorphism.

Here's the differences between (actual) Dynamic polymorphism and Static polymorphism (CRTP):

Requirements for dynamic polymorphism:

  1. Is-a relationship between base and derived class.
  2. Base class defines a 'generic' algorithm that is used by derived class.
  3. The 'generic' algorithm is customized by the derived class.

Requirements for static polymorphism:

  1. 'Is-a' relationship between base and derived class.
  2. Base class defines a 'generic' algorithm that is used by derived class.
  3. The 'generic' algorithm is customized by the derived class.
  4. This method is pure virtual. The derived method implements it.

Benefits

  • CRTP is simulating dynamic...

Author image

Strategy Design Pattern


Definition:

Define a family of algorithms, encapsulate each one and make them interchangeable.

It is also known as 'policy' pattern. Instead of implementing a single algorithm directly, code receives run-time instructions as to which in a family of related algorithms to use.

Strategy is a flexible pattern, as it makes combining, adding, changing behaviors of an object easy as pie.

Design

  • create your algorithms as classes, or abstract classes
  • refine your algorithms by inheriting from them
  • create your target object Duck here
  • the target object has pointers to all the possible base algorithms it can support
  • create your object by supplying to it the behaviors you want to provide through its constructor
  • to assign new behaviors simply supply new...

Author image

State Design Pattern


This is a demonstration of the State Design Pattern in C++ with a groovy example that will stick in your memory.

The state pattern allows an object to alter its behavior at runtime when its internal state changes. There is a base State class and various concrete derived state classes. The state class hierarchy makes up a state machine and the desired object can be at any one single state at a point in time. State is a very similar - a structural alternative - to the Strategy pattern.

Author image

Visitor Design Pattern


I have to agree that this design pattern confused me for a longer time than I'd want to admit. But fear not! Confusion is now over! The time of Understanding is at hand! This cancer curing project will solve all mysteries of the Visitor pattern.

Definition: Represent an operation to be performed on elements of an object structure. Visitor lets you define a new operation without changing (recompiling) the classes of the elements on which it operates.

Understood? No? I didn't think so; keep on reading. I never understood those definitions either. They only make sense After you delve deep into it and start making sense of it on your terms!

A Visitor is a behavioral software design pattern and a good design decision if you want to perform similar kinds of operations on objects of different types that are grouped inside a...

1 2 3 ... 6