Skip to main content

4 posts tagged with "Patterns"

View All Tags

· 6 min read
Adnan Rafiq

What is an Adapter Pattern?

The Adapter Pattern connects two incompatible objects by exposing an interface compatible with the Client. The object refers to a class, web service, REST API, process, or physical device depending upon your context.

Consider a C# Web Application displaying Weather Updates on its landing by utilizing the third-party REST API.

In this application, there are three participating objects in the Adapter Pattern:

  1. A Weather REST API (Adaptee) has the functionality of weather updates. The Weather REST API only understands JSON.
  2. The C# MVC Web Application (Client) displays weather updates on its landing page using the Weather Web Service.
  3. The Adapter enables the Client to utilize the Adaptee functionality. It does that by doing two things:
    1. It converts the Client's input to the format acceptable to Adaptee i.e. JSON to C# Object(s).
    2. It converts the Adaptee's output to the format acceptable to the Client i.e. C# Object(s) to JSON.

· 4 min read
Adnan Rafiq

What is Cache Aside Pattern?

It enables you to improve application performance by reading the data from the cache-store (Redis, Memory Cache) instead of the persistent store (database) or an integration service.

· 5 min read
Adnan Rafiq

What is Template Method Pattern?

Template Method Pattern executes multiple same steps in the same order and allows consumers to change the behavior of the steps.

“Implement the invariant parts of an algorithm once and leave it up to subclasses to implement the behavior that can vary.” Elements of Reusable Object-Oriented Software.