Timeline for Is utilizing a singleton for a cache an antipattern?
Current License: CC BY-SA 4.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 13 at 21:36 | comment | added | Chthonic One | Also, to the person who downvoted my post, why did you do so? If it was because you believe singletons are in fact an antipattern, please explain how? One of the qualities of antipatterns is that there is another documented and easily replaceable solution to the problem. There is not for singletons. There may be different kinds of singletons or ways to implement them, but all of them are singletons, and if you need to have exactly one of them for some reason, there is no work-around. Thus is it not an antipattern. | |
Mar 13 at 21:27 | comment | added | Chthonic One | Yep. I recently reworked a library we passed out to a subcontractor to not expose any unnecessary code for our CV model selection, creation, and use. Eventually I had to settle on the factory pattern that caused so many issues for me in traceability in code in the past. They didn't need to know what model I gave them. They just told me where the models were, what size images they were going to give me, and they got one that would give them the list of bounding boxes they expected. Anything else was just way too complicated for them to deal with it turns out. | |
Mar 13 at 20:28 | comment | added | JimmyJames | To one of the points in my answer, it was really common for junior devs to learn about Singleton and then start using it for almost everything and create a big mess that would need to be cleaned up. Based on your story, I'm guessing that was the senior's experience and the immediate reaction was to push back. There are definitely times when it's crucial to have one instance, at least within a certain context. Not just 'we only need one' but there 'must only be one' or things won't work. Memory management (GC) comes to mind as an example. | |
S Mar 13 at 19:20 | review | First answers | |||
Mar 13 at 22:23 | |||||
S Mar 13 at 19:20 | history | answered | Chthonic One | CC BY-SA 4.0 |