views:

99

answers:

3

Background: My organization uses Microsoft .Net (3.5) with SQL Server 2005 as back end.

With RAD being the norm and Agile being the widely used process. I have always found using design patterns difficult since it involves a bit more understanding and bit more training.

Can you give me some examples where design patterns have solved real time problems in Web programming? What is the criteria for using any design pattern? What is the benefit reaped from it.

I know it is a general question but this would help me a bunch.

+1  A: 

Design patterns are both an answer and a way to communicate ideas. One of the best ways to understand the benefits is simply to do some reading on the basic patterns and then look back through you own code, APIs you make useful and other code and you will find many instances of those patterns being applied. Simply because thats what they are, a distillation of common applied solutions to problems.

Derek Clarkson
Could you tell me what patterns you have used?
Raja
Lots. Quite a few without knowing it. If you are the sort of programmer who looks at his code and thinks "There's a better way to do this", then goes looking through APIs for design ideas, then you will have been using them too.A good outline of the basic patterns is near the bottom of this page: http://en.wikipedia.org/wiki/Design_PatternsThere are plenty of others, but mostly they are people just trying to make money from combining these basics and calling them new.
Derek Clarkson
Thanks Derek :-)...I especially loved the last part (lol). I went through that link and even though I have not used it per say I have used a lot of its concepts (Decorator, Factory, Strategy and Observer). Its nice to get honest opinions from experienced people :-).
Raja
+4  A: 

Here's a little bit of a different approach that might help you on your quest. Learn the patterns as a way to see examples of good design instead of only looking for places where a specific pattern can be applied. I believe understanding why patterns are good designs is the key to using them effectively. As a start, Factory Method, Strategy and State are easiest to learn and probably most commonly used correctly. Once you get the hang of those patterns and the principles that make those patterns good designs you can move on to more complicated patterns that might be more useful in your web app such a Model-View-Controller, Abstract Factory etc.

derdo
Very interesting observation and it makes pretty good sense. thanks :-)
Raja
+1  A: 

There are a number of patterns I've seen:

MVC/MVP - This comes up often in doing forms where there is the need to handle business logic separately from the UI and the domain objects are a third part to this.

Adapter - Database connections can use this part so that one doesn't have to know what kind of DB connection there is, it just works.

Strategy - Ever have different ways to perform what is almost the same operation on different types of devices? I have and this is what I used was a simple Strategy pattern.

Singleton - Ever use the Application object in ASP.Net? That's an example of the Singleton pattern in use.

Factory - This kind of goes hand in hand with the Strategy case I mentioned earlier as the Factory may produce a specific type of object that is needed and I remember seeing this back in classic ASP 6 years ago now.

The pattern is a way to solve a specific type of problem in rather general terms, thus there are lots of grey shades in understanding when to use this one or that one.

JB King