# 11. Funciones

{% hint style="success" %}
Functions should do one thing. They should do it well.&#x20;

\=> Evitar los *side effects*\
\
\=> Regla de oro: mantener el indentado en 2 (o 3) niveles
{% endhint %}

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

{% hint style="success" %}
Argumentos: 0 > 1 > 2 > 3&#x20;

\=> Usar orientación a objetos

\=> Usar punteros a objetos
{% endhint %}

```jsx
credentials.checkPassword()
credentials.createSession()
```

```jsx
const drawPoint(x, y, r)
const drawPoint({x, y}, opts)
```

{% hint style="danger" %}
No modificar los argumentos de entrada \
\
&#x20;\=> Evitar los *side effects*
{% endhint %}

{% hint style="info" %}
Excepciones >> Error Codes

\
\=> Error Handling is ONE thing
{% endhint %}
