C# Corner Mumbai Group Team Party Meeting on most used Design Patterns

Where did all start from?

The whole idea was initiated by "Mahesh Chand" sir and "Dhananjay" sir.  The whole thought was that in today's world with growing internet and the kind of knowledge base which is available on the web , developers rarely connect offline. 

With due respect to the online world we cannot under estimate the power of meeting offline, getting connected, knowing people by faces  and talking to them personally gives you a different feeling which cannot be communicated via  electronic faces posted on facebook, twitter etc. That's what this small Mumbai tea party meeting was all about.

Things started shaping up

I was completely bought in to the thought of meeting developer's offline and discussing on a topic and concluding / exchanging thought process.   After a lot of thought we decided on a topic i.e. "Most used design patterns". Thanks to Praveen he posted the announcement on c# corner and my mobile started ringing with calls and interest (http://www.c-sharpcorner.com/News/1242/mindcracker-mumbai-chapter-meeting-announced.aspx) .


People started calling

I had received like 15 or more calls but some of them I was not able to turn back and some of them did not turn back on the meeting day J.  First a big apology for people whom I was not able to revert back. I can post to you the below design pattern cup to your location as a sorry gesture from my side (Only Mumbai for now).


It was a destiny of 4 people to meet

So the meeting finally started with 4 enthusiastic developers including me starting from the left Kamal sir,  Akshay sir, Swapneel sir and me.


GOSH what a contrast between me and Swapneel sir one is hairy and the other is J .



Mr. Kamal sir first started the fire stating that Singleton is the most used pattern. This was also backed by Akshay sir. For some reason I had a thought that Singleton is definitely most used but it's also over used and is now favorite as an anti-pattern.

We also discussed that sometimes you really do not need singleton like in ASP.NET web application where you have cache and application objects, how  does singleton benefit ?. Said and done we cannot use cache and application objects in windows application, comparatively singleton has a wide reusability across technologies.

So the one pattern which added to our list was "Singleton Pattern".



The next pattern which came out was the factory pattern (I am not sure it was initiated by whom but I think it was Swapneel sir). We discussed how factory pattern is good for decoupling and can serve as a middle man between UI and the BO and the BO and the DAL.

You can also watch my video on factory patterns from factory design patterns

So one more pattern to our list was "Factory Pattern".



The next pattern which was added to list by Swapneel was decorator pattern. Decorator helps to  add dynamically stacked behavior thus helping us to change the behavior of the object on runtime.. He talked about his experience where he needs to create various schemes in a plug and play manner. You can have Scheme 1 which has plan 1, plan 2 and plan3, but then you would like to create scheme 2 which is combination of plan1 and plan2.

We also did a small demonstration of how we want validation to be plug and play with combination depending on different situations. You can see the screen we demonstrated at the right hand side using decorator pattern.

One more pattern added to list "Decorator pattern".


The final pattern we talked about was "Iterator pattern" which helps us to browse elements of a collection in an encapsulated manner.

We also discussed shortly about design patterns like observer (the publisher and subscriber model) and mediator  pattern. Below is a simple indicatory diagram I have created to visualize which patterns go where. This is just an indicatory diagram, design patterns will have 100 other situations where they will fit in other than the one shown below.


Later we also spoke about how senior management and customer over look design patterns and sometimes due to project deadlines we need to sacrifice all good things and just complete the project with clumsy code.




Conclusion and what next

Due to time constraint we did not talk about other patterns. So the conclusion for now is that below patterns are the most used (Many people will have different thoughts about what we concluded, but I personally think learning is a ongoing process): -

  • Factory
  • Singleton
  • Decorator
  • Iterator

The next step is to demonstrate these patterns online through some webinar. We are also planning some important webinar and meets on common topics like estimation, coding standards, writing good requirements etc.  We have lighted the candle; we would like other people to make it a fire.

Where many of those communities are talking about new technologies it's time to talk about common things we do every day and mature on the same. In todays scenario 5% people are excited about learning Azure (no offense) and on the other side we have 80% developers still struggling with simple OOP concepts.

Do you have topic which is important for common developers and professionals, let us know, we can talk.

Courtesy: - http://www.mumbailocal.net/

I have my own small training company, you can see my 500 videos on Design patterns, UML, SharePoint, VSTS, SQL Server, C#, .NET, ASP.NET etc and lots more.