Identifiers

4.3 Explain the purpose and use of programming concepts.

📘CompTIA ITF+ (FC0-U61)


In programming, data must be stored so that a program can process it. Programs perform tasks such as calculations, comparisons, storing user input, and retrieving stored values. To do this, programmers use identifiers.

An identifier is a name used in a program to identify a piece of data or a programming element. It allows the program to reference information stored in memory.

Identifiers make programs easier to read, write, and maintain because they provide meaningful names for data and program components.

Examples of programming elements that use identifiers include:

  • Variables
  • Constants
  • Functions
  • Classes
  • Arrays
  • Objects

For the CompTIA ITF+ exam, the most important identifier types to understand are:

  • Variables
  • Constants

1. Variables

Definition

A variable is a named storage location in memory that holds a value which can change while the program is running.

The value stored in a variable can be modified by the program as operations occur.

A variable always has:

  • A name (identifier)
  • A data type
  • A value

Example structure:

variable_name = value

Example:

userLoginCount = 5

Here:

  • userLoginCount → variable name (identifier)
  • 5 → stored value

The program can later change this value.


Why Variables Are Used

Variables allow programs to:

  • Store data temporarily
  • Store user input
  • Perform calculations
  • Track changes during program execution
  • Manage application state

Without variables, programs could not dynamically process data.


Variables in an IT Environment

Variables are commonly used in many IT systems and applications.

Examples include:

User Login Systems

A system may store login attempts in a variable.

loginAttempts = 0

Each failed login increases the value.

loginAttempts = loginAttempts + 1

File Size Processing

A backup application may store the file size in a variable.

fileSize = 2048

The program uses the variable to calculate storage usage.


Server Monitoring

Monitoring software may store CPU usage in a variable.

cpuUsage = 72

The program checks the variable and sends alerts if it exceeds a threshold.


Database Queries

A query may store returned results in variables.

totalRecords = 120

The application then displays the result.


Characteristics of Variables

Variables have several important characteristics.

1. Stored in Memory

When a variable is created, memory is allocated to store its value.

Example:

activeSessions = 25

Memory space is reserved for storing the value 25.


2. Value Can Change

Variables can change during program execution.

Example:

downloadProgress = 10
downloadProgress = 50
downloadProgress = 100

The value updates as the download progresses.


3. Associated With Data Types

Each variable stores a specific type of data.

Common data types include:

Data TypeDescriptionExample
IntegerWhole numbers10
FloatDecimal numbers10.5
StringText“AdminUser”
BooleanTrue or Falsetrue

Example:

userName = "admin"
isConnected = true
memoryUsage = 65

Variable Naming Rules

Programming languages follow rules for naming identifiers.

Common rules include:

1. Must Start With a Letter or Underscore

Valid:

userName
_serverStatus

Invalid:

1username

2. Cannot Contain Spaces

Invalid:

user name

Correct:

userName

3. Cannot Use Reserved Keywords

Reserved words are used by the programming language.

Examples:

if
while
return
class

These cannot be used as variable names.

Invalid:

if = 10

4. Should Be Meaningful

Variables should clearly describe their purpose.

Good:

fileCount
diskUsage
networkStatus

Poor:

x
data1
temp

Meaningful names improve readability and maintenance.


Variable Initialization

Initialization means assigning a value to a variable when it is created.

Example:

serverStatus = "Active"

Without initialization, variables may contain undefined values depending on the programming language.


2. Constants

Definition

A constant is a named value that cannot change during program execution.

Once a constant is defined, its value remains fixed.

Example:

MAX_USERS = 100

The value 100 cannot be modified later in the program.


Why Constants Are Used

Constants help:

  • Prevent accidental value changes
  • Improve program readability
  • Maintain fixed configuration values
  • Improve program reliability

Constants in an IT Environment

Constants are widely used in software systems.

Examples include:

Maximum System Limits

An application may define a constant for maximum allowed users.

MAX_USERS = 100

The program checks:

if currentUsers < MAX_USERS

Network Port Numbers

Network applications may define port numbers as constants.

HTTP_PORT = 80
HTTPS_PORT = 443

These values remain fixed.


Database Configuration

Applications may store database configuration settings as constants.

MAX_CONNECTIONS = 50

Timeout Values

Server applications often define timeout limits.

SESSION_TIMEOUT = 30

This means a session expires after 30 minutes.


Characteristics of Constants

Constants have several key properties.

1. Value Cannot Change

After definition, the value cannot be modified.

Example:

PI = 3.14159

Changing it later would cause an error.


2. Improves Program Safety

Using constants prevents accidental modifications.

Example:

Instead of writing:

timeout = 30

Using a constant:

SESSION_TIMEOUT = 30

Prevents other parts of the program from modifying it.


3. Improves Code Readability

Constants make programs easier to understand.

Example:

Poor readability:

if connectionTime > 30

Better readability:

if connectionTime > SESSION_TIMEOUT

Naming Conventions for Constants

Constants usually follow a different naming style from variables.

A common convention is:

Uppercase letters with underscores

Example:

MAX_USERS
SERVER_PORT
SESSION_TIMEOUT
DATABASE_LIMIT

This makes constants easily recognizable in code.


Differences Between Variables and Constants

FeatureVariableConstant
Value changeCan changeCannot change
PurposeStore changing dataStore fixed values
MemoryAllocated during executionAllocated once
Naming stylecamelCase or descriptiveUPPERCASE
ExampleloginAttemptsMAX_LOGIN_ATTEMPTS

Example Program Using Variables and Constants

Example pseudocode:

MAX_LOGIN_ATTEMPTS = 5loginAttempts = 0loginAttempts = loginAttempts + 1if loginAttempts > MAX_LOGIN_ATTEMPTS
display "Account locked"

Explanation:

  • MAX_LOGIN_ATTEMPTS → constant (fixed value)
  • loginAttempts → variable (changes during execution)

Why Identifiers Are Important in Programming

Identifiers help programs:

  • Organize data
  • Reference stored values
  • Improve readability
  • Simplify debugging
  • Maintain structured code

Without identifiers, programs would rely only on raw memory addresses, making development extremely difficult.


Key Exam Points for CompTIA ITF+

Students preparing for the CompTIA ITF+ (FC0-U61) exam should remember:

  • Identifiers are names used to identify programming elements.
  • Variables store data that can change during program execution.
  • Constants store values that remain fixed.
  • Variables and constants improve readability, organization, and maintainability of programs.
  • Variables are used for dynamic data, while constants store fixed configuration values.
  • Identifiers must follow naming rules and conventions defined by programming languages.
Buy Me a Coffee