أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.
Tell us about one design pattern you have used before.
I like the way Umar Alharaky referred to it as recurring solutions. Design Patterns apply to just about any problem area and could be based on coding, visual design, building and other problem/solution processes.
Typically after some time certain design patterns settle as the norm for solving a specific type of problem within a given set of circumstances, until of course the conditions or environment changes.
I believe a certain amount of this also follows development trends and some patterns are merely trends which die down. Other design patterns are so fundamentally apt that they stick and almost never change in the fundamental ability to solve a given problem.
Design patterns are architectural and code templates for how to solve a problem that can be used in similar situations. It's about reusability. Instead of re-inventing the wheel, you can apply a general design that addresses a recurring design problem. It describes the problem, the solution, when to apply the solution, and its consequences.
There are several famous ones such as MVVM, MVC, Producer-Consumer, Factory, Singleton, Facade, Decorator, Adapter, Iterator, Proxy, Composite, Abstract, Bridge, Builder, Prototype, Observer, State and State Machine, Visitor.
In fact, we use them on a daily basis even if we are not aware of it. They can be used alone or in combination. But they are not the ultimate universal solution to all kinds of problems.
Sometimes a generic implementation can lead to a lot of overhead which may lead to an inefficient solution.
For example, it would be better to use a for loop instead of using an enumerator for single dimension arrays because it'll be much faster.
Also a better way to create an instance of a type is by using DynamicMethod rather than using Activator.CreateInstance. etc.
In simple words design pattern specifies how the objects in an application are structured and related to each other. i.e dictates the arrangement of objects in a particular context. there are many design patterns available each suitable for unique and different kind of problem. singleton pattern is best used for db deriver class when only one instance for db connection required. strategy pattern helps us to make decision which class need to be instantiated depending on the context. factory pattern, as the name suggested a class designated as factory to deliver various king of objects...