473,549 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP Coding Questions Discussion

Hi,

I am wondering if I am doing right. Please advise.

I create a system with 8 major steps and each step can go different
direction. General speaking, a lot of if statements and functions inside.

Each page is over 1000 lines. In order for me to debug, I separate the lines
by function and create a template page.

Then I use <--# include... --> to link to this template page.

Also some of the code are shared with other page link query, table..., I
also create a temp page for this and include into other pages.

The pro is that:

1. if update, I just update one temp page and all the page will be updated.
2. easy to debug because it will make the page shorter. The one with include
page has only 140 lines and without the include page is over 1500 lines.

The con may be:

1. too many include command to make the system slow??

My question is Am I Doing correct? Or there is a better solution?

Thanks,

Lin Ma


Jul 19 '05 #1
25 2384
What kind of application needs 1000 lines per page?

That seems ludicrously overboard, IMHO.


Each page is over 1000 lines. In order for me to debug, I separate the lines by function and create a template page.

Jul 19 '05 #2
Thanks for the response. I have tables, headers, queries, JavaScript, I also
have if statements... Some pages also send email to certain group...

The system is like a documentation approval system, different level people
will take different action, sign their option and move to next level person.
The next person can reject, accept, on hold... A lot of functions.

My point is that Can I divide my code into server area by function. Each of
the area creates a separate file. Then use Include command to assembly this
files together?

Thanks for the response.

Lin

"Aaron Bertrand - MVP" <aa***@TRASHasp faq.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
What kind of application needs 1000 lines per page?

That seems ludicrously overboard, IMHO.


Each page is over 1000 lines. In order for me to debug, I separate the

lines
by function and create a template page.


Jul 19 '05 #3
Off course you can do it but, always remember that a SSI (include statement)
is writen in the code is always included before any building of the code.
this mean that if you include a file in an if ... end if statement this file
will always be included.
This is a bit heavy for the server but can be really helpful for a debuging
purpose.
do not overuse it, that's all
Jul 19 '05 #4
> My point is that Can I divide my code into server area by function. Each
of
the area creates a separate file. Then use Include command to assembly this files together?


No, but you could use server.execute( ). Includes are processed before ASP,
so any logic you use in ASP to determine which files to include will be too
late.
Jul 19 '05 #5
Thanks.

Is there a better way to do to make page shorter?

Thanks a lot.

Lin

"Martin CLAVREUIL" <ma************ **@wanadoo.fr> wrote in message
news:eQ******** ******@TK2MSFTN GP12.phx.gbl...
Off course you can do it but, always remember that a SSI (include statement) is writen in the code is always included before any building of the code.
this mean that if you include a file in an if ... end if statement this file will always be included.
This is a bit heavy for the server but can be really helpful for a debuging purpose.
do not overuse it, that's all

Jul 19 '05 #6
On Mon, 11 Aug 2003 09:43:03 -0500, "Lin Ma" <a@a.com> wrote:
I create a system with 8 major steps and each step can go different
direction. General speaking, a lot of if statements and functions inside.

Each page is over 1000 lines. In order for me to debug, I separate the lines
by function and create a template page.
Creating functions is smart if the same code is being executed
multiple times. If executed once, just put it there.

1,000 lines is big. Big enough that you're likely causing a slowdown
somewhere that you don't need to. Modularize the options and put them
in separate code pages.
Then I use <--# include... --> to link to this template page.
In general, use includes to place the exact same block of code in
multiple pages. If it only runs once for the page it's on, don't use
an include.

But, you *might* use an include to separate code from HTML.
Also some of the code are shared with other page link query, table..., I
also create a temp page for this and include into other pages.
This is what includes are designed for, shared code or portions of
pages. I don't see the reason for a temp page, but that may be your
explanation or my ignorance that's confusing me.
1. if update, I just update one temp page and all the page will be updated.
Welcome to the reason for includes.
2. easy to debug because it will make the page shorter. The one with include
page has only 140 lines and without the include page is over 1500 lines.
Bleh! Break it into multiple pages. Just beacuse you can put
everything on one page doesn't mean you should.
The con may be:

