Skip to content

Instantly share code, notes, and snippets.

@tiffany-taylor
Created July 3, 2020 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiffany-taylor/21267db87c06c912c326792856c96b82 to your computer and use it in GitHub Desktop.
Save tiffany-taylor/21267db87c06c912c326792856c96b82 to your computer and use it in GitHub Desktop.

I have, what I think is an architecture question, but I'm not certain. I have a project that I built a while back, the code was ripped from another project, and I don't understand some of the design decisions. I'm wondering if someone could help explain it to me, or point me in a direction where I can learn myself. I have a class which sets a URI in a separate class. From this line of code, a method from another class is called, which requests the HTML from a given URI. This method creates an Amp Request object, and calls a method which makes a request using the Request object. The makeRequest() method checks that a status code of 200 is returned, otherwise an exception is thrown.

What I'm confused on is why a separate class is created where the URI is set, and the Request object is created when requesting HTML. How's it better than creating a Request object in a bootstrap file which passes the URI in as an argument, and then pass the Request object is passed into makeRequest(), from the bootstrap file? Is it done this way because of Amp? Or is there a design reason for doing it this way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment