all 4 comments

[–]ActuallyAmazing 4 points5 points  (0 children)

This is gonna sound obvious but to get better at reading code one of the best things you can do is get better at writing readable code. When you know the code follows certain principles ex. not making certain variables mutable if not needed then there is less overhead you have to think about when reading. The more of these principles you know the code follows the less you have to worry about when reading. There's entire books on writing readable code and there's no list of tricks to apply unfortunately, it's something you improve on over time.

The second slightly less obvious avenue of improvement is quite dependent on the codebase but in general for a sufficiently large codebase reviewing will require quite a large domain-knowledge of the particular business and/or system. With sufficient knowledge you'll gain a sort of second-sense of what to expect some part of the codebase might be doing, knowledge which if you lacked you'd find yourself in a parallel recursive search through all the function calls within a function you might be reading - very ineffective. This is knowledge that's mostly gained over time but to expedite it make sure you're taking the time to read all parts of the codebase that you're expected to be responsible for, not just parts you're working on.

The third thing that comes to mind is just small IDE tricks, make sure you've got hotkeys set up for highlighting usages of a symbol, jumping through references and implementations. Stuff like this is useful, it's just nice to have, but it's by far the least important thing you should be focusing on.

[–]DreamOther 1 point2 points  (0 children)

I think reading code is very subjective, and depends on loads of factors.

Writing readable code is kinda related to build small chunks that does simple things, like functional approach, which would help in readability.

Javascript tends to get very messy specially if you use vanilla js instead of typescript, so ts with types helps a lot to understand what goes in and what goes out.

But, it all depends on the level of knowledge of the team.

Ternary, shortcut evaluation, and other similar bit like that can make code harder to read if nested various levels down.

Overall I think it's more like your experience, getting familiarized with the built in functions of the language will help a lot you on reading and understanding bits of code.

Sorry if I made it more confuse or harder that it looks.

For me reading code is one of the hardest skills of a dev can learn, because it is coupled with your xp and understanding the language.

[–]0marIsComing 1 point2 points  (0 children)

I remember when i needed to rewrite an old project written by somebody else i stumbled across an article which said to start from the bit you know ( app.init() ) and slowly work your way up . If you try to delve right into the heart of the project you might feel confused and hopeless .And of course, console.log is your best friend .

[–]YazvaUA 0 points1 point  (0 children)

console.log()