Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Web
Expertise: Intermediate
Apr 27, 2000

Encapsulate Your Code

One of the most common mistakes developers can make is to extensively use global variables. While they are sometimes necessary, global variables can cause problems in code that are both difficult to find and costly to fix. One way of preventing the use of global variables is by encapsulating all of your code in subroutines.

As in the code fragment below, ASP pages can be organized into a set of functions, all called from a Main subroutine declared at the top of the page. Using this coding standard can prevent debugging later.

 
<%@ LANGUAGE="VBSCRIPT" %> 
<% Main '----------------'Function: Main 'Purpose: Entry point for the page.'
---------- Sub Main %> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <html> <% DisplayPage() %> </html> <% End Sub %>
Manoj K.
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date