Continuing with the design pattern fun, lets talk about one of the most commonly used pattern, Singleton and an alternative called Monostate. I too wrote about singleton pattern relative to Joshua Bloch’s Effective Java a few days back. The Basic Difference in Two Well what is this monostate we talk about? Monostate is very similar to a singleton and you may call it a conceptual singleton. The basic difference between the two is that- Problem with Singleton – The intent ...
People have been appreciating the effort I am putting in each post these days. Feels good. Moving on with another design pattern, we have the ‘Factory Design Pattern’. It is also known as the Simple Factory Design Pattern. There exists a very similar pattern named ‘Abstract Factory Design Pattern’. The difference between the design patterns will be discussed once I post about Abstract Factory Design Pattern in my next post. Lets use the Factory Design Pattern to solve a simple ...
As I mentioned in my previous example for Strategy Design Pattern, that the design patterns are best understood with examples. Without wasting any more time, I’ll just define our simple problem. Problem: We have a newspaper say, “GlobalTimes” (fictitious name). The newspapers usually have many readers. Now, the problem is to notify the news readers of every news that is published in the newspaper. Design: Here, one solution to the stated problem is to use a producer/consumer model, where the ...
Design patterns are better understood when we try learning them with an example. Lets take up a problem here. Problem: Lets say there are Animals which can fly and those which cannot. Since, the world is constantly evolving, any animal can be given the ability to fly by nature, or the ability can be taken from the animal. Design: The problem that the great mathematician ‘Nature’ faces here is, ‘How to incorporate a new behavior of flying within the present ...
So, here is an extensible API for complex validations. I’ve written a small piece of code for common validations. The code can be extended to introduce more complex validations. Highlights – Builder Pattern Extensible code Non-instantiable Validation class Used a variety of concepts I discussed in the past month Here is the link to the github respository. Do check it out. https://github.com/73ddy/poc_trunk