-->
Showing posts with label Patterns. Show all posts
Showing posts with label Patterns. Show all posts

12/10/2018

Microservices Introduction - Monolith Vs Microservices

This post is a beginning of a long series which will cover Microservices, Devops, Containers, Dockers and many other futuristic concepts.

All these concepts are vast and range from simple to complex implementations. So let’s take it slow.
We should learn about Monolith application before learning about Microservices.

Monolith Application

This is the regular way of application development we followed earlier. Typical 3 tier application with Presentation Layer, Business Layer, Data Access Layer. Below image explains what we call a Monolith application.

11/06/2012

MVC - DI & Unity with Lifetime Manager


In this post we will see 2 important things.

1. Using Unity Dependency Resolver
2. What is Lifetime manager and its significance.

23/02/2012

Structural Pattern : Decorator Pattern Demo


Decorator Pattern can be defined best by below Image.
Before going into details lets go through the text book definitions and UML diagrams first.

Definition:
Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to sub-classing for extending functionality.

16/01/2012

Behavioral Patterns - Observer Pattern

Lets not follow the text book definition of Observer Pattern.
Start with OO Principles.
OO Principle says, "Strive for loosely coupled design between objects that Interact".
Loose coupling brings the flexibility and resilience in system.

Lets take Facebook notifications as an example.
When there is any changes in my profile or wall , it will be automatically notified to my friends.
In this case, i am the subject and My friends are Observers. My friends list may vary. People may be added or removed from the list. But the system should be flexible enough to communicate the information despite of the change in observers list.

23/12/2011

Singleton Pattern : Load Balancer Demonstration


Singleton Pattern : This is a pattern which is widely used when there is a situation to create only one instance of a class.

Lets demonstrate the pattern using a simple example.
Earlier i used to wonder how load balancer servers work. So, i decided to write an application to demonstrate both the things in one go.

11/12/2011

Structural Pattern - Adapter Pattern - Object Adapter Pattern



I am a big time fan of Animation movies and cartoons.
I love cartoons like Calvin & Hobbes, Tom & Jerry; Animations like Shrek, Kung Fu Panda (Poo).
So, lets see how these characters will teach us Adapter pattern. :)

09/12/2011

Behavioral Pattern - Chain of Responsibilities Using Extensibility Framework


"Change is good and Inevitable", this is what i said in my earlier post.
But not all changes are good. That is why we have Change management system in place in IT.
Because some changes will be like this :

30/10/2011

Custom Controller Factory & Structure Map - MVC Razor


Oww.... wait, why i have to go for Custom Controller Factory ? 
Error shown in earlier post "Default Controller Factory Vs Custom Controller Factory"  is lack of default constroctor. So, i will add one parameter-less constructor. That is it. Problem solved. :)

Sorry, now you have created a bigger problem. Let me show you how.
If you understood the article "Dependency Injection", you will observe the flexibility (Loosely coupled) we achieved because of that.

16/10/2011

Builder Pattern

Developers have observed that, composing a system using inheritance makes it too rigid.
Creational Pattern is a way to break that tight coupling by abstract out the object creation.
The Creational patterns aim to separate a system from how its objects are created, composed, and represented. They increase the system's flexibility in terms of the what, who, how, and when of object creation. Creational patterns encapsulate the knowledge about which classes a system uses, but they hide the details of how the instances of these classes are created and put together.

Lets start this pattern with a hot snac. "Pizzaaaa . . . "
 Even though i am a non vegetarian, i love "Veggi Delight" than any other flavor. I know its very hard to discuss a design pattern keeping this picture in front of you. But lets stick to topic.
There are lot of variations in Pizza, different sizes, there are different types of bread doughs(base), different types of sauces , different types of toppings that can be used to prepare a pizza.
Now let's cook a pizza in c# mode.

10/10/2011

Dependency Injection (DI / IOC)


"Loosely Coupled" is the one of the basic qualities of a good design.
Let me justify that first.
If you have 2 choices:
1. A task which has lot of dependencies on others.
2. A task which have Minimum number of dependencies.
Which one will be easier. Obviously its #2.
So, less dependencies means more loosely coupled and better the design it will be.

I believe 80% of world population know below Guy.
He is Harry potter with a Magic Wand (stick in his hand), which he will be using to cast the spell.
Now lets watch the potter's magic in a console application using c#.

02/10/2011

Abstract Factory Pattern

Let me begin with a proverb, "Change is Inevitable & Good." If you are not ready to adapt to the change, you will not survive. Same case applies to our software as well.

Like many of us, I am a big time Fan of PC Games. So, i thought of interpreting the usage and implementation of a pattern on the same lines.

I love "Company of Heroes" game. It has awesome UI and whole lot of Gadgets and i had great time playing it.
Look at UI once.
If you closely observe, there are Cars, Tankers, and Flights. In fact there are different types of each kind.
Now, lets say i have Scenario, where i designed this kind of a game (Lets Assume ;))
I have to handle all these kinds of vehicles say, Tankers. Tomorrow, i got a complain that, the tankers are not efficiently attacking the Aircrafts. Now, i have to categorize Tankers into 2 different types.
1. Ground Tankers.
2. Air Tankers
Tomorrow, there may come another type. And my code should be open to implement any new kind of vehicle that may creep into scope in future.

So, in order to handle families of related and dependent objects, we use "Abstract Factory Pattern".

Coming to Game, when the user starts the game, i have to give him the following vehicles to start off.
1. Soldiers Car
2. Officers Car
3. Passenger Aircraft
4. Soldiers Aircraft
5. Land Tanker
6. Air Tanker.

03/09/2011

Page Controller Vs Front Controller Pattern

How do you best structure the controller for moderate / complex Web applications so that you can achieve reuse and flexibility while avoiding code duplication?

MVC has been a tried and tested method of structuring your applications for a long time. Generally MVC mainly focuses on separating model and view and less attention on the controller. Specially in rich client applications the view and the controller tends to lie close together. But in web applications this separation is more critical since the view is essentially happening at client side (browser) while the most of the controller sits in the server side.
There are 2 basic ways of structuring the 'C' of the MVC, i.e Controller. The 2 basic methods are the Page Controller method and the Front Controller method.