DEV Community

Bertil Muth
Bertil Muth

Posted on

Frequently used design patterns

Which patterns do you use the most? In which context/what for?

Latest comments (10)

Collapse
 
kayis profile image
K • Edited

Components, for custom/aggregate UI elements and factory functions to create them :D

Collapse
 
bgadrian profile image
Adrian B.G.

Just a reminder, "most used" does not mean that they are used correctly, or they are the best solution :D

Collapse
 
rcosteira79 profile image
Ricardo Costeira

This. One of my greatest fears is will end up suffering from "design patternitis". I've had situations where the first solution I thought was to use some pattern, but later ended up not implementing it due to the impact on both performance or code complexity. Nevertheless, knowing the pattern helped me reach a better solution, so there's that.

Relevant link: jono.woaf.net/design-patterns/

Collapse
 
bgadrian profile image
Adrian B.G.

I think that if you go the other way around is better. Work your problem, and if in the end the solution ressemble a common pattern then you have a guideline how to implement it.
Your business logic is important, not the patterns.

Thread Thread
 
rcosteira79 profile image
Ricardo Costeira

Yes, I completely agree with you :) I was just talking about my own experience. I usually end up doing what you said, but it is quite common for me to easily recognize a pattern use case before starting any kind of implementation, and hence my fear.

Collapse
 
rcosteira79 profile image
Ricardo Costeira

It really depends on the domain. The ones I used the most until now are:

  • Singletons for core entity access (maintaining a database connection or a thread manager, for instance);
  • Thread pool for thread managers;
  • Observer and iterator (ReactiveX is awesome);
  • Facade and repository for data access;
  • Adapters for, well, adapting classes to interfaces (used them a lot on Android);
  • Builders and factories for objects with many different parameters and versions;
  • mvp and mvvm as architectural patterns;
  • Strategy and template method because I hate seeing a lot of ifs and switches :)
Collapse
 
creativ_bracket profile image
Jermaine

Mixture of Factory for building different objects and Strategy in the context of writing pipeline logic as a means of reducing boilerplate from switch and if statements.

Collapse
 
remify profile image
Rémi B • Edited

Great mix for "Workflow" like processes.

Collapse
 
sergeytelpuk profile image
Sergey

Model–view–controller is an architectural pattern

Collapse
 
rohithmenon89 profile image
Rohith Kunnath

Builder Pattern mostly used instead of typical getter/setter boilerplate codes. Gives me a clear idea on properties which are mandatory and optional. Really likes the way it helps a shareholder understand by just reading a couple of lines.