more useful options | |
PerlMonks |
Scaling single-script CGI applicationsby larsen (Parson) |
on Jul 08, 2001 at 16:07 UTC ( [id://94820]=perlmeditation: print w/replies, xml ) | Need Help?? |
I guess everyone has written a medium CGI application at least once.
I did it several times, each time discovering something new to make
my application more scalable.
Now I think that a single script with run-modes provide
the best framework to develop CGI.
Then I write a procedure for every run-mode I need. Using Template module I need also a template file for every type of page that my CGI application will generate (that often corresponds to a single run mode) so that I could add functionality to my application just adding a new term in my %dispatch_table and writing a proper new procedure. I fell very comfortable with this developing process. But I'm sure I didn't say anything new for most part of you. Unfortunately designing a CGI application often drives to more complicated situations, where a run-mode implies another run-mode and so on, asking the developer to pass parameter through the application, just because a run-mode has to pass them to the run-mode that will actually need them. I'll explain this situation with an example. Let's suppose we are developing a web-based forum. So there will be a list run-mode that displays every message in the forum, allowing the user to reply to a particular message. Also, there will be a form run-mode that will provide... a form to let the user insert the reply. In this form there will be a submit button that will invoke insert_message run-mode. This mode contains DBI stuff to actually insert the new message in the forum, reporting success or error to the user. Here a schematization:
What does it means? form run-mode fetches proper parameter, will pass it to the template that will probably add a hidden field to pass this parameter to insert_message mode. I think this approach is too complicated and makes the application difficult to scale. The linear process of adding new procedures and entries in the %dispatch_table breaks when the functionality provided by the application is formed by several dipendent screens. What can be done to cope with such situations? I thought to a couple of solutions, but I'm not sure of their effectiveness.
Back to
Meditations
|
|