4 ms·
> 3. Functions should have extensibility, put the required parameters as parameters and always include an “options” at the end. Each function can have defaults
by darkarmani 7y ago
> 3. Functions should have extensibility, put the required parameters as parameters and always include an “options” at the end. Each function can have defaults that you can extend, which means you need a deep-extend method:
No! Absolutely not! There is a time and a place for this, but it's nearly impossible to reason about the interface if any data can be passed in.
- EGreg 7y agoI think you misunderstand. It’s not that “any” data can be passed in. The options object is documented in every version. It’s just a place that lets future versions add named parameterd
- Madeindjs 7y agoIMO If a method take many parameters there is a chance that this methods have too many responsibility and can be cut into two methods.