DEV Community

Discussion on: Is it worth reading source code?

Collapse
 
alinp25 profile image
Alin Pisica

When I work on any project, I have a phrase in my mind that I confirmed in time "Learn to reinvent the wheel, but don't reinvent it". If I know how everything works under the hood, skip over spending time on this. If I don't know how to use it / make it, I'm going to make it for the first time from scratch. After this, if I have an opportunity to get over it, I'll use it.

Collapse
 
codemouse92 profile image
Jason C. McDonald

"Reinvent the wheel" is a funny phrase when you consider just how many times we literally have had to reinvent the wheel (compare and contrast: stone wheel, bike wheel, car wheel, ATV wheel, airplane landing gear wheel....). We absolutely need to know how to reinvent the wheel, otherwise we'd all be rolling around Flintstones style still.

That said, we should only be reinventing the wheel if (a) existing wheels don't meet our current needs, and/or (b) we have a specific original improvement in mind that will make the wheel better in a given use case. That, of course, means we have to know a lot about the wheels that exist. Ergo, your reason for reading source.

Collapse
 
joshcheek profile image
Josh Cheek • Edited

Best to consider refactoring before considering rewriting/reinventing, IME.

Thread Thread
 
codemouse92 profile image
Jason C. McDonald

Depends entirely on the code base. Rewriting is usually much quicker than refactoring someone else's spaghetti.

Thread Thread
 
joshcheek profile image
Josh Cheek

I'm advocating considering refactoring first, not saying it is always the answer.