TinyDB--Android-Shared-Preferences-Turbo
TinyDB--Android-Shared-Preferences-Turbo copied to clipboard
Implementing Singleton Pattern
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)
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.
Upvote!
https://github.com/kcochibili/TinyDB--Android-Shared-Preferences-Turbo/pull/22/commits
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..