loading...

re: Writing code for your future self VIEW POST

TOP OF THREAD FULL DISCUSSION
re: // this is a user object or undefined, should probably use `some` instead of `find` const isUserPostCreated = users[0] && posts.find(post =...
 

I see no issues with reading your code, plus what I provided in the article are only meant to serve as suggestions. My own examples could definitely be improved as you showed.

I do prefer adding a variable over a comment though, because as you said: comments become stale.

But yeah, this stuff is hard sometimes 😅

 

Variables become stale too :v
Don't tell me you have never seen something like

isValid.forEach(name(true))

They are easier to update though, since once someone finally realizes what that damn thing represents, they can apply a "rename identifier everywhere" refactoring tool.

Haha, yeah good point. I agree that they are easier to update.

I like to use comments as a last resort to explain why a piece of code is written in a certain way or exists in the first place.

code of conduct - report abuse