Some OOP code I've seen, uses global functions to obtain data or return an object. For example, in Laravel we have functions like app()
, config()
, view()
etc.
Is it considered a good practice to create global functions in addition to/instead of injecting dependencies? What are the benefits and what are the drawbacks?
Aucun commentaire:
Enregistrer un commentaire