Results 1 to 11 of 11

Thread: VB Variable Naming conventions...

  1. #1

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    VB Variable Naming conventions...

    OK, as part of quality control for BAE audits we have to write silly documents about the correct naming conventions...

    So, I know the naming conventions of Data-Types and controls, however I do not know the industry standards for ado objects...
    I always use adoRec for a recordset and adoConn for a connection object...

    Don't suppose anyone could shed some light onto this.

    Woka

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: VB Variable Naming conventions...

    Originally posted by Wokawidget
    OK, as part of quality control for BAE audits we have to write silly documents about the correct naming conventions...

    So, I know the naming conventions of Data-Types and controls, however I do not know the industry standards for ado objects...
    I always use adoRec for a recordset and adoConn for a connection object...

    Don't suppose anyone could shed some light onto this.

    Woka
    here we use the "rst" prefix for recordsets .... rstResults, rstPricing, etc
    and con for connections.... conDB, conDatabase, etc....
    then cmd for command objects, cmdSelect, cmdUpdate..... and prm for the parameter object.....
    hope that helps...

    [edit] IMHO: There's no need to specify ADO.... unless you are using more than one method for connecting to the database (ADO and ODBC) - which seems rediculous, yet understandably possible -- then ADO would seem to be implied.....
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    Addicted Member
    Join Date
    Aug 2002
    Posts
    187
    Woka,

    This is what I could dig up out of a couple of books.

    1. Practical Standards for Microsoft Visual Basic gives the Hungarian notation for database objects as:

    Prefixes for Database Objects

    Database - db eg. dbCustomers
    Field (object or collection) - fld eg. fldLastName
    Index (object or collection) - idx eg. idxAge
    QueryDef - qry eg. qrySalesByRegion
    Recordset - rst eg. rstSalesByRegion
    Report - rpt eg. rptAnnualSales
    TableDef - tbl eg. tblCustomer

    2. Programming ADO

    In their sample code, they use

    Recordset - rs
    Connection - cn
    Command - cmd

    Both books are published by Microsoft Press.

    Cheers

    Jack

  4. #4
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    Command - cmd
    And how do they differentiate this from the Command Button control then?
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Originally posted by MerrionComputin
    And how do they differentiate this from the Command Button control then?
    Not that it's a problem, but normally I wouldn't be doing this: cmdAddButton.Excecute.... all commands are scoped local to the sub that's running, and we use n-Teir architecture as a matter of standards.... there are no command buttons in my data access tiers...
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

  7. #7

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    Ok cheers for the varible prefixes.

    OK, I am now having to write a "Good Practices" list...So far I have:
    • Always manually destroy objects, from their scope when finished with, by setting them to Nothing.
    • All database code should be written in the back-end server side components, where applicable.
    • Avoid using variants wherever possible.
    • Never access methods or properties, from an object, by utilising the default property.
    • Passed variables declared in a function should always be declared as ByVal, unless ByRef is specifically required.
    • Always use Option Explicit at the top of a module to enforce variable declaration.
    • Never use the END command.
    • Always set a project to auto-increment its revision number.
    • Always declare variables for the scope they are intended for.

    I know there are many, many more, but am having a mental block...its just one of those days

    Woka

  8. #8

  9. #9
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Woka - when you are done with that I'd be interested in a copy....
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  10. #10

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    yea...no probs...
    There are one or 2 things I have changed like I have seen varible prefixes on the web that say use lvw for a ListView, and tre for a TreeView...but I have always seen, and used tvw for a TreeView...don't know how much of a problem that causes...

    Woka

    PS I was joking about the cmd in the back end b 4 anyone sez anything

  11. #11
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    What?

    This is my naming convention:
    CommandButtons - Command
    PictureBoxes - Picture
    TextBoxes - Text
    Lists - List
    ComboBoxes - Combo
    TreeViews - TreeView
    ListViews - ListView

    So I'd have Command1, Command2, etc, Picture1, Picture2, etc. You know, that's the way they're setup as, why change them? VB named them that way and it knows what it's doing.

    Anyone who spends time coming up with cute little letters to put in front of them is just wasting their time, and I just don't understand it...



    (Kidding, of course...)
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

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



Click Here to Expand Forum to Full Width