What should I use instead of banned variable names in EK9?

← Variable Naming Rules and Conventions · Ref: Q906

EK9 bans generic variable names at compile time (E11031). Here is a complete replacement guide.

REPLACEMENT TABLE

Instead of 'temp' use: swapHolder, intermediateResult, transformedInput
Instead of 'value' use: price, score, threshold, measurement, reading
Instead of 'data' use: payload, sensorReading, customerRecord, configEntry
Instead of 'flag' use: isValid, hasPermission, isActive, wasProcessed
Instead of 'buffer' use: inputBuffer, readChunk, outputAccumulator
Instead of 'result' use: computedScore, lookupOutcome, validationStatus
Instead of 'count' use: itemCount, retryAttempt, errorTally
Instead of 'index' use: currentPosition, insertionPoint, searchOffset
Instead of 'item' use: currentOrder, selectedProduct, queueEntry
Instead of 'obj' use: the specific type name — person, connection, response
Instead of 'str' use: formattedName, rawInput, encodedPayload
Instead of 'num' use: quantity, threshold, portNumber

THE PRINCIPLE

The name should answer: WHAT does this represent in the problem domain? Not WHAT type is it.

BAD: temp <- customer.getAddress() what IS temp?
GOOD: billingAddress <- customer.getAddress() clear purpose

BAD: data <- sensor.read() could be anything
GOOD: temperatureReading <- sensor.read() obvious meaning

ALWAYS ALLOWED

- Single characters: x, y, z, i, j, k (math and loop convention)
- Compound words containing banned words: connectionState, errorHandler, dataProcessor
- Type-qualified names: the type carries semantics (amount as Money, thrust as Dimension)

See Q290 for the complete banned list. See Q296 for research evidence.

Example

defines module qa.naming.alternatives

  defines function

    <?-
      Shows descriptive alternatives to banned names.
      Every variable name tells you what it represents.
    -?>
    processOrder() as pure
      ->
        unitPrice as Float
        orderQuantity as Integer
        discountPercent as Float
      <-
        finalPrice as Float: 0.0

      // NOT: temp <- unitPrice * orderQuantity
      subtotal <- unitPrice * #^ orderQuantity

      // NOT: value <- subtotal * (1.0 - discountPercent)
      discountedAmount <- subtotal * (1.0 - discountPercent)

      finalPrice := discountedAmount

    <?-
      Shows compound words with banned roots — these ARE allowed.
    -?>
    describeConnection() as pure
      ->
        connectionState as String
        errorHandler as String
        dataProcessor as String
      <-
        rtn as String: `${connectionState}: ${errorHandler} via ${dataProcessor}`

  defines program

    NamingAlternativesDemo()
      stdout <- Stdout()

      // GOOD: descriptive names
      totalPrice <- processOrder(29.99, 3, 0.1)
      stdout.println(`Order total: ${totalPrice}`)

      // GOOD: compound words with banned roots are allowed
      summary <- describeConnection("active", "retryHandler", "jsonProcessor")
      stdout.println(summary)

      // GOOD: single-character math variables
      x <- 3.0
      y <- 4.0
      hypotenuse <- sqrt(x * x + y * y)
      stdout.println(`Hypotenuse: ${hypotenuse}`)

      // GOOD: type carries semantics
      orderCount <- 5
      isActive <- true
      customerName <- "Alice"
      stdout.println(`${customerName}: ${orderCount} orders, active=${isActive}`)

Common mistakes

E11031 — 'data' is a banned non-descriptive variable name in EK9 — use a name that says what it represents (e.g. hypotenuse). See ek9 -h E11031 for details.

Incorrect:

      data <- sqrt(x * x + y * y)
      stdout.println(`Hypotenuse: ${data}`)

Correct:

      hypotenuse <- sqrt(x * x + y * y)
      stdout.println(`Hypotenuse: ${hypotenuse}`)
Other ways to ask this
  • What are good alternatives to temp, value, data in EK9?
  • How do I rename banned variables in EK9?
  • What descriptive names replace banned identifiers?
  • Give me a renaming table for EK9 banned names

Coming from another language?

Java: no naming enforcement, relies on optional SonarQube rules. Python: PEP 8 naming is voluntary. Rust: clippy provides optional naming suggestions. Go: golint suggests naming conventions. EK9: compile-time naming enforcement — generic names are compiler errors, not warnings.

Keywords: replace, banned, descriptive, rename, alternative, variable, E11031, naming