Now I'm developing a c++ application and I'm facing a problem of sharing an instance.
For this problem, I created a simple class diagram. I want to share HogeDataManager for class A and C. A creates HogeDataManager and read HogeData via its public methods. And B adds some data to HogeDataManager.
For sharing HogeDataManager, I have to prepare set_mgr method for B and C. But I think it is not a smart way. Of course if I adopt Singleton pattern, it will be resolved. But Singleton is sometimes dangerous, so I want to find better ways to avoid such a problem.
Aucun commentaire:
Enregistrer un commentaire