At work we are completing a rather large CGI application. The main program is only a couple hundred lines long (it mostly directs traffic) and all of the work is done with about a dozen modules. We use the term module loosely as each of these modules is pretty much a program of it's own.
Session variables are read from the database in the main program and again in each module. I don't have any previous experience handling sessions so I don't know if this is the norm. I have written some of the more recent modules so they don't use any session variables themselves. In these I am passing in every variable I will need when I call the module. This list has gotten as large as 30 variables for some modules, and it would be a lot larger for other modules.
I feel that passing in a large number of variables makes the code cleaner. The other programmer feels that re-creating the variables will slow down the application. Obviously we have differing views as to the merit of each approach. Since we are just about finished this version and getting ready to start the next version we want to come an agreement as to the best solution.
I know I am being rather vague but my questions are these:
1) Is it better to use sessions in modules like this?
2) Is it better to pass in every variable under the sun?
3) Will one approach make the application faster/slower than the other?
4) Do you feel that either/both of these approaches is just plain bad?
Any tips and pointers will be appreciated.
mr greywolf
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.