Using Constants - Any Disadvantages?

Results 1 to 3 of 3

Thread: Using Constants - Any Disadvantages?

  1. #1
    Jason Guest

    Default Using Constants - Any Disadvantages?

    Are there any disadvantages to using constants? I like to use them to simplify code. Below shows how I&#039;m currently using them. Any thoughts would be appreciated.<BR><BR>&#039;Constants<BR>&#039;Speci fies names for first index of two-dimensional array that stores a table of items<BR>Const ID = 1 &#039;Product ID property<BR>Const NAME = 2 &#039;Name property<BR>Const QTY = 3 &#039;Quantity property<BR>Const UPRICE = 4 &#039;Unit Price property<BR>Const TPRICE = 5 &#039;Total Price property<BR>&#039;Specifies names for first index of two-dimensional array that stores a table of query results<BR>Const T_ID = 0 &#039;Product ID property<BR>Const T_NAME = 1 &#039;Name property<BR>Const T_UPRICE = 2 &#039;Unit Price property<BR>&#039;Specifies DSN (Data Source Name) for use with database connection<BR>Const STORE_DSN = "DSN=Store"<BR>&#039;Specifies whether debugging is on (True/False)<BR>Const DEBUG_ON = True<BR><BR>Example Usage:<BR><BR>Set oConn = Server.CreateObject("ADODB.Connection")<BR>oConn.O pen STORE_DSN <BR>Set oRs = oConn.Execute("select * from products")<BR>aTable = oRs.GetRows<BR>aItem(NAME,1) = aTable(T_NAME,1)<BR>aItem(UPRICE,1) = aTable(T_UPRICE,1)<BR>If DEBUG_ON Then Debug_ShowItems

  2. #2
    Join Date
    Dec 1969

    Default RE: Using Constants - Any Disadvantages?

    I don&#039;t think the kind of stuff u want to do u don&#039;t need any constants.I mean the purpose of constant is somewhat different say if u are using a value &#039;n&#039; no. of times and u are not going to change it in that page than constant makes sense.<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: Using Constants - Any Disadvantages?

    Obviously, over use of almost anything can be a bad thing.<BR>However, using constants is generally considered a very good idea. There is a miniscule performance hit, but for 90%(probably much higher) of websites, its not noticeable.<BR>Using constants properly greatly increases readability and maintainability and I think it&#039;s worth what ever little performance trade-off there is with using them.<BR><BR>Just my thoughts.

Posting Permissions

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