Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have a thought that I tried asking at SO, but didnt seem like the appropriate place. I think that source sites like Google Code, GitHub, SourceForge... have played a major role in the history of programming. However, I found that there is another bad thing to these kind of sites and that is you may just "copy" code from almost anyone, not knowing if it is good(tested) source or not.

This line of thought has taken me to believe that source code websites tend to lead many developers (most likely unexperienced) to copy/paste massive amounts of code, which I find just wrong.

I really dont know how to focus the question well, but basic thought would be:

Is this ok? Is Open Source contributing to that or I'm just seeing ghosts...

Hope people get interested because I think this is an important theme.

share|improve this question
    
Your question and argument are contradictory. You are basically trying to say that Google code results in bad code being copied. Open source has positive sides too, read Linux code and become better at the OS ?? :-) –  Geek Nov 29 '10 at 7:56
    
Do you have any evidence that this actually happens, with any significant frequency? –  ShreevatsaR Nov 29 '10 at 12:55
    
Are you saying that the world would be better if there was no source code available to anybody? I'm failing to understand here. If there is going to be source code, better it should be good source code, and OS has some features that tend towards good code. –  David Thornley Nov 29 '10 at 15:26
    
Don't get me wrong, Im very pro-Open Source, but im also a programming professor and I wanted to discuss the matter with all of you to see how many people thinks that Open Source MIGHT lead to bad programming practices. Focus on the "MIGHT" and see is not a "DOES" –  David Conde Dec 3 '10 at 5:46
add comment

10 Answers 10

up vote 43 down vote accepted

Correlation doesn't imply causation. Developers copy/paste code they don't understand because they're bad developers. The availability of such code doesn't turn good developers bad.

If there were no open source projects, there would still be forum posts with code snippets or programming books with examples. So we're back to my first paragraph: bad developers will find a way to be bad at writing code. The blame for copying and pasting code lies with the developers who do it, not with the source code repositories.

share|improve this answer
18  
And actually, I'm sure that "bad developers" currently copy/paste bad code from forums, more than from github... –  David Nov 29 '10 at 8:36
2  
+1 - I remember this happening back before the days of the internet even - going and finding another application someone in the team had written, grabbing a routine and pasting it in. Open source may have spread a little more temptation around but it's not the cause by a long shot. /endoftediousoldwarstories –  Jon Hopkins Nov 29 '10 at 8:38
    
Worst code i've seen was closed source proprietary stuff. Even student stuff could not measure up to the shear monstrosity this thing was... yet... it is still used daily by users oblivious to the monster within –  Newtopian Mar 1 '11 at 9:06
add comment

I don't think too many developers copy-paste from large open-source projects. It's just too much work to find the right spot in thousands of lines of codes, and it could be different (at least for a bad developer) to find out which part to copy. They rather copy-paste small snipplets found on forums, articles, examples etc., where everything is nicely put together.

share|improve this answer
    
you forgot to precise "nicely put together, but unfortunately for a slightly different problem than the task at hand"... that is the cause of troubles :/ –  Matthieu M. Nov 29 '10 at 20:15
    
Matthieu: not only that, often they are outdated, or even incomplete or syntactically wrong - but they are sooooooo easy to copy-paste!" –  user281377 Nov 29 '10 at 21:39
add comment

For each 100 programmers that just copies/pastes code without knowing what he's doing, there's almost one that doesn't.

Before Google Code et similia there were snippets all around the web that people copied/pasted, so I don't really see the problem as being relelated to this kind of sites.

share|improve this answer
3  
Perhaps the problem is with the world itself.... people will be people –  David Conde Nov 29 '10 at 5:58
add comment

Isn't one of the big principles of coding "don't re-invent the wheel"?

If you copy bad code and doesn't learn from it, then it's your bad. If you copy great code and learn from it, then you're a good programmer going on great.

share|improve this answer
add comment

