+ 1

Proxy pattern broken

Hi First and foremost request is the feedback on my implementation of proxy pattern implemented below for lazy loading. One additional question I have is about the proxy Class doing stuff fine for us , but what if user directly create the real image class object.? How to stop this accidental break of wrong Class object creation? https://sololearn.com/compiler-playground/ck4g81fjBLhc/?ref=app

12th Feb 2025, 7:54 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
1 Réponse
0
This is also a wrong implementation I belive.. If we create different object of the proxy class , it still loads image from disc. I thought I will set real image constructor as private and have proxy class as friend class to allow private access. But seems like proxy already fails to cache the objects.
15th Feb 2025, 2:59 PM
Ketan Lalcheta
Ketan Lalcheta - avatar