Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 DEV-Group
 DEV Discussions (General)
 A humble sugestion for the Dev Team
 New Topic  Reply to Topic
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

AnonJr
Moderator

United States
5768 Posts

Posted - 28 September 2005 :  12:03:05  Show Profile  Visit AnonJr's Homepage  Reply with Quote
Working on some modifications to the hospital's forum, I noticed that some of the Subs and Functions rely on info not explicitly passed to them... it was the source of a couple of head-scratches this morning.

While you guys are working on the new version, could you please make sure that the subs and functions don't unnecessarily rely on external information?

IMHO it would help abstract a few things and make the subs/functions a little more re-usable.

Case in point: I am working with sr_erick's sub-forum code. I needed the "Jump to Last Post" arrow and link to show properly in the sub-forum listing. I finally found the function, but couldn't get it to work right because even though the variables were named the same, the scope was different. I ended up making a third copy of the function and passed it the two variables it needed. Had it been set up like this in the beginning, a more generic version could have been coded, put in inc_func_common.asp or somewhere like that, and there wouldn't be a copy on default.asp and on forum.asp and now in inc_subforum.asp - the one function could be more versatile.

Just my 2c. I got it working, I just thought that I would add this to the discussion as I see a lot of subs and functions that are duplicated in several areas - often with little to differentiate them... while I am a big fan of cut and paste, having it in one place makes it easier to update.<

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 28 September 2005 :  17:51:24  Show Profile  Visit HuwR's Homepage  Reply with Quote
yes, having it in one place makes it easier to update, but also means it would be loaded into a lot of pages where it isn't needed, as it is only used by two pages it can hardly be called a "common" function<
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 28 September 2005 :  21:51:49  Show Profile  Visit AnonJr's Homepage  Reply with Quote
True. That particular one is only used in a few places like Active Topics, default.asp and forum.asp. However, I've noticed a lot of this in things used more pervasively. I only mention it to point out something that I'd noticed. I'm doing a lot of refactoring of my own code as I upgrade various things so this sort of thinking is at the top of my mind. Its just the way development goes.

Its why I think a more object oriented/class-based structure could help if implemented properly... but that's just me, a humble intermediate programmer. <
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 28 September 2005 :  22:06:54  Show Profile  Send ruirib a Yahoo! Message  Reply with Quote
I generaly agree with your comment. It's probably the general VB easy way that causes this. Global variables use difficults maintenance, that's for sure, specially for someone who didn't design the original code. On the other way, the use number of forum variables would make it difficult to pass them into a function, at least in the usual way VB does it, so...

<


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 28 September 2005 :  23:13:45  Show Profile  Visit AnonJr's Homepage  Reply with Quote
I never said it would be easy to develop , just easier to maintain/MOD in the long run. I've started moving a lot of code to classes, and started getting better about passing variables to my subs and functions instead of using the globals... its required more thought but resulted in tighter, more re-usable code.

Like I've said before: its something I'd like to see. But if it doesn't happen, it doesn't happen. In some ways a dev team of 1 can make life simpler... and then again it leaves few checks in the thought process. (Though some days I feel like a 486 in a PII world)

And now I'll stop before I ramble too far into incoherance.... <
Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 29 September 2005 :  00:05:15  Show Profile  Reply with Quote
I have seen it mention before, but can you give me some info on using classes in ASP? Not an area I have coded in.<

Support Snitz Forums
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 29 September 2005 :  00:05:33  Show Profile  Send ruirib a Yahoo! Message  Reply with Quote
I wasn't disagreeing, just saying VB doesn't help much to do it differently, though it's mainly a programmer's choice.<


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 29 September 2005 :  00:59:48  Show Profile  Visit AnonJr's Homepage  Reply with Quote
quote:
Originally posted by Davio

I have seen it mention before, but can you give me some info on using classes in ASP? Not an area I have coded in.



I've got a few links back at the office. I'll post them up here as soon as I get to work tomorrow.

One is from over at http://www.techrepublic.com, another is from MS itself, and I can't remember where the other two came from off the top of my head.<
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 29 September 2005 :  05:20:55  Show Profile  Visit HuwR's Homepage  Reply with Quote
classes in ASP are page centric so would not be of much use as a repleacement for global variables and functions, they can not be stored in session objects or application objects either, yes they are beneficial when writing VB applications, but not when writing an ASP website.

The ASP server is multithreaded and assigns a different thread to each page request (and hence each script engine). But VBScript class instances are apartment-threaded objects, which means that they must run on the thread that created them.<
Go to Top of Page

StephenD
Senior Member

Australia
1044 Posts

Posted - 29 September 2005 :  05:28:12  Show Profile  Send StephenD a Yahoo! Message  Reply with Quote
I was just about to say that ...
(Overdosed on Gingko Biloba)<
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 29 September 2005 :  09:01:35  Show Profile  Visit AnonJr's Homepage  Reply with Quote
I didn't know about the threading issues. Time to dig back into the books!

