mercredi 11 janvier 2023

Laravel Trait or extended class in regards of performance?

I wonder what is better to use in my specific case? I have built an extensive voting system that has to consider many cases. The function in which I find out the case (findCase()) is very long (>100 lines). In my service class I have other functions that refer to the output of the above function. Since my service class has now become very long, I would like to outsource the findCase() function. I am thinking of putting this function in an extra class or implementing a trait in the service class. I read in a definition of a trait that you only include traits in code that you use in different classes. In my case, however, this is not the case. I only need the function in the service class.

What would be the right approach? Trait, extended class, leave it as it is? In particular, I also have to consider the performance here.

Thanks for your time and help!

Aucun commentaire:

Enregistrer un commentaire