Today I Learned - Rocky Kev

TIL Very Efficient Code

POSTED ON:

TAGS:

I absolutely love this:

via https://www.reddit.com/r/ProgrammerHumor/comments/10dh6x1/very_efficient_code/j4lm8eg?context=3

Why I like it

via IntentionallyBadName

This code is part of the Dutch DigiD App which is an authentication app for Dutch citizens to log in to government websites for taxes and other government related stuff.

It's O(1)

via sebbdk

at some point discovered that nitpicking isolated bad code only serves to suck the soul out of my juniors.

via kalesandwichsincity

There are no awards for short code. Two types of coders would use this solution. Those who've written code for one month, and those who've done it for a lifetime. In-betweens can't resist over-engineering.

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

Unless called 1000 times per second, there’s no reason for optimizing this further. It’s better to have readable code and spend time where it matters.

via Glitch29

It's EXTREMELY easy to read. It's easy to verify that there aren't any bugs. It's not that long. And while performance is unlikely to matter here, it runs faster than any solution which involves string operations.


Related TILs

Tagged:

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.

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.

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.