Today I Learned - Rocky Kev

TIL about this work of beautiful code

POSTED ON:

TAGS:

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!)

So this post Mohammad Faisal's The Greatest React Developer I Ever Met, is absolutely validating.

It’s a shame that I couldn’t understand my own code (if I looked at it after 3–4 months) but his code was so beautiful that a junior developer like myself had absolutely no problem understanding what was going on there.

export const SomeComponent = () => {

const userInfo = getUserInfo();

const profileDetails = getProfileDetailsOfUser(userInfo.id);

const aboutData = extractAboutData(profileDetails);

const personalData = extractPersonalData(profileDetails)

return (
<UserDetails>
<About data={aboutData} />
<PersonalInfo data={personalData} />
</UserDetails>
)
}

What I find beautiful is that you don't need to even understand React! But you absolutely can see what data is being pulled in, what's happening to the data, and how the data moves around.

Gorgeous.


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.