paint-brush
Mastering the Singleton Design Pattern in APIs: When to Use and When to Avoidby@piyushtripathi
1,641 reads
1,641 reads

Mastering the Singleton Design Pattern in APIs: When to Use and When to Avoid

by Piyush Tripathi4mMay 18th, 2023
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

The Singleton Design Pattern is a way of making sure that a class only has one instance and can be accessed globally. In Python, you can do this by making a class with a private constructor and a static method that returns the instance. This is great for things like database connections or settings where you only need one instance. When it comes to testing, singletons are a big no-no. They create a tight coupling between classes.
featured image - Mastering the Singleton Design Pattern in APIs: When to Use and When to Avoid
Piyush Tripathi HackerNoon profile picture
Piyush Tripathi

Piyush Tripathi

@piyushtripathi

I have over 10 years of experience in the IT/Computer industry as an Engineer.

0-item
1-item
2-item

STORY’S CREDIBILITY

Opinion piece / Thought Leadership

Opinion piece / Thought Leadership

The is an opinion piece based on the author’s POV and does not necessarily reflect the views of HackerNoon.

Guide

Guide

Walkthroughs, tutorials, guides, and tips. This story will teach you how to do something new or how to do something better.

Code License

Code License

The code in this story is for educational purposes. The readers are solely responsible for whatever they build with it.

L O A D I N G
. . . comments & more!

About Author

Piyush Tripathi HackerNoon profile picture
Piyush Tripathi@piyushtripathi
I have over 10 years of experience in the IT/Computer industry as an Engineer.

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite