File tree
Expand file treeCollapse file tree1 file changed
+15
-2
lines changed Expand file treeCollapse file tree1 file changed
+15
-2
lines changed Original file line number | Diff line number | Diff line change |
---|
@@ -193,8 +193,21 @@ function createMicrobrewery(name) {
|
193 | 193 | **[⬆ back to top](#table-of-contents)**
|
194 | 194 |
|
195 | 195 | ## **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. |
198 | 211 |
|
199 | 212 | **Bad:**
|
200 | 213 | ```javascript
|
|
You can’t perform that action at this time.
0 commit comments