re: Do you have a process for naming things? VIEW POST

FULL DISCUSSION
 
  • variable names in camel case, uppercase combos gets camel cased too:
const filePath = "";
const displayAsap = true;
  • Boolean variables always positive :
const fileExists = true;
// not "fileEmpty" or "fileNotExist" 
const reportErrors = false;
// not "ignoreErrors" 

plural for arrays:

const routes = [];

for (const route of routes) {} 
  • length of arrays/list gets "count" appended, the target is in plural:
const routes = [];
const routesCount = routes.length;
  • Boolean properties gets "enabled" appended to their names:
class Request {
  static debugEnabled = false;
  static cacheEnabled = true;
} 
  • Get, get...s, delete, delete...s, enable, disable, enabled, add, add...s, set, set...s, has, store, read, display, for method names :
class Request {
  static _debugEnabled = false;
  static _routes = [];

  enableDebug() {} 
  disableDebug() {} 
  debugEnabled() {} 
  addRoute() {} 
  addRoutes() {} 
  setRoute() {} 
  setRoutes() {} 
  hasRoute() {} 
  hasRoutes() {} 
  deleteRoute() {} 
  deleteRoutes() {} 
  getRoute() {} 
  getRoutes() {} 
  storeResponse() {} // only for writing in file
  readResponse() {} // only for files
  displayResponse() {} 
  displayErrors() {} 
} 
  • Am not a code nazi so methods that do not display or CRUD can be named normally:
class Router {
  get() {} 
  post() {} 
  listen() {} // this one 
} 

For Vue component gets "item" if sub components:

component/
  Breadcrumb.vue
  Breadcrumb/
    Item.vue
  Menu.vue
  Menu/
    Item.vue

I try to stick with this as best as I can to keep consistancy 😅

(really need to write those somewhere...)

code of conduct - report abuse