homepage Welcome to WebmasterWorld Guest from 54.204.142.143
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Visit PubCon.com
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
Origin of Coding Technique
Origin of a technique used to write subroutines
RWSteele




msg:3001854
 10:13 pm on Jul 10, 2006 (gmt 0)

I've been migrating and cleaning up a bunch of ASP sites at my current job and I've come across a particular coding "technique" that I find annoying and very hard to follow and would greatly appreciate some opinions.

Here's an example:

MyInclude.asp

<%
sub MySub()
Var1 = "foo"
Var2 = "bar"
End Sub
%>

MyPage.asp

<!--include file="MyInclude.asp"-->
<%
Call MySub()
Response.write Var1 & Var2
%>

Although MySub has no arguments and can't return a value, after it's called two variables automagically appear. Amazing! I've also come across similar subroutines that create connections, recordsets, etc.

Now, if I'm not mistaken a Sub is Public by default, but IMHO no arguments and creating variables to use outside the scope of the sub is just asking for trouble. Is this some old school technique or just plain bad coding?

 

wardbekker




msg:3002172
 6:54 am on Jul 11, 2006 (gmt 0)

The person who wrote that should be fired! ;-)

Well, although VBscript apparently makes this kind of statement possible, it doesn't score high marks for readability.

A possible refactoring is to create a method that returns a class that contains the properties that are needed on each page (Var1, Var2).

adb64




msg:3002198
 7:55 am on Jul 11, 2006 (gmt 0)

This indeed is a very bad coding "technique".
I have more than 20 years experience in coding, mainly C, and if I would code like that my employer would fire me!

RWSteele




msg:3002458
 1:17 pm on Jul 11, 2006 (gmt 0)

Thanks for the input. It's nice to know my eye for bad technique is better than it was 6 years ago before I became a lonely code monkey. :)

Thanks again.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved