samedi 26 septembre 2015

2 small questions regarding larvael facades

I know it's an issue with a lot of debate, but there are two issues about it that I haven't seen much reference to and would like to know the answers to:

  1. We're using static functions all the time - I'm sure no one will ever stop using dd() helper for example, but obviously even pure php static functions like json_encode() or array(). Why doesn't it make sense to see laravel classes behind facades as similar helper functions and not as class dependences?

More than that, many times we're using those "dependences" in a narrow control flow (or conditions) inside the method and the class\method is truly not necessarily dependent on those helpers all the time (for example user class used only if user is authenticated etc.)

  1. In his response to this debate, Taylor Otwel himself said that the use of facades may lead to "responsibility bloat in your classes" meaning we might be tempted to write classes\methods that do too much and not separate them - but I don't understand how using facades instead of injecting all those classes in the contractor or method is different in terms of responsibility - from what I understand it's just a change in where you "declare" those classes - in the method signature or inside it (I understand that has a lot of differences, but don't see one in class responsibility matter). Can someone explain this?

Bottom line I'm asking this because obviously I'm all for facades when they serve as helpers and not as a core part of the class\method purpose, and I want to know I'm not the only one... I'm mostly anxious of having to write every little piece of helpers I'm using as dependences in my classes.

Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire