Hoc naming

From openreachtech/hora-skills-ort-core · View interactive version

Hoc naming is an AI agent skill from the GitHub repository openreachtech/hora-skills-ort-core. Naming conventions for the identifiers in code — classes, members, variables and parameters. Use when choosing or reviewing a name. The super-prefix a method name carries belongs to the method super-prefix convention; constants, to the constants convention; a skill's name, to the skill-updating conv

How to use this skill

Skill file

Shared: Naming

Summarizes naming conventions.

Class names

This is because there is no way to express "the plural of instances of a plural-named class."

// NG
class Users {}
const users = [new Users(), new Users()] // Cannot express "plural of instances of a plural class"

// OK
class User {}
const users = [new User(), new User()]

Name variables and properties holding arrays as plural nouns

// NG: named singular despite holding an array / expressing plurality with a List suffix
const user = users.filter(it => it.enabled) // holds an array yet named singular
const paymentList = payments.filter(it => it.completed)

// OK: plural form of the noun denoting the element
const enabledUsers = users.filter(it => it.enabled)
const completedPayments = payments.filter(it => it.completed)

A variable holding constructors starts with a capital

import MiddlewareCtors from './middleware-ctors.js' // an array of classes
import middlewareHash from './middleware-hash.js' // a plain object

The parameters of a higher-order function's callback

/hoc-higher-order-functions.

Naming abstract classes and derived classes

// Abstract class
class BaseSample {}

// Abstract class extended for the application
class BaseAppSample extends BaseSample {}

// Derived classes (super prefix removed and replaced with a distinguishing prefix; suffix "Sample" is kept)
class AlphaSample extends BaseSample {}
class BetaSample extends BaseAppSample {}

An interface name carries no distinguishing prefix

Method names are "predicates," not "complete sentences"

// NG: named as a complete sentence (object.isStatusValid() reads as "object is status valid?", which is unnatural)
isStatusValid () {
  return this.status !== null
}

// OK: named as a predicate (object.isValidStatus() reads as "object is valid status")
isValidStatus () {
  return this.status !== null
}

Property syntax and "messages to the receiver"

Method names start with a verb

Third-person singular verb → convention that the return value is boolean

object.isValid() // boolean
object.containsInvalidTag() // boolean (third-person singular contains → boolean)

Criteria for using abbreviations

Do not use non-ASCII characters in names

// Never use
class 😂 {
  取得 () {
    return null
  }
}

Avoid single-word class names wherever possible

Spell out the full role

Name a value for what it is, not for how it was made

Use American spelling

Prohibited words and redundant compound words

Property names

Datetime suffixes: `At` for an instant, `On` for a date

// NG
const modifiedFrom = ...  // does the value carry a time of day? the name does not say
const billed = ...        // a date or an instant?
const effectiveFrom = ... // a single instant named as if it were a range end

// OK
const modifiedAt = ...
const billedOn = ...
const effectiveAt = ...
const modifiedAtFrom = ... // range lower bound, suffix kept
const modifiedAtTo = ...   // range upper bound

Method names

Super-prefixes state how a method behaves

carries a super-prefix before its verb. Which prefixes there are, and what each one promises,

belong to /hoc-super-prefix-method-name.

still chosen by the rules on this page, so a method's name is settled here first and the

prefix is put in front of it afterwards.

Accessors (getter / setter)

Method name verbs (choosing among highly abstract verbs)

Contrasting terms

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.