When you mention the VB Apps, you probably hit on part of my line of thinking... I started off as an applications developer using primarily VB and COBOL (not in the same app). I took a Perl class for kicks and (long story short) got hired as a web developer for my Perl skills. IS upgrades the server and "by the way, we won't be installing Perl." I figured a move to ASP/VBScript would be the easiest to make given my background with VB.

In the end though, I wasn't suggesting we do everything with classes, or that we store them in the session/application objects, or use them to replace all the global variables. You're right, they wouldn't be of much use.

But what about encapsulating the Member info into a class so the validation isn't repeated in multiple places? When someone wants to require a field that isn't required or vice versa, there are a fair number of places to fix the code. By creating a user class (maybe put it in clsUser.asp) and then include it in every page that deals with the profile and validating information, it would become easier to make alterations.

We have a part of the website where people can view fliers for our various classroom-based classes. The code for the display and management has been a lot of "cut and paste" wich makes adding further enhancements rather interesting... I've taken some of the code I wrote the first time through and started consolodating it into a Flyer class. Its required a fair amount of work, but my code is tigher, cleaner, and I stand a better chance of figuring out what in God's Green Earth I was trying to do with a given portion of code. (And man have I found myslef wondering what I was thinking in some places... all I can say is it made sense at the time)

Is it going to replace all the functions and subs? No. Is it going to take the place of the session variables? Nope. Will it help other areas of the software? Yes. Like all things it has a proper place and use.

Incidentaly, here are a few of the articles I've been reading. A lot of what I've been reading is out of some books I've picked up at Barnes n Noble, but some of these are decent articles.

http://www.asp101.com/articles/richard/ooasp/default.asp

http://www.asp101.com/resources/jonmgohr/081899/class.asp

http://www.asp101.com/resources/jonmgohr/082499/class2.asp

There was one more over at http://www.techrepublic.com that I can't seem to find the link for anymore....

Are they the pinacle of professional writing? No. Do they give some ideas? Yup.

Please keep in mind, in all this I am not trying to criticize/complain/etc about the code. Like I mentioned above, I'm working on adding this to the work I do now. I would like to continue this discussion as its helping me to evaluate my choices a little better. A dev team of 1 is a mixed blessing.<
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 29 September 2005 :  12:04:17  Show Profile  Visit HuwR's Homepage  Reply with Quote
quote:
But what about encapsulating the Member info into a class so the validation ....
Yes, maybe for something like this it would be useful, but you also have to look at the amount of code involved in doing so, just because your "X" lines of code look easier to read doesn't necesarily mean it is the most efficient, the more lines of code there are in your asp files the slower your site will be, don't forget unlike an app your code is not optimised before it is used.<

Edited by - HuwR on 29 September 2005 12:04:53
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 29 September 2005 :  12:25:39  Show Profile  Visit AnonJr's Homepage  Reply with Quote
I can wrap myself around how having more lines of code don't necesarily make the script slower. Would I be correct in thinking that this is where its up to the developer to balance readability/maintainability with speed/efficiency?

I've not noticed a difference in the speed of the Online Flyer application I mentioned earlier; all generation times are more or less within the same range. However, I've found it infinatly easier to add new features to the class and implement it in the final project.

If I'm not careful, I'm sure I'll hit a point where the class becomes too unwieldly and large, and therefore a bigger hinderance than help. But there are places it could help.<
Go to Top of Page

-gary
Development Team Member

406 Posts

Posted - 29 September 2005 :  12:34:40  Show Profile  Reply with Quote
For scripts, I'd say the best approach is get in and get out as fast as possible. Let the code requesting the data process it how it needs. This keeps your shared functions smaller, quicker and much easier to use across the application. The more specific you try to make the classes, the more functions inside them you'll need and the more calls to the class you'll need.

Something like a member validation class would be useful as it's used site wide and is very specific in scope, but outside of few exceptions it will only lead to code bloat.

They also wouldn't lend themselves well to use with mods as the classes would most likely need modifying for even simple mods. Fewer generic functions would be more easily integrated and expanded upon and the less base functions that modders have to touch, the more extensible the code becomes.<

KawiForums.com


Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 29 September 2005 :  12:54:56  Show Profile  Visit HuwR's Homepage  Reply with Quote
quote:
Something like a member validation class would be useful as it's used site wide and is very specific in scope, but outside of few exceptions it will only lead to code bloat.

Yes, well unfortunately that is something you can't do with a class in asp, it only has page scope, so any page that needed it would have to contain the classes complete definition, not that that would be a problem, but may indeed lead to some overly bloated pages, where all you wanted was user.Name<
Go to Top of Page

Doug G
Support Moderator

USA
6493 Posts

Posted - 29 September 2005 :  16:41:32  Show Profile  Reply with Quote
I like using VBScript classes. I don't see much difference with the scope as compared to an include page of functions, which also has page scope. My faq pages are all done with extensive use of VBScript classes and I am happy with the way they perform. In many cases I found classes to shorten code rather than bloat it.

It would be nice if user classes in VBScript could be saved in an application or session object, but this shouldn't prevent the use of classes imho.

<

======
Doug G
======
Computer history and help at www.dougscode.com
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.15 seconds. Powered By: Snitz Forums 2000 Version 3.4.07