Software QA/Test/Testing FAQs: What Are Constants, Variables?




   Software QA/Testing

Glossary and Technical FAQs


PreviousGo to next page





Q: What is a constant?

A: In software or software testing, a constant is a meaningful name that represents a number, or string, that does not change.

Constants are variables whose value remain the same, i.e. constant, throughout the execution of a program.

Why do developers use constants? Because if we have code that contains constant values that keep reappearing, or, if we have code that depends on certain numbers that are difficult to remember, we can improve both the readability and maintainability of our code, by using constants.

To give you an example, let's suppose we declare a constant and we call it Pi. We set it to 3.14159265 and use it throughout our code.

Constants, such as Pi, as the name implies, store values that remain constant throughout the execution of our program.

Keep in mind that, unlike variables which can be read from and written to, constants are read-only variables.

Although constants resemble variables, we cannot modify or assign new values to them, as we can to variables.

But we can make constants public, or private.

We can also specify what data type they are.

[Continued on next page...]

Click on a link!


______________________________________________________

Copyright 2003-2013 by Rob Davis PE. All rights are reserved. No part of

this document may be reproduced in any form whatsoever

without written permission from Rob Davis, PE.

http://softwaretestengineer.com

http://robdavispe.com


     Go to next page