DEV Community

loading...

Name a DESIGN PATTERN and WHY u use it πŸ˜€ ?????

Sharad Raj (He/Him)
Full Stack Developer | Intel AI Edge Scholar 2019 | Google India Scholar 2018 | Open for full time opportunities
・1 min read

You got it .... let's discuss a bit more on design patterns here.....😁

Discussion (7)

Collapse
sargalias profile image
Spyros Argalias

I... Love the observer pattern.

I just find it so satisfying and elegant...

I don't use it with React because it's not needed, but with vanilla JavaScript when something needs an active "watcher" relationship to something else. Or in C# with events and delegates (which are basically the observer pattern).

Sidenote: I find it different to the pubsub pattern. For me pubsub is more like "I'll broadcast something and I don't care who is listening or why". Whereas observer seems like a more cohesive relationship to me. "This event is important, someone is exclusively interested. I'll notify them directly."

Collapse
sharadcodes profile image
Sharad Raj (He/Him) Author

Cool

Collapse
pclundaahl profile image
Patrick Charles-Lundaahl

Null object is definitely really cool!

I usually try to avoid using too many patterns - they can be really handy in a pinch, but most of my projects are pretty small, so I usually just try to pay attention to SRP and make sure things are small and composable. I've been slowly adopting more functional patterns, too, and I find that helps simplify things quite a lot.

I suppose the big one I tend to use is the façade pattern (helps with SRP). Others I've used a fair bit are Observable, along with a slightly-modified Service Locator (to get rid of the need to cast the results).

Collapse
sharadcodes profile image
Sharad Raj (He/Him) Author

That's nice

Collapse
pclundaahl profile image
Patrick Charles-Lundaahl

I haven't had much opportunity to use it, but I think the state pattern is really cool. Has anyone here ever used it?

Collapse
sharadcodes profile image
Sharad Raj (He/Him) Author

Not me

Collapse
sharadcodes profile image
Sharad Raj (He/Him) Author • Edited

My personal favourite is NULL PATTERN cause it saves me from writing extra code for handling exceptions and errors... What about u ?