1. too many include command to make the system slow??
Maybe, probably not noticably considering the system is processing all
those lines.
My question is Am I Doing correct? Or there is a better solution?


No matter how you do it, there's *always* a better solution. :)

I'd look at the programming logic. You mentioned eight major steps.
How many minor steps, and how many of those can be broken into
separate pages. Cheap example:

Big Pages:
=============== ====
If User is Supervisor Then
Do code
Do more code
Do more code
End If

If User is Employee Then
Do code
Do more code
Do more code
End If
=============== =====

Small Pages:
=============== ====
If User is Supervisor Then
Goto Supervisor.asp
End If

If User is Employee Then
Goto Employee.asp
End If
=============== =====

In the separate ASP pages, do the code for that IF statement. In this
pseudocode it saves four lines for the main page, and each individual
page is easier to debug.

Jeff
Jul 19 '05 #7
In article <ud************ **@TK2MSFTNGP09 .phx.gbl>, a@a.com says...
My point is that Can I divide my code into server area by function.
... Then use Include command to assembly this files together?


Sure you can, Lin Ma. Here's an example for you:

-----<begin file capitalizeWord. asp>-------
<%
Function capitalizeWord( w)
dim s, t, u, l
l = Len(w)

if (l = 0) Then
capitalizeWord = ""
exit Function
End If

s = Left(w, 1)
t = Right(w, l - 1)
u = Ucase(s)

capitalizeWord = u & t

End Function
%>
-----<end file capitalizeWord. asp>-------

and in file tests.asp:

------<begin file tests.asp>------
<%@ Language=VBScri pt %>
<%Option Explicit%>

<!--#include virtual="bmlc_a sp/includes/adovbs.inc"-->

<!--#include virtual="bmlc_a sp/includes/capitalizeWord. asp"-->
<!--#include virtual="bmlc_a sp/includes/ConnectionStrin g.asp"-->

<!--#include virtual="bmlc_a sp/includes/debugScreen.asp "-->
<!--#include virtual="bmlc_a sp/includes/makeOption.asp"-->
<!--#include virtual="bmlc_a sp/includes/queryDatabase.a sp"-->

<!--#include virtual="bmlc_a sp/TestCreation/TestClass.asp"-->
<!--#include virtual="bmlc_a sp/TestCreation/TestQuestionCla ss.asp"-->

-------<end file .asp>-------

