11. Funciones

Functions should do one thing. They should do it well.

=> Evitar los side effects => Regla de oro: mantener el indentado en 2 (o 3) niveles

checkPasswordAndCreateSession(credentials)
 /* => */
checkPassword(credentials)
createSession(credentials)

Argumentos: 0 > 1 > 2 > 3

=> Usar orientación a objetos

=> Usar punteros a objetos

credentials.checkPassword()
credentials.createSession()
const drawPoint(x, y, r)
const drawPoint({x, y}, opts)

No modificar los argumentos de entrada => Evitar los side effects

Excepciones >> Error Codes

=> Error Handling is ONE thing

Last updated