My opinion is that there are good open source projects and bad open source projects. The availability of good open source projects that can be found on sites like Git Hub allow the sort of beginner programmer that will one day end up as a good programmer to have an almost endless source of good code to look at and study and (if desired) copy. The thing is that the sort of person that ends up as a good programmer is almost incapable of just copy and pasting code. They want to look at it and take it apart and modify and understand what makes it good and what could make it better and what would make it worse. By the time they're done, it's their code and they understand how it works.

It does make it more convenient for bad programmers to be bad programmers but so what? It's sort of like the flaw in javascript where

i = 1

creates a global variable i and

var i = 1

creates a proper local variable. This makes it possible to spot crap code in a second by all of the inadvertent global variables laying out all over the place1. The fact that it's easier to copy and paste projects together means that it's easier to spot crap code because it will be littered with the sort of vestigial limbs that were adapted to the conditions that it came from and not the conditions it's currently living in.

1 The lack of global variables doesn't of course imply that the code is good but it's a promising sign

share|improve this answer
add comment

Everyone has some sort of motivation for releasing their code in a manner that allows other people to use, modify and re-distribute it.

Some of the reasons:

  • You feel the code is useful, and would be useful to others
  • You feel the idea is useful, and hope more experienced people will refine the implementation
  • You are obligated by a license to release the code for modified binary executables that you distributed
  • You hope the availability of the code will help boost your business

Other reasons, of course come into play, or perhaps a combination of reasons. Your question seems to hinge on an assumption that code released into the wild should be of a minimum quality, which I think is overly idealistic.

Additionally, I think more 'copy and paste' coding results from reading a 'tutorial' that someone posted on a blog with snippets, not from someone who took the time to mine through github to find something that might solve a problem. Yet, using examples from a five year old 'quick start' guide you bought at a used book store might be equally dangerous.

Good programmers avoid the mistakes that inexperienced programmers tend to make, that will always be the case. You often learn how to avoid these traps by falling into them.

share|improve this answer
add comment

At first there's no exact definition of good code. You may take two parts of good code and combine them, and get bad code. Just because code styles are different.

Bad programmer copy-paste bad code, write bad code.

Good programmer copy-paste good code, write good code. Good programmer will not paste bad code.

But open source give us great chance not write same code again and again, but

share|improve this answer
add comment

This question is impossible to answer.

However, if you are asking with respect to yourself, e.g. "does the presence of freely available code that solves problems that I'm dealing with make me a sloppier or worse developer," then there's a very simple and collaborative solution to your anxiety.

Find a project that you use, support, or find interesting, and see if you can involve yourself with it. Write some code, write some test cases, or provide some documentation. Whatever you end up doing, you'll be working with and evaluating the code you're using, and helping out a project you support.

share|improve this answer
add comment

Open source tends to good coding, since you cannot hide your bad code behind a working application, you need to code well otherwise you are out of game. Understanding and copy/pasting a good code doesn't make the developer worse (do not confuse with copy/pasting instead of doing a proper design). And, as mentioned in another answer, a bad programmer will find another ways to produce bad code if there were no available source codes.

share|improve this answer
add comment

Theodore Sturgeon said "90% of everything is crud" and that applies to open source software as much as anything else. There are many, many projects on Sourceforge which are a dump of one or two people's unfinished code, and nothing happened since the first upload.

That doesn't mean open source software is intrinsically bad or lower quality. Good projects have higher quality because

  • if you aren't getting paid in money, the reward you are earning is the respect of your collaborators
  • everyone can see your work
  • versions get released when they are ready, not because some commercial imperative forces them to be released half-done

If you are assessing open source software you might want to adopt, you want to find out if there is a large enough community using it so if the current developers can't or won't support it, there will be enough interest and demand in alternative ways of maintaining and developing it. You would ask the same question about commercial software.

I would like to highlight the Apache Software Foundation's work to identify promising open source projects, give them resources and help support them through an "incubator" stage so that they can develop enough momentum to be viable in the long-term. While of course there are many other excellent open source projects around, if a project has achieved ASF top-level status you can have some confidence about its quality and viability.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.