Notice that you have to do the inclusions outside of the asp markers.
Also, there is no built-in protection against redundant including of
symbols, (no #ifdef in C++ speak) so you will have to come up with some
kind of scheme to protect yourself against that.

-- Rick

Jul 19 '05 #8
> I'm a little confused. I'm somewhat new to this ASP stuff, but I've
been developing software for over 20 years (way over, come to think of
it), and to my mind 1000 lines is not a big program.
For a "real" application, no. For a web page, that's massive. I've been
developing ASP applications for, what, 7 or 8 years now? IIS 3 beta 2,
whenever that was made available. And I've never seen, much less written,
an ASP page with 1000 lines.
Rather than have an unruly, unmanageable string of response.redire ct-
related pages like the system it replaces, it has a central ASP page
that accepts the client-side input and generates the appropriate
response pages on the fly.
And you think this is more efficient?
So are you (Aaron, specifically) claiming that I should break that up
into a dozen individual pages that use the WEB equivalent of "goto"
(response.redir ect) to switch between them?


When I build my sites, almost all of my content is stored in the database.
The information is not always retrieved directly from the database, e.g.
aspfaq.com uses a caching technology which only gets updated when the
articles actually change. The entire aspfaq.com site is about 120 lines of
code, and a good portion of that is style sheets / client-side javascript.

However I'm not claiming at all what you should or should not do. I think
if you have 1500-2000 lines of code, that's going to be a royal PITA to
manage, no matter how you decide to break it up (or not at all). I just
can't, for the life of me, imagine what you would need to do - for a set of
web pages - that would require that much code.

A
Jul 19 '05 #9
>> >I create a system with 8 major steps and each step can go different
>direction. General speaking, a lot of if statements and functions inside.
>
>Each page is over 1000 lines. In order for me to debug, I separate the lines
>by function and create a template page.
1,000 lines is big. Big enough that you're likely causing a slowdown
somewhere that you don't need to. Modularize the options and put them
in separate code pages.


I'm a little confused. I'm somewhat new to this ASP stuff, but I've
been developing software for over 20 years (way over, come to think of
it), and to my mind 1000 lines is not a big program. In fact, it's
barely non-trivial.


VB apps routinely run many thousands of lines of code. But rarely
does the server need to process an entire VB application just to
display a logon screen. Plus, the nature of ASP and the web means you
don't need all the code for an application in one page.
Is it a matter of terminology? When Lin Ma says "pages" maybe she
doesn't mean what you guys mean when you say pages.
My take is a "page" means a single "file" processed and sent to the
browser.
In one of the subsystems of my application I have a main "page" that has
about 450 lines in it. About half of that is the main code (about half
of which is comments) and the other half is utility subroutines. There
is no display code in this file.
If Lin Ma has 1,000 lines and half are comments and another third are
blank, that's a different story. But in the ASP world, 1,000 lines of
code is pretty danged big.
In this main "page" I include fourteen directly related ASP files and
four data files. The ASP files collectively have about 700 lines in
them. In addition I include another nineteen general purpose ASP files
that do things like capitalize words, query the database, generate
dynamic "<select>" controls, etc. That adds another 500 lines of code,
or so.
That can also be dramtically squeezed from the sounds of it. Or at
least broken up.
Rather than have an unruly, unmanageable string of response.redire ct-
related pages like the system it replaces, it has a central ASP page
that accepts the client-side input and generates the appropriate
response pages on the fly.
Unruly and unmanageable aren't the code's fault. But the solution is
rarely putting everything in one large file.
I don't see how it could be done in less than, well, 1500 - 2000 lines
of code.
I don't either. But I don't have the code... :)
So are you (Aaron, specifically) claiming that I should break that up
into a dozen individual pages that use the WEB equivalent of "goto"
(response.redi rect) to switch between them?


No. But discreet points where user input is needed probably should be
in discreet pages. You have 500 lines of code that query databases,
capitalize words, create dynamic SELECT controls, all of which could
possibly be better handled elsewhere. (Well, for one thing, ASP.NET
might help with some of your controls...) If you don't need to query
a database at the same time you capitalize words, don't put the
functions in the same page. In fact, handle capitalization on the
input side instead of the output, you capitalize once instead of every
time.

There's no real "method" to handle any of this. And what works in one
case most certainly won't work in all. For example, I have pages
which could easily be optimized, but they rarely get run and the
performance increae would be minimal so why bother? My efforts are
better spent elsewhere.

Jeff
Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

55
5117
by: Jonas Smithson | last post by:
I've seen a few attractive multi-column sites whose geometry is based on pure CSS-P, but they're what you might call "code afficionado" sites, where the subject matter of the site is "coding practices." (One example of this is alistapart.com.) However, the project/development realities for small boutique sites are completely different from...
4
1182
by: Joe Befumo | last post by:
I've been a project manager for the past several years, and my programming chops are a bit rusty, so I'm soliciting help for a programming test for a job. (I don't feel at all dishonest for doing this because, frankly, I would have absolutely no compunctions about asking my betters for help if I were actually on the job.) I've been out of...
0
1306
by: pandu | last post by:
..NET database dev questions http://freedownloadablebooks.blogspot.com/2008/03/net-database-dev-questions.html Some general quickies http://freedownloadablebooks.blogspot.com/2008/03/some-general-quickies.html ..NET WebDev interview questions - Part 1 http://freedownloadablebooks.blogspot.com/2008/03/net-webdev-interview-questions-part-1.html...
0
1228
by: pandu | last post by:
..NET database dev questions http://freedownloadablebooks.blogspot.com/2008/03/net-database-dev-questions.html Some general quickies http://freedownloadablebooks.blogspot.com/2008/03/some-general-quickies.html ..NET WebDev interview questions - Part 1 http://freedownloadablebooks.blogspot.com/2008/03/net-webdev-interview-questions-part-1.html...
0
7546
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7740
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7985
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5387
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5111
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3517
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1082
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
784
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.