IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
Coder
Search Coder Group:

Advanced
-Collapse +Expand Coder Study Test
PRESTWOODCERTIFIED
-Collapse +Expand Coder Store
PRESTWOODSTORE

Prestwood eMagazine

April Edition
Subscribe now! It's Free!
Enter your email:

   ► KBRole-Based T...Coding & OOGeneral Codi...   Print This     
  From the February 2010 Issue of Prestwood eMag
 
Coder General Coding Concepts:
Computer Language Constants
 
Posted 16 years ago on 12/16/2008
Take Away:

A constant is just like a variable (it holds a value) but, unlike a variable, you cannot change the value of a constant.

Coder Definition Flashcard:
 A flashcard from our Coder Flashcards Library
 A definition from our Coder Definitions Page

KB101710

Computer Language Constants -

A constant is just like a variable (it holds a value) but, unlike a variable, you cannot change the value of a constant.


A constant is just like a variable (it holds a value) but, unlike a variable, you cannot change the value of a constant.

Tip: Many programmers have adopted a standard of all uppercase with underscores separating words for constants but personally I don't like that standard. All caps just slows me down so I prefer to start all constants with a lowercase k as in kUniversalConstant. If a constant is global in scope I start it with an uppercase k as in KUniversalConstant. I really don't like going against trends and this was a hard decision for me. Study your language and decide for yourself. For VBA languages, Microsoft migrated from the all caps suggestion to use camel caps preceded with con suggestion as in conUniversalConstant.

More Info

Code:  Access VBA Constants (Const kPI = 3.1459)
Code:  ASP Classic Constants (Const kPI = 3.1459)
Code:  C# Constants (const)
Code:  C++ Constants (const)
Code:  C++/CLI Constants (const or literal)
Code:  Delphi Constants (Const kPI: Double=3.1459;)
Code:  Delphi Prism Constants (const kPI: Double=3.1459;)
Code:  ObjectPAL Constants (const..endConst)
Code:  Perl Constants (use constant)
Code:  PHP Constants (define)
Code:  VB Classic Constants (Const kPI = 3.1459)
Code:  VB.Net Constants (Const kPI Double = 3.1459)

Comments

1 Comments.
Share a thought or comment...
Comment 1 of 1

I always begin the name of a constant that has a global scope with an uppercase k, for example snow rider 3d.

Posted 8 months ago
 
Write a Comment...
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1185A1
Enter key:
Definition Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains play-drums.com and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile

 KB Article #101710 Counter
16786
Since 12/16/2008
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2024 Prestwood IT Solutions.   [Security & Privacy]