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?