Copying code

Started by
4 comments, last by Endar 18 years, 6 months ago
On my first project that is something more complicated than a game of pong, I find myself copying a lot of code from other sources (not just cutting and pasting, obviously). Not simple stuff, but things that I've been trying to think how to make work for a while, and end up having no idea, I'll look at the source from a graphics engine, and seeing what they have, I'll try to understand it and then incorporate it into my code. Its just that I sometimes have a feeling that what I'll end up with will be only a fraction of my own work. Thoughts, criticisms?
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
Advertisement
Creating a non-trivial game involves a lot of problem solving. You could probably get by without seeing other people's solutions but it would take you a _lot_ longer.

I wouldn't worry about using other algorithms and ideas. As long as you understand the theory behind it and produce your own code then you are doing what 99%+ of programmers do.




+ based on my own, pessimistic, guess
What Kuladus said.

Especially when I was starting out, I used a lot of copy and pasted code which was then heavily modified. Even if I didn't exactly understand all what I was doing, I was able to figure out how to combine, for example, a mandlebrot set program using one graphics API (which I didn't have) with an example program for another graphics API into a single working mandlebrot set displayer, with zoom soon added :-).

Even now, there tends to be a lot of APIs which require a lot of boring boilerplate code, stuff which although in need of adaptation, won't change drasitcally. I've taken to wrapping such boilerplate code behind interfaces with sane, overrideable defaults, which helps cut down on the copy and pasting I do, even if it does end up with the same effect.
I think that it's sometimes important for you to sit down and try to solve a complex problem for yourself without even looking at someone else's source. It really starts to open new doors of greater understanding... Or even breaking up the problem and asking questions about it on these forums would be just as benefitial.
Please be very, very careful about copying your *own* code, though. :)
Quote:Original post by Zahlman
Please be very, very careful about copying your *own* code, though. :)


Which is the exact reason I never copy and paste more than 4-5 lines of code at a time. :D
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper

This topic is closed to new replies.

Advertisement