Skip to content

Commit b8b382d

Browse files
committed
Drive home pont of limiting function arguments
1 parent d783297 commit b8b382d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

README.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,21 @@ function createMicrobrewery(name) {
193193
**[⬆ back to top](#table-of-contents)**
194194

195195
## **Functions**
196-
### Limit the amount of function parameters (2 or less)
197-
Use an object if you are finding yourself needing a lot of parameters.
196+
### Function arguments (2 or less ideally)
197+
Limiting the amount of function parameters is incredibly important because it
198+
makes testing your function easier. Having more than three leads to a
199+
combinatorial explosion where you have to test tons of different cases with
200+
each separate argument.
201+
202+
Zero arguments is the ideal case. One or two arguments is ok, and three should
203+
be avoided. Anything more than that should be consolidated. Usually, if you have
204+
more than two arguments then your function is trying to do too much. In cases
205+
where it's not, most of the time a higher-level object will suffice as an
206+
argument.
207+
208+
Since JavaScript allows us to make objects on the fly, without a lot of class
209+
boilerplate, you can use an object if you are finding yourself needing a
210+
lot of arguments.
198211

199212
**Bad:**
200213
```javascript

0 commit comments

Comments
 (0)