12 Matching Annotations
  1. Sep 2022
  2. Mar 2022
  3. Mar 2021
  4. Feb 2021
  5. Oct 2020
    1. const debounceFunc = debounce(1000, false, (num) => {    console.log('num:', num);}); // Can also be used like this, because atBegin is false by defaultconst debounceFunc = debounce(1000, (num) => {    console.log('num:', num);});
    1. Looks like the problem is that debounce defaults to waiting for 0 ms ... which is completely useless!

      It would be (and is) way to easy to omit the 2nd parameter to https://lodash.com/docs/4.17.15#debounce.

      Why is that an optional param with a default value?? It should be required!

      There must be some application where a delay of 0 is useless. https://www.geeksforgeeks.org/lodash-_-debounce-method/ alludes to / implies there may be a use:

      When the wait time is 0 and the leading option is false, then the func call is deferred until to the next tick.

      But I don't know what that use case is. For the use case / application of debouncing user input (where each character of input is delayed by at least 10 ms -- probably > 100 ms -- a delay of 0 seems utterly useless.

    1. But recently I started to think about default values as some sort of a technical debt ... which is not a straight bad thing but something that could provide some "short term financing" get us to survive the project
    2. Right, and if most uses of an FTP service use new FtpService() the one that sets an alternate port will stand out (service.SetPort(12345))
    3. General rules of thumb
    4. The question about default values in general - default return function values, default parameter values, default logic for when something is missing, default logic for handling exceptions, default logic for handling the edge conditions etc.
    5. For a long time I considered default values to be a "pure evil" thing, something that "cloaks the catastrophe" and results in a very hard do find bugs.