문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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.

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.

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.

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

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.

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

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.

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.

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 softwareengineering.stackexchange
scroll top