Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This may be a inappropriate question, but I\'m really need help demystifying thi

ID: 647368 • Letter: T

Question

This may be a inappropriate question, but I'm really need help demystifying this.

Suppose we want to create web application like reddit or Gmail. The way I understood it from my research is that there are two ways to approach this problem.

1) Web application like reddit can be created using PHP only. HTML for the front-end will be rendered by PHP on the server and application logic will also be written in PHP on the back-end side. With this method, web application would not feel "real-time" since for any changes you would need to refresh the page.

2) Create RESTful backend in PHP and use JavaScript frameworks like backbone.js to create single page web application and manipulate the HTML on the front-end. Front-end written in javascript would send requests to back-end which would only return JSON packages (no HTML). On the front-end, Javascript should decide how to manipulate the front-end based on the JSON packages returned from the back-end. With this method, web applications would be real-time.

What is the advantage of using method 2 over method 1? I read that Gmail is implemented using method 2. Why did they use javascript frameworks to create the front-end, if they could send HTML rendered on the back-end side and make AJAX calls to check for notifications?

Is it generally better to use method 2 over method 1? Server-side page rendering or client-side page rendering?

Thanks in advance!

Explanation / Answer

The reality is that a modern web application (not a web "page") has a lot of moving, interactive parts. That means there's going to be some Javascript, and perhaps a lot of it.

This means that if you go the first route, you will be "complecting" the Javascript front-end code with the back-end code.

If you go the second route, you will be separating your concerns and making it possible for the back-end and front-end to vary independently.

As a general rule about software architectures, in fact, the second route is preferable. Loose coupling and high cohesion are more easily achieved by separating your concerns properly, which is what the newer design methodology will provide.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote