DEV Community

loading...

Discussion on: Do you have a process for naming things?

Collapse
jckuhl profile image
Jonathan Kuhl

Functions:

  • How succinctly can I describe what the function does? Can I make this succinct function its name? Here's a function that fetches football scores off ESPN:
async function fetchScores() {
    const scores = await fetch(urlToEspn);
    return scores;
}

See? Does what the name says.

Variables:

  • What does this variable hold? const person = new Person() Gee, i wonder what person is.

Objects

  • What it is, and first letter of the type is capitalized, always.

Methods of objects:

  • avoid naming the object in the function, example filereader.readfile(). I know that it comes off the file reader object, so naming the method readfile is redundant. read() is fine. filereader.read()