Slashdot Log In
How Mainstream Can Code Scavenging Go?
Posted by
ScuttleMonkey
on Sat Dec 01, 2007 12:13 AM
from the unwanted-easter-eggs dept.
from the unwanted-easter-eggs dept.
The time-honored tradition of code scavanging has long been a way for new programmers to "break in" to a new language or task that they may not want to build from the ground up. The re-use of old code, cleaned up and tweaked to a new purpose can help developers learn many useful skills and accomplish tasks quickly, especially for small tasks that aren't of vital importance. One blogger wondered if this process could be formalized and tools could be built to help foster and enable code scavanging on a mass level. Is this a viable option, or are there just too many things to consider?
This discussion has been archived.
No new comments can be posted.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
Full
Abbreviated
Hidden
Loading... please wait.
IP Laws? (Score:4, Interesting)
Re: (Score:3, Funny)
Re:IP Laws? (Score:5, Insightful)
That's a great knee-jerk reaction. Without understanding the motivation behind the article, you assume that code scavenging means stealing other people's code. What they're really talking about is (legitimately) re-visiting code that you or other people have written, and then picking and modularizing bite-sized chunks. In other words, you would design a large program (mark I) and then go back and pick out useful parts, clean/debug them and have working modules (mark II) for the next project.
Also, for people who haven't read TFA, it's 9 short paragraphs long and barely an article. They talk about a "formal approach to code scavenging" without even coming close to explaining what exactly that MEANS.
Parent
Don't we call that "refactoring"? (Score:2)
You can then use those modules in other programs.
Re: (Score:2)
short answer: yes. and even before "refactoring" came into vogue, there were other names for it. hence, TFA is not really a FA.
Re:Don't we call that "refactoring"? (Score:5, Funny)
It leaves us only "the". Which is an article. Liar.
Parent
Re:IP Laws? (Score:5, Interesting)
Agreed. Reading TFS, I thought it was going to be yet another "we can make programming like Lego!" thing. (Which it ain't, and probably never will be. [joelonsoftware.com] Bonus reference: "Lego" is mentioned in the second paragraph of this article [wired.com] about Steve Jobs/NeXT/WebObjects from Wired. God bless Wired and their eternally fucked-up CMS that can't serve images for any story in the archive and, this week, shows the actual HTML code that should be formatting the Question-and-Answer portion of the article.)
Reading TFA, I really don't know much more than I did before. This is the best I could come up with:
So, code scavenging is... um, re-use? Can anyone make better sense of that than I can?
:-)
"In other words, they 'scavenge' the good bits and tweak them to a new purpose."
Um, no. You scavenge the pieces you need, not necessarily the good bits. Have you ever been looking for some code to do parse phone numbers, and while looking at source, said "Hey! This looks like a great way to compare two lists!" Probably not. You're only looking for formatting code, so that's all you see, so that's all you get. Looking at source is not like looking at produce at the food store, where you can walk by the tomatoes and they catch your eye because they're perfectly ripe and really, really nice-looking.
Rather than searching Google, I think every good programmer should take the time to create a really good library. I don't mean take the time writing great code, I mean take the time to organize it into a proper library: make one, clean, well-commented version; put things into variables, ($tableName in queries instead of the actual table name, etc.) and pull code from that when you need it, rather than just copying-and-pasting from the last place you remember using it and then changing all the variable names, table names, etc.
I plan to make mine Real Soon Now.
>> So, how quickly would you run afoul of Intellectual Property laws doing this?
> That's a great knee-jerk reaction.
No, that's just the first thing that popped into his head. (Pardon me if I'm putting words in your mouth, Mr. Gambit.) With that one sentence, he did not say (or imply) "The only people who would use this are thieves." He just put out that question for people to discuss. That topic came up here just a couple days ago. [slashdot.org] I highly recommend reading that discussion. There are some very good points; among them, that if you publish something with no licensing info, it is copyrighted to you by default. (In the US at least,
Parent
Re: (Score:2)
Another good point in comment "every good programmer should take the time to create a really good library" And this should go without saying, build your own library of templates and snippets you carry as long as you do coding, often saves a lot of time. Some companies which use SM/CM ( source
Re: (Score:3, Insightful)
These are the ideas that CPAN, PEAR and other code repositories are built on. So instead of trying to reinvent the idea, the author should have poked around a little more, and to learn more about what is available as opposed to trying formalize a "hackup job."
The parent makes a good point here, where you should take the time to build a clean library base to work with. If one should have a well structured infrastructure, and should they need to implement a certain feature, more often is the case, that a g
Re: (Score:3, Funny)
Good point. I think I'll use it the next time someone comments about code of mine that is overly complex and convoluted.
"You see, all the simple ways of doing it
My reaction was different (Score:2)
So I am not sure at all to what extent this code scavenging is sufficiently helpful to make formalize
Re: (Score:2)
Some code cannot be copyrighted. HTML, for instance, cannot be locked away and hidden in a vault because it relies on being there so the browser can render it at the time of the download. Those, HTML is a great "scavenger" language, because it is easy to learn new techniques by poking around the "View Source" code.
Other code that cannot be copyrighted is copylefted. The GPL expressly guarantees that code can be used, studied, modified, and redistributed.
Now... formalizing a lesson plan to teach stude
Re: (Score:2)
I've been thinking of scavenging code from SCO... (Score:5, Funny)
Vernor Vinge (Score:5, Interesting)
Re: (Score:2)
Re:Vernor Vinge (Score:5, Insightful)
It is one of the most misunderstood concepts about programming. A programmer fresh out of college knows how to write algorithms really well, but has no idea that there are architectural and design land mines waiting for them just down the development road.
Too many development shops will get an app "working" and think that is all there is to development, because no one has the depth of experience to look a year down the road and see that they will need to rewrite the entire app from scratch in order to make the simplest of changes.
I'm sorry, but if your program is not extensible nor maintainable then you really haven't "succeeded" at anything. You've simply fooled yourself into thinking the process is simpler than it is while screwing your clients out of their development dollars.
Parent
Re: (Score:3, Insightful)
The method of assigning homework is to give 3 lines on what a program needs to do. For example, write an FTP client that you can use to download a file. The method of grading is if you can download a file or not. The decision on how to get the HW done with the least amount of time spent is an architectural challenge.
Which is what the parent hates: people who only think about getting the product out of the door and who sacrifice things like maintainability.
Even firefox and Mozilla did a few complete rewrites of the various parts. Rewrites are part of programming unfortunately. The nice thing about rewrites is that the programmers now have experience on how to do things better and are able to better compartmentalize the code. I wouldn't say rewrites are terrible things - though they do annoy management and people above to no end.
Firefox & Mozilla are prime examples of bad codebases. We all know the disaster that was the last rewrite in-house at Netscape.
_SOME_ re-writes are necesary and usefull, but a company where the usual way to add a new feature is a re-write of the whole software is doing somethign wrong.
code repositories (Score:3, Informative)
we scavenge code online w/e, find it needs to be used by a lot of people
so we inherit the scavenged and put it in a nice module and tada!
this is nothing new
semi-formalized (Score:5, Informative)
Re: (Score:2)
http://snippets.dzone.com/tags/ruby [dzone.com]
http://snippets.dzone.com/tags/ruby/http [dzone.com]
http://snippets.dzone.com/tags/python/windows [dzone.com]
http://snippets.dzone.com/tags/rebol [dzone.com]
And so on..
It's called a "subroutine library" (Score:5, Funny)
The Web 2.0 crowd rediscovers subroutine libraries. Film at 11.
Re: (Score:3, Funny)
You gotta punch it up, PHB-ify it: "Reusable Enabling Action-Oriented Web Object Architecture Patterns".
Re: (Score:3, Funny)
Instead, he answered "uh... cut and paste?"
Re: (Score:3, Funny)
Google Code (Score:3, Informative)
Re:Google Code (Score:5, Informative)
http://www.google.com/codesearch [google.com]
Parent
foreheat meet desk (Score:5, Funny)
And the first article suggests that trusting the code is an issue, because you didn't write it. Well let's see - it's short, and you just pasted it into your program. But you're not going to bother to read it? You fail. Seriously.
Re: (Score:2)
It might be a new idea for more people than you think. There is this ideal picture of people writing The Perfect Software from scratch, isolated from the rest of the world. And there is the other ideal, people assembling The Perfect Software
Re: (Score:2)
Isn't this a library? (Score:3, Funny)
"Scavanging"? (Score:2, Funny)
Unlikely? (Score:4, Interesting)
Since..when? Recently I've picked up perl again, and I've found more than what I need to scavenge to make my own personal extensions to blosxom [blosxom.com] through google searches.
I mean, granted, it depends on your definition of a bite-size task, but it's a blanket statement no matter which way you spin it.
Eh? (Score:2)
This is a great idea! (Score:4, Funny)
Maybe the C++ language could do it. Then you could just
Hmm, CC++AN sounds pretty dumb. It'd never catch on. Oh well.
Re: (Score:2)
Oh, c'mon! It has one potential use - It sounds like a munged pr0n version of something for Perl [cpan.org]. That alone would make the effort worth it, no?
Today Slashdot jumped the shark. (Score:3, Funny)
Seriously. I'm starting to lose brain cells when I read the "articles" these days.
Re: (Score:2)
It's already been done. (Score:2, Funny)
Re: (Score:2)
(and half a bazillion other projects... Hell, not it's been going on before Microsoft decided they needed a working TCP/IP stack for Windows 2000 or anything...)
Wow (Score:5, Funny)
Microsoft Popfly? (Score:2, Informative)
http://www.popfly.ms/Overview/ [popfly.ms]
Compare to other engineering materials (Score:2)
Standardized and well-understood components save a vast amount of effort in other engineering fields and help produce results that are more easily verified to be good.
Why not apply the same approach to software engineering? Isn't that the greatest promise of open source?
Re: (Score:2)
That is very different than taking a bunch of code, stitching it together, and building a system out of it.
The Title (Score:2)
This reminds me of another book ... (Score:3, Interesting)
Re: (Score:3, Informative)
Re:scavanging turds is mainstream (Score:5, Funny)
Indeed...we need a -5 Asshole.
Parent
Re: (Score:2)
A while back, I asked one of my programmers to write a routine to dump out a Perl structure. I said I needed it in about a week. Lo and behold, it worked on-time and all was good.
What is wrong with Data::Dumper? Or rather did you need something that worked with Data::Dumper?
Turns out, as any Perl expert here knows, my programmer simply took the Dump module, which dumps perl structures. I wanted to have the dump be a nice dynamic javascript html table thing, and my programmer told me no -- or rather that it would require him to do it from scratch, and of course now, a month later, we didn't have the time.
Having done a lot of work with Perl, I would say that Data::Dumper is the wrong thing to use for that. TemplateToolkit, OTOH, would allow you to quite quickly generate HTML based on your data structure. A competent Perl programmer shouldn't require too much time to do that, esp. if it is in a different document.
One more note (Score:2)
Ultimately, my point is that when you control every line of code, you aren't hampered by other people's restrictions. I would have been happy had my programmer written his own dumping code from scratch, but I also would have been happy had he started with the cpan dump code, searned from it, and created a derivative version. Hell, in this case, I'd have been happy if he had studied it to the point where he could have modified it easily.
Sadly here is where you are terribly wrong. They key to doing what you want to do is to understand what you want from the beginning, do the requirements analysis up front, etc. and so forth. There is a *huge* difference between dumping a Perl object (the way Data::Dumper does) and creating a nice HTML document from it.
Your programmer, if he was smart, grabbed the CPAN module, wrote a little wrapper around it, and integrated it into your application. If you had known what you wanted up front, he would ha