Results 1 to 12 of 12

Thread: Development Guidelines / Resources

  1. #1
    Join Date
    Aug 2005

    Development Guidelines / Resources

    This is a bit of a cross post from another forum - but might be of use...

    A lot of question on here seem to be from beginners, and some keep on re-appearing. So below some hints to help out:

    Use Option Explicit
    Place this in the first file that gets called in your ASP page. It will force you to declare any variables that you use and stop typo's

    Make use of include files for site wide functionality
    This will allow you to specify common site variables (database connection strings), and common functions ( sendMail?) in one place on your site. This can also be used for templating a site (top.asp / bottom.asp).

    Use Functions and Subs to encapsulate code
    This puts a level of scope on your variables and stops different things interfering with each other.

    Use some kind of hungarian style notation ( str, int, lng, obj), for variables
    This will help you figure out what each variable is as you use it. For example there was the merit table posting on here, what is merittable? rsMeritTable would have given everyone a much better clue.

    Use Friendly variable names - Stevusuk
    There isn't any reason why you would want to name a variable "x" when it could be "intPage"

    Comment code, you might not remember why you did it that way in a couple of months time

    Where possible try and split your code into the appropriate layer
    The standard three tiers of development are data, business and presentation. Try to keep these apart in your code and everything will work much better.

    Avoid arrays etc. like the plague
    The RecordSet object is perfectly nice to work with, stop trying to pull data into nameless arrays. What reads better:

    Rules of Thumb
    1. If is seems impossible it's likely you're doing it wrong.
    2. S/He who googles first is unlikely to be shot down in flames
    3. Those error numbers really do mean something, try searching
    4. If you're having to debug more than 30 lines of code you've not encapsulated enough
    5. If you have to jump through more than 3 functions/subs to debug a problem you've encapsulated too much.


    Useful Functions

    	Function SendMailHTML( str_sendMailTo, str_sendMailFrom, str_sendMailSubject, str_sendMailBody, str_sendMailFileAttach )
    		Dim objConfiguration
    		Set objConfiguration = CreateObject( "CDO.Configuration" )
    		With objConfiguration
    			.Fields("cdoSMTPServer") = ""
    			.Fields("cdoSMTPServerPort") = 25
    			.Fields("cdoSMTPAuthenticate") = 0
    			.Fields("cdoSendUsingMethod") = 2
    		End With
    		Dim iMsg
    		Set iMsg = CreateObject( "CDO.Message" )
    		With iMsg
    			Set	.Configuration = objConfiguration
    			.To = str_sendMailTo
    			.From = str_sendMailFrom
    			.Sender = str_sendMailFrom
    			.Subject = str_sendMailSubject
    			.HTMLBody = str_sendMailBody
    			If ( str_sendMailFileAttach <> "" ) Then Call .AddAttachment( str_sendMailFileAttach )
    			On Error Resume Next
    			If ( Err <> 0 ) Then SendMailHTML = "Unable to send a mail due to a server error"
    			On Error Goto 0
    		End With
    		Set iMsg = Nothing
    	End Function

    Any more for any more?
    Last edited by Richard Conyard; 08-25-2005 at 06:15 AM.

  2. #2
    Join Date
    Aug 2005
    Wales, UK
    This is good advice - especially when someone else might be picking up your code.

    Also - another guideline I tend to use is to use names for variables and functions that explicitly describe what they are used for so in effect your code becomes self-documenting.

    There isn't any reason why you would want to name a variable "x" when it could be "intPage". And if it needs to be more explicit, do it, it makes it easier to understand what "intCurrentSearchPageNumber" is for than "strPage". It may seem a lot of effort at first, but it does pay off in less brain usage each time you visit the code.
    aka "stevus", noun: an unashamed wannabee geek, trying hard to attain geekdom and the role of alpha-geek but without the brains to do so;

    e: stevusuk@yahoo.com

  3. #3
    Join Date
    Jan 2004
    Melbourne, Australia
    Nice post. I will make it sticky for a while.

  4. #4
    Join Date
    Apr 2005
    Hastings, Sussex, UK.
    Quote Originally Posted by Richard Conyard
    Avoid arrays etc. like the plague
    The RecordSet object is perfectly nice to work with, stop trying to pull data into nameless arrays. What reads better:
    I have to disagree with this. The initial statement is ambiguous. Arrays are a very powerful and flexible way of handling data and must be used appropriately. Nameless arrays I can understand are fustrating for anyone trying to understand the code but that's a naming convention issue, not a programmatical one.

    As for the example shown, the recordset is itself an array and can be manipulated as such. Shifting datasets into named arrays can also be valid when having to process large amounts of information repeatedly. The recordset object may not be the most efficient way of doing this so destroying the object and closing the connection is valid.

    It's all about using the right tools for the job but do not avoid arrays, they're an essential part of any programming language and without them the world as we know it wouldn't exist.

  5. #5
    Join Date
    Feb 2003
    Have to agree with Eddie. In fact, arrays should almost always be used in place of an open recordset -- particularly in an OLTP system. If using ADO to get the data, a GetRows should be used to put the data into an array, thus allowing you to close the recordset and db connection as soon as possible. In high throughput systems, you want to close the rs right away, freeing the resource for the next transaction. Also, accessing the data via array is significantly faster than using a recordset object -- another important performance gain in OLTP systems. If you don't use arrays because arr(3) is unreadable, then you are throwing away one of the most powerful tools at your disposal. Also, you can certainly use constants to make em more readable if you prefer (and I do this from time to time in my own code) -- for example something like this
    Const CUST_ID = 0
    Const CUST_NAME = 1
    Const CUST_ADDR = 2
    '' populate arr via GetRows ADO method
    Response.Write arr(CUST_ID, i)
    Response.Write arr(CUST_NAME, i)
    Response.Write arr(CUST_ADDR, i)

  6. #6
    Ubik's Avatar
    Ubik is offline &lt;%= &quot;New Meja Hor&quot; %&gt;
    Join Date
    Nov 2005
    I love using arrays as recordsets and I do it in all my code.

    PHP Code:
    function aGetRecords (strSQL)
    dim connrs
        Set conn 
    conn.open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=mydata.mdb;"
    Set rs Server.CreateObject("ADODB.Recordset")
    rs.open strSQLconn
    if not rs.BOF and not rs.EOF then
    end if
        Set rs 
        Set conn 

    aChangeRecord (strSQL)
    dim dbaseConn
        Set dbaseConn 
    dbaseConn.Open("Driver={Microsoft Access Driver (*.mdb)}; DBQ=mydata.mdb;")
        Set dbaseConn 

    If I have no idea what you are talking about, then I will pretend I know and answer accordingly.

    Thinking about starting a New Thread entitled 'Please Help Me!' ? Read this!

  7. #7
    Join Date
    Jan 2008
    hi there, i'm Z from Malaysia. Sorry for bugging all of you but could you guys lend me a help?

    right now i was in third year of my computer science studies, and are undergo practical training in order to complete my diploma. What is bugging me is that, in my college, i was taught how to use some basic software and hardware. I am well if it comes to visual basic 6.0. But right now, i was given a task of upgrading a window-based system (completely using microsoft access) to a web-based system.

    i've done most of the interface of all the form. the original system has 21 form to begin with.. right now, i'm having trouble in:
    1) producing the script/code program for the system.
    2) Connecting the web-site with the database
    3) generate the log-in scheme..

    I've been given until 31st January 2008 to finish the project since it will be launched on 3rd Feb.. Please help me, i need all the help i can have right now.. it's really bugging me since i was REALLY a newbie.. If you agree i would gladly sent you the project for your reference... thanks for the time..

  8. #8
    Join Date
    Dec 2007
    Dayton, OH
    Design First, Code Later
    Spend more time in the design phase than the coding phase. The more you think out your problem and research it the better off you will be in the long run.

    Use Classes
    They are great for encapsulation and you can move a lot of your business logic into these classes. Try to separate your business logic layer and your presentation layer.

    Make Code Flexible
    Do not code to make something work, code things with changes in mind so that if your boss asks you to change a piece of functionality you don't suffer by "reinventing the wheel"

    Make A Custom 500_100 Error Page
    Without some sort of error tracking system you will not be able to tell if code is failing.

    Hope this helps.

  9. #9
    Join Date
    May 2012
    Fantastic information.....Thanks for tips

  10. #10
    Join Date
    Oct 2012
    VBScript is the default programming language that is encoded in ASP, so if you want to specify a different programming language which should clarify any programming language that will be used at the very beginning of the code. Less than one line of code that should be your first line of the ASP code or your last page will break and you will get an error message...

  11. #11
    Join Date
    Mar 2014
    Thanks for the guidelines.. it should be easily to understood

  12. #12
    Join Date
    Nov 2014
    Dubai, United Arab Emirates
    good job we developed our website for a http://minutesuae.net]web design company in Dubai[/url] in asp and it is working good.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.12805 seconds
  • Memory Usage 2,992KB
  • Queries Executed 15 (?)
More Information
Template Usage (35):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (6)bbcode_code
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (12)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (12)postbit
  • (12)postbit_onlinestatus
  • (12)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (72):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • bbcode_parse_start
  • postbit_imicons
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates