User Tools

Site Tools


en:devmon:guidelines:variables

This is an old revision of the document!


Variable Name

In General

  • Avoid CamelCase and variation: use underscore
  • As short as possible to describe the “function” of the var: sample my $desc = “devmon is cool”

With or without "s" at the end

  • scalar($) and hash(%) without “s”
  • array(@) with an “s”

Avoid ambiguous names

  • last (final or previous)
  • set (adjust or collection)
  • left (direction or what remains)
  • right (direction, correct or entitlement)
  • no (negative:non or number)
  • record (verb or noun)
  • second (time or position)
  • close (nearby or shut)
  • use (active_usage or category of function)
  • term (terminal or termination)
  • temp (temperature or temporary)
  • val (value or valid)
  • Avoid too short names that dont give a real benefit: prefer good readability
  • prop(erty), val(ue), str(ing), num(ber), idx(index), but use it as postfix {variable}_XXX
  • i, j, k, x, y, z

Do not use

  • list, set, value, equals, data, var,

Quantity

  • {variable}_count
    • : {variable}s_count
    • Hash: {variable}_count
  • Linear Structure: , hash, list →{variable}_count
  • Non-Linear Structure: Tree set: → {variable}_count, ?

Prefix

  • format: as_number, as_string,
  • boolean: is_number

Reference

  • {variable}_ref
en/devmon/guidelines/variables.1629351244.txt.gz · Last modified: 2021/08/19 07:34 by adminw1k1