Made by Itchimonji

Programmers try to avoid switch statements because switches are breaking the rule of the Open-Closed-Principle. Also, continuously extending the switch statement with more clauses leads to a high maintenance effort, as you need to modify the written code every time you extend it. Maybe your working unit-tests will fail after…


Based on my story Inheritance & Object Composition I want to show you, how you can use some Angular features for reusing code in really nice ways. I prepared some easy examples below.

Inheritance

Inheritance is a very simple principle in Angular. You can combine a base class with a superclass…


A Mediator controls the interaction of different object groups. A real life example is a chat room in which different users write to each other. The chat room or server is the Mediator object that manages users and distributes the messages to different clients.

The pattern helps to loose coupling…


Nowadays, a State can be found in a lot of application architectures: Web page state, database state (set of stored data), or stateful sets like MQTT — shortly explained, the entire content of its memory, e.g. all its variables, objects allocated, or open network sockets.

The pattern describes how changing…


The Iterator pattern is very helpful when encapsulating an aggregated object and providing sequential access to its elements. Shortly explained, you can not simply manipulate an array by copying, adding, or removing elements without an intermediate layer. In most cases a polymorphic iteration is supported. …


Chain of Responsibility avoids the coupling between sender and receiver of a request. For this, multiple objects can take part in the process. The whole thing can be thought of as a one-time iteration of a given sequence, which can be variable. Objects are chained together and the request is…


Strategy is often used when wanting to switch between different algorithms or behaviour at runtime. Decoupling the logic makes this change very simple and elegant, and also allows easy expansion with new algorithms.

At the end there is an emergence of a family of related algorithms. Strategy is one of…


Template Method is known as one of the cleanest inheritance techniques. The pattern is defined by setting the basic structure of an algorithm in an operation and delegating flow steps to subclasses. This allows the subclasses to override certain steps of an algorithm without changing its structure. …


Often a Proxy controls the access to another object. Intermediate layers that control access to a database are a well-known example. The pattern distinguishes between Remote Proxy, Virtual Proxy, and Protection Proxy. …


Flyweight is also known as Cache and often found in the computer gaming section when sharing various GUI elements in order to save memory. It is defined by sharing fine-grained objects to efficiently deploy and reuse them in a large number.

Sometimes there may be runtime penalties associated with transferring…

Itchimonji

Full Stack Software Engineer | Trained Mathematical-Technical Software Developer | Writer at CP Massive Creative

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store