what is singleton pattern in Object-oriented programming (OOP)

in programming •  6 years ago 

Hello programmers , i'm new in Field of programming. When i was learning oop i meet this term "singleton pattern" and i don't understand. Please if there is any programmer that know this term please comment below and thx for your help 😊

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  
  ·  6 years ago (edited)

A creative usage of a post, indeed!

You can find the correct answer on wikipedia, or in a book about design pattern, if you can afford it (like the GOF)

A singleton is basically a globally unique instance of a class.

The class must be written so that it isn't possible to create new instances; instead, the only thing you can do is to take the only instance of that class. You must also disallow copying, or destroying, the instance.

The pattern part refers to how you actually implement such a thing in a language, a sort of recipe which you can use to achieve the goal.

thx what type of programmer you are ? game programmer ? or web programmer ? android programmer ? or something else ?

I mainly do back-end stuffs; no game, no web, no android: servers which provide services/API which aren't exposed in the wild.