C
CB
I have what must be a very common design issue in web programming, probably discussed 2000 times already, but I can never find any mention by searching. In particular
I have a web page with a form, which is posted to the server when the user is finished. The next stop for the user might be a return to a list, or it might be to refresh the form, depending on circumstances. Which of the followng is better programming technique
1) Post the form data to an intermediate script which handles the database update, and then issues a response.redirect to either the list or the original form depending on circumstance
2) Decide on the next stop using javascript on the client side, and post the data directly to that location -- either the script that generates the list, or the script that generates the form. Use an include directive at the top of both scripts to pull in the code that does the database updating (a big subroutine in a separate file). Each script decides whether an update is needed by checking posted data, if any
In the old days, IE used to give an annoying alert with any redirect, killing option (1), but now that seems to have changed. So the main disadvantage of (1) seems to be extra traffic to and from the client and maybe a bit of latency
The main disadvantage to option (2) seems to be that more code needs to be compiled for the list script and the form script, an extra 300 lines, even though an update might be required less than half the time either script runs
As I understand how ASP works, a script and all its include files are compiled the first time the script is hit, and they stay in memory for a while, so they are not recompiled every time. So the cost of extra lines of code would be more to compile the first time, and a bit more memory consumed. But how much? Is the difference trivial, or something to worry about
At one extreme, an ASP-driven website could consist of just one url, one file, which pulls in all the rest of the code with a long set of includes, and decides which code to execute and what to present to the user based on information in the request. At the other extreme, code can be atomized into dozens or hundreds of single-purpose files, and volley the user to the right next page using response.redirect. From a pure server performance standpoint, would either extreme be the best type of application design? Or is the best somewhere in the middle?
I have a web page with a form, which is posted to the server when the user is finished. The next stop for the user might be a return to a list, or it might be to refresh the form, depending on circumstances. Which of the followng is better programming technique
1) Post the form data to an intermediate script which handles the database update, and then issues a response.redirect to either the list or the original form depending on circumstance
2) Decide on the next stop using javascript on the client side, and post the data directly to that location -- either the script that generates the list, or the script that generates the form. Use an include directive at the top of both scripts to pull in the code that does the database updating (a big subroutine in a separate file). Each script decides whether an update is needed by checking posted data, if any
In the old days, IE used to give an annoying alert with any redirect, killing option (1), but now that seems to have changed. So the main disadvantage of (1) seems to be extra traffic to and from the client and maybe a bit of latency
The main disadvantage to option (2) seems to be that more code needs to be compiled for the list script and the form script, an extra 300 lines, even though an update might be required less than half the time either script runs
As I understand how ASP works, a script and all its include files are compiled the first time the script is hit, and they stay in memory for a while, so they are not recompiled every time. So the cost of extra lines of code would be more to compile the first time, and a bit more memory consumed. But how much? Is the difference trivial, or something to worry about
At one extreme, an ASP-driven website could consist of just one url, one file, which pulls in all the rest of the code with a long set of includes, and decides which code to execute and what to present to the user based on information in the request. At the other extreme, code can be atomized into dozens or hundreds of single-purpose files, and volley the user to the right next page using response.redirect. From a pure server performance standpoint, would either extreme be the best type of application design? Or is the best somewhere in the middle?