Welcome Guest, Not a member yet? Register   Sign In
Why is it not recommended to use services in models and libraries?
#5

(11-04-2023, 09:05 AM)semprom Wrote: Why is that not recommended?

If you call Services in your class, the class depends on Services.
It means the class does not work at all without Services.
If you use the class, you must provide Services for it.

But if you inject the needed Service instance (not Services) into your class, 
you can use the class anywhere without Services.
It is more portable, and clean.
Perhaps it would be a little slower with Services.

However, Services is relatively simple because it is simply static methods to return Service instances.
So it will not be a major problem.
Reply


Messages In This Thread
RE: Why is it not recommended to use services in models and libraries? - by kenjis - 11-04-2023, 08:38 PM



Theme © iAndrew 2016 - Forum software by © MyBB