Skip to Content
Nov 19, 2020 at 07:13 AM

Is it a non sens to use SingleTon on Factory Design pattern ?


Hi team,

I am currently working on a big project, for this project I have created several class (maybe more than 10). All these class have their own responsibilities.

To avoid dependencies between all these class, I have used Interfaces (obviously) and 2 Factories (because I have two main separated block of logic).

Two of these class are SingleTon because I absolutly need to have the same memory area. For example the log. During all the process I have to populate the same log.

Now the process: My process occurs in several part of user-exit & Enhancement of the VA02 transaction. There is no BADi, so no simple way to share memory.

My main problem: During the usage of these tool, there are a lot of Instance creation (yep a lot), these as a possible effect on the performance and memory. I wonder how to reduce these multiple instance creation of the same object.

And I wonder if in the Clean Code & Design Pattern word, it is a non sens to create the Factory class as SingleTon & to keep in these instance the instance previously created ?

If a part of the code need anothere instance of an already created object, it is needed because the instance as a specificity, so the Factory could manage these.

What is your feeling about that?