Today I Learned - Rocky Kev

Tagged “cleancode”

  1. TIL not obsessively trying to be DRY

    Quite often, DRY is applied to any duplication, rather than specifically to the duplication of business rules and knowledge. This is often made worse by automated code analysis tools, which will often highlight any duplication as a code smell.

  2. TIL ways to organize eventListeners

    Some code spaghetti I made recently was creating a lot of eventListeners for multiple buttons, and then forgot what they all connected to.

  3. TIL Very Efficient Code

    This is a great solution. Easy to understand. Executes really fast. No real-time string concatenation. No over-engineering. String appearance is easily customized.

  4. TIL more clean code principles

    Functions should either answer something or do something, but not both. If you use third-party libraries, wrap them. Throw errors.

  5. TIL Cleaner data structures

    Avoid unnecessary contexts, optional chaining, better error handling, avoid using flags

  6. TIL Cleaner Functions

    tl;dr - Limit the number of arguments, Avoid executing multiple actions in a function, Avoid mutation, Avoiding non-negatives, Return Early

  7. TIL about this work of beautiful code

    I'm a strong believer in writing code for tomorrow's developer. I'm incredibly anti-code-golf. (It's a beautiful art form, but keep it out of production code!)

  8. TIL about the 11,000 line file

    At work, I discovered a core project file that is almost 4,000 lines of code. Code flowed from top to bottom. I thought this is what nightmares are made from.

  9. TIL of a guide for naming things

    Naming is hard. Naming is important because '.imgFloatLeft' no longer is accurate when we switch to 'ltr' format.

  10. TIL trailing commas in Javascript

    JavaScript has allowed trailing commas in array literals since the beginning, and later added them to object literals, and more recently, to function parameters and to named imports and named exports.

  11. TIL Grouping Event Handlers

    Group your event handlers together for that sweet cleaner, fresher code.

  12. TIL writing cleaner If statements

    Graphs and visual flow of various if-else statements

  13. TIL more about destructuring

    Destructuring allows us to extract values from arrays and objects and store them in variables with a more convenient syntax.

  14. TIL functions should only do one thing

    The most important rule of programming is - break your code into tiny bite-sized pieces. That makes it easier to compose, test, and add it.

See all tags.