GithubHelp home page GithubHelp logo

Comments (2)

Anubarak avatar Anubarak commented on August 16, 2024

Maybe it's a good idea to take a look at Pixel and Tonics easy and clever solution for this problem in their services, helpers, elements and so on.

They mostly don't use it.

There are only a few uses of the request component in their code because that's the "correct" design pattern of an MVC. The controller should handle the request and the controller knows what kind of request it is - because you separate them in console and web controller. After your controller handled iti you should ry to avoid relying on it too heavily.

When you only pass the variables you need you won't get in trouble. Besides that you should check what kind of request you have in order to use the correct response component.

If your code end up with those if conditions all over the place maybe it's worth the rethink the design pattern (not talking about you in particular, just in general way)

Don't get me wrong - I can totally understand your point and I got to deal with it too in the past but when you structure your classes in a certain way from the beginning you won't have that much to worry. Of course it's "easier" to grab variables from request nearly everywhere instead of passing them all the way to the service but it's sometimes the cleaner approach

from docs.

timkelty avatar timkelty commented on August 16, 2024

@Anubarak Yep, agreed with your points.
In my case I'm mostly fighting against this not in my own code, but in plugins I'm using.

So, I think whatever the solution is, I think something in the docs specifically advising devs would be ideal.

from docs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.