Author image

Registry - Dependency Injection Container Design Pattern


Registry lets you establish a single point of access for objects. Registry is often used as a Dependency Injection container (DIC). A DIC is a singleton class with a hash map container of various singleton types as well as functions querying the map. The queries are done and we return a certain object from the container. This hash-map is the provider of objects originating from a common interface and which they can be reused by whoever's asking (so it's best for them to be of the type std::shared_ptr<Type>). The objects stay resident inside DIC.

Since we want to avoid duplications, we implicitly want to "share" instances of objects; this requirement is screaming out for shared_ptr

Author image

Fallout 4 & Fallout New Vegas game Mod - Colt 1911 - Tribute to Cobra (1986)


KeyC0de productions presents a video game modification for Fallout 4 and Fallout New Vegas.

The iconic pistol from the movie Cobra (1986).

Starring:

The customized Colt 1911 (aka Colt Government) Gold Cup National Match, as the sidearm of Lieutenant Marion Cobretti, a member of the elite Police division known as the "Zombie Squad" is a single-action, semi-automatic, magazine-fed, recoil-operated pistol chambered for the .45 ACP cartridge.

Caress it with tenderness.

Guest starring:

Suppressor: There was never a suppressor shown in the 1986 movie so I had to invent one. I modeled it after the Thompson Machine ISIS 2.45 Suppressor, which can handle 45 ACP, 40 S&W, 9mm and other calibers.

Check out the mod webpages for more info and...

Author image

Base Friend Design Pattern

A software design pattern I've seen multiple times in codebases, that I've decided to designate (Name & Conquer). It answers the following question:

We have a certain ResourceClass, that we wish to use its internals in various other UserClasses. How do we achieve interaction using the base friend pattern?

It is a means to efficiently share code between different components/classes without breaking (too much) the rule of encapsulation. Classifying it as a behavioral design pattern should do nicely.

Design

We can leverage the C++ friendship rules. We're aware that C++ friends break encapsulation, "friends invade our private life". We don't like that, we hate it. However.. remember that friendship is not inherited nor bidirectional. Given this fact, we could create a base class for all our UserClasses and that class alone can...

Author image

Exception Class Hierarchies in C++


How to use exceptions? How to manage error codes in your C++ programs? That is the question of the day.

Luckily c++ exceptions are pretty standard in their programming. The go-to strategy is to create a base exception class with a name of your choosing (KeyException was mine) and then you can create subclass exception classes, nested in the various principal classes of your codebase. As an example I've created the GameException class which you can use as a template to create other nested exception classes.

Let's start with a tiny C++ exception primer -reminder- though before you get your hands on the code.

Author image

KeyEngine - 2d & 3d Game Engine


Hobby DirectX11 C++ game engine, with ambitions of evolving into a full fledged game engine in 98.13 billion years.

Author image

"KeyC0de Productions" intro sequence


If you've seen some of my YouTube videos you may have noticed the 12 sec intro sequence that rolls first thing.

I made this mainly using 3d Studio Max 2015 and Adobe After Effects.

To say it was tough would be an understatement, as I'm not really a modeler, animator. I just loved 3d Studio max and years ago I got the student license which allowed me to play and tinker with it to my heart's content. Same goes with After Effects, although the After Effects aspect was much simpler, required less work and after watching a few YouTube tutorials I was set.

I drew inspiration from various intros I adore such as:

  • Audio Visual Enterprises (1993)
  • Prism Entertainment (80s)
  • Gun Media (which is basically a carbon copy of Vidmark Entertainment 88)
  • Zodiac video (from 1985)
  • WWE Monday Night 1985
  • 20-20 vision (90s)

The music tune you will hear being played is a free sound from 

Author image

Aspect Oriented Programming


Aspect Oriented Programming (AOP) is a programming paradigm that aims to increase modularity by allowing the separation of cross-cutting concerns. It does so by adding additional behavior to existing code without modifying the code itself, instead separately specifying which code is modified via a 'pointcut' specification, such as “log all function calls when the function's name begins with 'set'”. This allows secondary behaviors (eg logging) to be added to a program without cluttering the meaty code that's core to the functionality.

Design

  • The AspectConfiguration specifies which aspect applies to which method of an object
  • Each aspect is essentially a method (or a separate class containing a group of those aspect-methods) written in an aspect-oriented language (or annotation, or through an idiom in an existing language).
  • Aspects are wrapped 'before', 'after' or 'around' methods. For example we...

Author image

Thread Pool


A thread pool is a software design pattern that helps programmers achieve concurrency in an optimal way. By maintaining a pool of threads ready to execute at any moment performance is increased and latency is minimized by keeping a set of threads always resident in a pool; at the ready, instead of frequently starting them up and destroying them because of frequent brief tasks. Thus we avoid short lived threads which break concurrency speedup.

All this because creating and destroying threads takes a longer time than keeping them constantly alive and waiting.

Design

  • there is an array of threads - m_pool
  • there is a FIFO queue of tasks (a Task should be a wrapper for a Callable object) - m_tasks. Tasks are enqueue()ed into the task queue
  • all...

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.

1 2 ... 6