TinyDB--Android-Shared-Preferences-Turbo icon indicating copy to clipboard operation
TinyDB--Android-Shared-Preferences-Turbo copied to clipboard

Implementing Singleton Pattern

Open alisherafat01 opened this issue 8 years ago • 4 comments

Hi, i was thinking that why you haven't implemented singleton pattern for this utility class, so that we can load this class just one time in whole application. is there any special reason? (i know that built-in shared preferences object uses singleton pattern by default)

alisherafat01 avatar Dec 05 '16 14:12 alisherafat01

That is a good idea. I initially did not do it because I didn't know about singleton at that time, and I didn't feel the need to add such behavior. I will explore the possibilities, and add it if it doesn't break the simplistic idea I created this project on.

kcochibili avatar Dec 08 '16 19:12 kcochibili

Upvote!

iRYO400 avatar Mar 28 '17 11:03 iRYO400

https://github.com/kcochibili/TinyDB--Android-Shared-Preferences-Turbo/pull/22/commits

alisherafat01 avatar Mar 28 '17 12:03 alisherafat01

Singleton pattern is mainly used for objects that hold data that is needed across the application. Tinydb currently does not hold much data, its more like a messenger to the default android Shared Preferences.
That is why I have not yet merged the pull request. Expand my view/understanding, if you think i'm wrong..

kcochibili avatar Mar 28 '17 16:03 kcochibili