Web Hosting Offers
See the new scripts recently added to Dynamic Drive. Click here.
Original, practical CSS codes and examples such as CSS menus for your site.
    Search code samples  
 
  Keyword
 
 
 
   
 
 
  Code Samples
 
ASP
CSS
Dhtml
Html
Javascript
PHP
 
   
     LOGIN HERE  
 
Username
Password
Forgot Password
Verify Signup
 
 
 

ASP >> General

What is "magic numbers" ?

Visitor Ratings (0) :

Description
Is it when a number is used instead of a name it is called magic numbers. For example: Instead of using

rs.open sql, conn, adOpenDynamic , adLockOptimistic

You can write : rs.open sql, conn, 2, 3

Magic numbers got the name due to the fact that you can put a number as a param to a piece of code and no one will really know what they mean. It always helps to be as descriptive as possible..

Even when I write server components, I will take parameterized inputs to my functions and routines and wrap them around an Enum to make it easier not only for myself to utilize the functions (6 months to a year down the road) but for other people to know what they mean as well..

It's all a readability/maintainability issue. It's a heck of a lot easier to know that adOpenDynamic means that you are going to open up a
recordset in dynamic mode.. then to say "2"
Code
Select All
 Rate this Resource