Is it a bad habit to look at code examples or other people's code when working on something?

Working on React my mental models are a bit slow when it comes to HTML manipulation with JSX. But I am able to move at a fair pace when looking at other people’s code. Just curious, is that a bad habit to get into? I’m not sure if it would be better to just force myself to think it through cold and just test/debug until I get stuff working.

@SeanDez no - its a good way to learn. You’ll see good code, bad code, middle of the road code, and over time all of it will make you a better programmer.

Reading lots of code is good. Just try and come with your own solutions by synthesizing what you’ve learned.

1 Like

As long as you understand the code after reviewing it. There’s nothing wrong with reviewing other’s code as long as you’re not copying it with the intent on passing it off as your work or if you use their code, give them credit.

2 Likes

Any programmer that says they learned to program without looking at other people’s code is lying.
That’s a fact.

Looking at other’s code is a good way to learn.

In fact, being able to follow along other people’s code is a good/necessary skill to have.

When you’re at work, you will not be always creating code from scratch on a new project. A good chunk of your time will probably be maintaining code made by other people, performing upgrades, adding new features, fixing bugs, etc.

1 Like

There is one thing that will make you a better coder than the average person. It is being able to take pieces of prewritten code, and put those pieces together to make your project work.

Anyone that tells you that that’s not true or they don’t do that, is an absolute liar. I have been freelancing as a dev for the last couple of years. I think that last piece of code that I actually wrote from scratch was in school. That was only because they had a plagiarism checker.

To be an awesome and efficient developer, all it takes is defining what you need for what you are doing, find similar sites that do what you are trying to do, taking chunks of code from them, and piecing it all together so that it works for your specific needs.

Again, anyone that tells you that that’s not true or they don’t do that, is an absolute liar!

1 Like

Have you used Google to search for an answer and come across a handful of stackoverflow articles? Someone else’s code, no? :stuck_out_tongue:

If I can see the code, then I churn it out. But if the image isn’t clear, I search old projects that I think might have an answer. Or the web. Then, I try to put that code into the context of my project and decide if it can work. There are almost always tweaks and changes that need to be done—like pounding a square peg in a round hole—but it usually puts me on the right track.

Searching to see if someone has already invented that wheel isn’t cheating… it’s being resourceful.

1 Like