Hacker News new | ask | show | jobs
by retrogradeorbit 4406 days ago
"They don’t tell you that a lot of programming skill is about developing a knack for asking the right questions on Google and knowing which code is best to copy-paste."

No, no, no! This always frustrates me. This is not 'coding' (maybe it is, and we should be doing less of it, and more programming). This is gluing together pre-coded snippets and trying to make it work. Continuing to do this is an impediment to getting better. Thinking that somehow this is what 'coding' is, is missing the point.

I will read a stack overflow page perhaps in a search for some direction, look at all the 'solutions' like surveying a landscape of others approaches to the problem. Then I'll throw them all away and code my own. Possibly it will share a lot with one of the answers, what I would consider a good approach. But a literal copy and paste just doesn't happen. I would consider a copy and paste a recipe for inviting trouble, because you haven't really reasoned through the problem yourself, and thus don't really understand the solution intimately.

Programming is a process of mental reasoning around your problem with an eye on the form of reasoning computers use, so you can express that reasoning to the computer in the language you're using. Because computers don't reason like humans 'reason' (ie. humans don't really 'reason'...), knowing how a computer reasons and behaves is alien and takes time to understand and learn and it takes time to become quicker at comprehending this. This is the path of becoming a better programmer. Gaining that experience so the process is less alien and you more easily can fathom how a computer will respond and behave with a certain approach of laying out of the logic you are trying to express.

Copy and paste doesn't help you at all with this. In some cases it may prevent you learning essential lessons and hinder your improvement.

14 comments

> Copy and paste doesn't help you at all with this.

Generally I agree with this, but there is a way to use copy-pasta as a learning tool. If I find a code sample that does what I want but don't understand it, here is what I do:

1. Add a comment with a link to the source for reference.

2. Rename the variables.

3. Comment the parts that I understand.

4. Flag the parts I don't understand with a simple // ? comment.

5. Research the parts of #4 until I understand them, and then update each comment accordingly.

#2 is incredibly important to me. I've been doing some walk-through tutorials lately (e.g., http://learn.knockoutjs.com), and if I use the same variable names as the tutorials suggest, then I'm just transcribing. The code doesn't stick in my head, and I'm not really learning as much. But once I start changing the variable names, then it sticks.

#3 might seem like a waste of time, but I've found with conceptually difficult code, having the #3 comments helps keep me grounded if my brain gets too muddled.

There should be one more step:

6. Make changes to it so that it does the same thing, but in a better way -- faster, smaller/more concise, etc.

I think that being able to do this (correctly) is to truly understand, since then you are "thinking beyond the code" and can see the problem that it solves, not just an implementation that solves it.

Absolutely disagree.

I personally learned (as I think many people did) by copying code out of books. Whenever something went wrong, I had to figure out whether it was my typo or the book's typo or my conceptual error or the book's conceptual error. That process helped me to learn a lot, and quickly. If everything went perfect, I got to play some creative game which I loved and gave me a sense of acheivement that helped me to progress.

I no longer do this, because it's not relevant to me at this stage of my learning, but I view that as an important part of my early learning process. If you reflect on your own early learning process, I would be extremely surprised if you didn't copy and paste code. Frankly, you are surely still dependent on other people's code now, you just might call it a 'library' instead.

I agree if you're saying professional developers should avoid copy-paste (there are also legal consequences), but new learners can make great progress by using copy-paste. I would say it's an essential part of studying what other people have done.

Do note that there can be a difference between copying code from a book (where you have to read each bit of the code and write it down) and simply hitting ctrl-c ctrl-v, in terms of what you learn.
I think there's a large difference between copy-paste and what you're describing (which I'll dub 'manual transcription'). I have no formal training in learning or cognition, but I do have quite a bit of personal, anecdotal evidence to suggest that manual transcription is far more useful, from a pedagogical standpoint, than straight copy-paste.

Rather than take a boring example from my programming career I'd rather draw from my brief mathematical studies in college. In undergrad I was taking a course on Real Analysis. The course redefined, much more rigorously, certain concepts that I had understood at a much higher level--think the limit, derivatives and the Riemann Integral. Suffice it to say that these new concepts challenged my understanding of introductory Calculus, and when I was tasked with writing proofs based on the underlying concepts (e.g. neighborhoods), I struggled.

In what can only be described as frustration I decided I was going to start copying the proofs over and over. I repeatedly transcribed half a doze proofs for a few days straight (I did each one a few times each night). A strange thing happened. I began to understand the proofs. By that I mean I started to understand the intuition required to make the transition between each step of the proofs. At that point I found the material much more accessible. Reading the book was easier, the lectures made more sense, I could do homework, and consequently I could complete the exams.

I like this example because there is no copy-paste alternative. I had to engage with the material, but I chose to engage at a very mechanical level. Still, there was something about the process of reading and writing that aided in understanding the material.

I don't believe you can get that with copy-paste unless you find some other way to engage with the code.

I'm very interested in whether or not manual transcription is pedagogically beneficial.

I personally write a lot. I certainly find it useful to do that.

However, I would not normally recommend Zed Shaw "Learn Code the Hard Way" type of method of writing out over and over again. I think it probably works and you can do it yourself, but I think it's quite inefficient. I don't need to type 10 PRINT "HELLO" 20 GOTO 10 more than once to get a good sense of what's going on.

I think you most of all benefit here from the time you're forced to put in. If you can understand nothing, there's really no other sensible thing that allows you to concentrate for the time you need to make decent progress.

However, I don't think this means transcription is pedagogically ideal. IMHO building something for yourself is more effective; getting expert tuition is more effective: in terms of time spent vs benefit received.

I completely agree with you and frankly I'm shocked to see most of the responses here purporting copy-pasting someone else's code to be a legitimate practice. I also imagine that most if not all of these people are into web developed where there's a long history of copy-pasting snippets of code and no one knows what he's really doing. I've seen many people write a jQuery script for their website and calling themselves developers. You're not a developer, you're mashing together tools you don't really know how to use in the hope that everything works out. On the browser you're working with a single thread, in the real world you're always dealing with multi-process/multi-thread programs that inevitably lead to race conditions and deadlock. I doubt anyone involved in systems programming thinks is normal to copy and paste code to "get things done", it's just not gonna work.
Same. I'm actually a little shocked HNers think regularly coping and pasting code snippets off the web is ok. That's, kind of crazy.

This is bad especially for young developers (such as myself). Not to mention jeopardizing the security and integrity of your software project.

I hear 'don't reinvent the wheel' often written in blogs etc. That is not good. The lazy developer would read that and go, 'oh, I dont need to know how these things work, it's already been done for me. I'll just slap A to B, no need to reinvent anything'

Imo how it should read instead is, 'keep reinventing the dam wheel till you understand how it was made, only then you're free from reinventing it'.

> I'm actually a little shocked HNers think regularly coping and pasting code snippets off the web is ok

I'm not surprised.

Ever observe threads about software engineering? They're profoundly anti-intellectual. HN is not the place to get any sort of engineering advice, I'm afraid. It's tailored towards self-promotion via programming. The difference may seem small, but the motives are quite different: mastery (as a developer) vs getting it done.

The HN engineering and programming community seems to me to consist of a wide variety of different groups and types of programmers (coders/engineers/whatever).

It shouldn't be surprising that there is a group who feel "I'll just slap A to B" is a good idea (that's not what happens every time somebody copy-and-pastes, by the way--it's one extreme example, and it's possible to copy-and-paste with a deep and mature understanding of what one is doing). Just like it shouldn't be surprising when certain elements of other groups chime in with comments implying CS is some deeply intellectual study of the fundamental nature of mathematics and logic, and if a programmer isn't treating his Enterprise CRUD App X as a means to engage in a deeply intellectual study or application of algorithms, data structures, and complexity analysis he's doing it wrong, or he isn't a real programmer, etc.

The thing is you can copy and paste code snippets properly and responsibly and try and learn at the same time. Or you can just patch over something and hope it works (a lot of the time it will).

My first job was doing Perl, after studying Java. The Perl cookbook was a godsend, and basically encouraged copy pasting BUT had a discussion on the different methods presented and advantages of each one. I personally found that a very good way to learn.

This is one thing I find nice in the Perl community. I haven't used Perl for a few years now, but I always found PeelMonks a lot better then Stack Overflow, because it encourages the discussions that Stack Overflow discourages. Essentially it encourages the bad type of copy pasting I have described.

You seem very confident of your assessments. To the point you'll even suggest HNers who don't see things as you do are crazy.

Are you aware of the notion that expressed confidence tends toward being inversely proportional to competence? And that this is a key to insightful learning?

You've said you're a young developer, so perhaps you haven't recognized this aspect of mind yet, but there's plenty of solid science (as well as anecdotal examples such as your confidence/competence in this exchange may be) that corroborate the essential truth of this aspect of mind.

Of course, I may well be wrong about applying that knowledge to this scenario, so I'm not going to claim confidence or competence in applying it, just that it seemed apropos. :)

I didn't call anyone crazy, it's the idea of copying and pasting code into a professional project that I think is crazy.

That's how I was schooled by senior devs, whose opinion I have profound respect for. The reasoning is sound to me, I'll stick with it. Unless, someone has better reasons why I should copy and paste code, I would consider it.

IMO it should be "You can't reinvent the wheel, but you can study physics to understand how the wheel functions."
I copy and paste code all the time. I'm in the business of getting shit done, not learning everything ever, I don't need to learn the ins and outs of some obscure algorithm I'm only going to use once. I also don't need to memorize Apis and boilerplate for technologies I rarely use. Of course once i'm settled into a domain I don't need google anymore. But it's invaluable for quickly diving into new stuff.
Please never stop doing this. I get paid $$$++ to swoop in after people like you are done and whole teams grind to a halt productivity-wise because the codebase is so bad.

You are doing god's work, son. Thank you.

There is a fair amount of code you should copy/paste unless you are doing pure research, some because it has been so well studied it is almost a certainty that you are not going to drastically improve on it and others, such as encryption implementations, because it is actively dangerous to fuck about with unless you are extremely careful and a domain expert.
If you're copy-pasting encryption implementations rather than using an existing library, you're probably doing it wrong.
Well yes, but libraries are really just an advanced form of copy/pasting and you can still do damage by using the library incorrectly, so you often end up using sections of examples by the people who wrote the library or who are otherwise experts in its use on how to implement the library correctly.
Sure, you can argue that library use is copy-pasting, if those snippets you're pasting come with regression tests and have been code-reviewed by multiple people.

I'm going to go ahead and suggest that a tremendous number of encryption mistakes are made specifically because people copy-paste library invocations without understanding what they're invoking and why. When you just sling a chunk of code into a project without understanding what you're doing and why, the potential for bugs goes through the roof.

Now I need to go buy another keyboard. Thanks :)

To the GP: Swizec has it, please don't stop.

please define $$$++?
It means 'lots of money'.
...."lots of money" varies from community to community.
Which is why saying lots of money if more useful than specifying an amount, because that amount may or may not be a lot of money where the reader is from, but might be a huge amount where the person who posted it is from.
Well, you take a dollar amount. Then you increase it. Then you increase it some more. Because companies who can afford it will pay you pretty much anything if you can make their whole engineering team even just a few percent more productive by improving the codebase. Or can figure out very hairy issues caused by Daily WTF style situations.

For example, I have a friend who sometimes fixes bugs in compiled software running banking systems with no access to the original code and woefully out of date documentation. He gets paid some 300eur an hour in a country where the median developer salary is only about 30k eur per year (about 14eur/h)

Sure, that particular type of problem likely/hopefully isn't caused by copy-paste programming, but it is caused by the sort of endemic issues copy-paste programmers to produce.

IMO, as it often turns out to be, whether or not the code is copied and pasted doesn't matter by itself.

A competent programmer borrowing code would likely factor it in in a way that won't present maintenance burden later on, and first of all would know when borrowing is appropriate. An incompetent programmer may produce problematic code even regardless of whether it's borrowed or original.

(Though I'd agree that incompetent programmer borrowing chunks of code from different sources without thinking is ‘worse’ than same programmer just writing bad code by himself—more predictability in the latter case.)

In my case, I regularly see borrowed code in projects that I maintain. As long as it's contained in an isolated module, documented (unless it's short and obvious) and used appropriately, I don't see a problem.

Interestingly, front-end code I work on seems to suffer from much worse-quality borrowing—it's like Python people lose all their discipline once they turn to JavaScript.

Agreed. I do actually copypaste code in some very specific scenarios. For instance, writing a string capitalization function for Javascript and not needing a whole string processing library.

Sure, you copy paste a line of code after inspecting it, and save yourself some half hour of time on a piece of code that is not core to the problem you're solving.

But I have never seen a programmer who says "I am in the business of getting shit done, so I copy paste code" to produce good code. Anecdotal evidence and whatnot, and my argument could be a bit of a strawman, but this is the sort of canary in a gold mine that I've found.

When a developer on my team says "I just want to get shit done", is when I start preparing for a lot of internal screaming down the line. Happens every single time. Every. Single. Time.

So no, while copy-pasting on its own is not the problem, it is a good symptom to look for.

Man... can I ask what led a company into the situation where they need to fix software without source code access? Did they rely on a vendor that went out of business? I imagine it is ancient software from the 80's or 90's?
To answer you, I'm 24, and an accountant by profession. From what I've seen, most banks still run some core functionality of their systems in IBM Mainframe, which includes JCL, COBOL and maybe other languages.

Because of space constraints then, file names were limited to 8 characters (someone correct me) and lines of code has fixed lengths. That already made commenting a nightmare. I have 'reverse engineered' scripts that were written more than a decade before I was born. Most have outdated documentation, filenames are a mess to figure out, and over time there have been automated conversion tools that were used to update language versions.

As I said, most of these systems still run some core functionality of the bank, and the people who wrote them ain't there no more, so banks have to shell out lots of money to either fix and maintain these, or to figure out what's happening so they can move to newer systems.

A form of anecdote could be that because IBM still make some form of x64 flavour Mainframe OS indicates that large corporates still have code that's potentially double my age.

I don't know the whole story, but seeming as this was banking software I wouldn't be surprised if it was indeed written some time in the 80's or 90's and the original developers were nowhere to be found.
Thanks for responding with a specific $ amount. I do indeed appreciate it.
Lol my code base is fine thanks. Maximizing productivity and writing maintainable code are not mutually exclusive.
You are being offensive here - going all as hominem rather than actually demonstrating any reason parent comment is wrong.
I read it a bit of a joke, not meant maliciously, and yet with a lot of truth to it.

I'm sort of in between "get shit done" and "fix other people's shit" in my work. Because I like to take pride in my work, and because I don't want to leave the full timers with yet more contractor mess, I take care to do my job as well as I can. And I prefer projects where I can be proud of everything I do.

But in the 'trenches' of unsexy work, where my ideals meet reality, neither I nor the full-timers always have the time, money, or expertise to do things right, and are sometimes even forced by management to just get it done.

And I don't always mind. I can be happy with the result because it serves its purpose, and I made both the managers and many customers happy, even though I cringe at the underlying mess we produced. I know it is likely to cause much more work down the road, and I would generally advise against 'ship first, refactor later', but I'm also okay with the idea that I provide work for specialists to fix my mess.

Can I call myself a 'programmer'? Or am I more of a 'code monkey'? Do 'real' programmers thumb their nose at my sometimes shoddy code?

I don't really care. I'm happy with my work, and with my solutions. My aim is to move towards being able to provide full, high-quality solutions, because that makes me happier. But it also makes me happy to creatively solve problems in a way that might be imperfect, or frowned upon by some.

The most important reason for me to provide good, solid, readable code is because I care about the full-timers I meet who don't enjoy fixing my mess, and because I don't want my client to get into trouble later. That's why. It's primarily (but not exclusively) because I work with humans and I don't want to abuse my 'privilege' as a contractor and (relatively) skilled communicator to give other people headaches and crying fits over having to fix my junk. I've seen that happen, and it sucks.

(sorry, not necessarily directing this at you specifically)

You missed this part of the post then:

> whole teams grind to a halt productivity-wise because the codebase is so bad

Don't be ridiculous. That does not make "You are doing god's work, son. Thank you." any less ad hominem, nor do you actually demonstrate any reasons. Your argument amounts to "copy+paste coding is bad, therefore your codebase is bad", yet at no point explains why. But keep downvoting anyone who points that out :)
An ad hominem argument is one in which you reject a position not on its merits but because of who is making it. They took a position that copy/pasting code leads to unmaintainable code, therefore his argument is not ad hominem.

He's being insulting, sure, but that doesn't mean he's making an ad hominem argument.

I didn't miss this part - you didn't put any reasoning behind it.
I've seen that more from guys that "start from scratch" than guys who cut and paste... most guys who cut and paste also annotate and comment... most geniuses can't be bothered to both code and comment...
I will disagree with your copy and paste assessment. While it will hinder a junior programmer its a godsend to the senior developer. Someone who can quickly recognize what the code is doing and integrate it into the final solution.

There are more than enough APIs just on the platform I work with daily that I can imagine how much fun it must be sorting through all those available to Windows developers must not be a joy. Well Google lets me search quickly for established solutions and combined with my knowledge I can quickly identify which if any will do what I want to do and adapt if not drop into my coding style.

TL;DR

Copy/Paste might not be good for new programmers, but time savings for experienced programmers warrants its use

I can appreciate your opinion on this but it strikes me as a bit of a 'high horse' statement to declare that copy and paste is the wrong way to learn or advance the process of mental reasoning. At some level, we're all copying someone who came before us, unless you're working at the absolute bleeding edge.

Everybody has their own style of learning, and not everyone is at a point in their journey where poring over API docs or dropping down into a lower level makes sense for them.

> This is not 'coding' (maybe it is, and we should be doing less of it, and more programming). This is gluing together pre-coded snippets and trying to make it work. Continuing to do this is an impediment to getting better. Thinking that somehow this is what 'coding' is, is missing the point.

That's not fair at all. Off the top of my head, three topics I have searched StackOverflow for a lot are Android development, MongoDB, and MySQL. Each time, I would consider the task I was doing to be programming, despite the fact that I was not building a mobile phone operating system or database myself from scratch.

> Copy and paste doesn't help you at all with this. In some cases it may prevent you learning essential lessons and hinder your improvement.

It annoys the heck out of me too when people apply for a programming job and cannot implement even trivial CS methods (like integer => string conversion with base N), then point out that they would just Google for a solution if they needed something like this.

But to be honest, a lot of programming wisdom is buried somewhere on the web as well as inside libraries that do not warrant reimplementation. Much of this googling and copy-pasting simply represents the fact that our traditional programming library approach isn't sufficient anymore for distributing correct implementations of particular functionality - probably too much overhead. SO is much like a large library with mediocre code, imprecise interface specification and without working imports, but it also contains many solutions to trivial problems that competent engineers should be able to implement straighforwardly...

I have been programming professionally for 10 years, 5 years more as a hobby. I have been paid 100s of thousands of dollars, my code is used daily by 10s of thousands of people, I have built large, complex systems from scratch, worked in teams and by myself. The things I make do what they're supposed to, they don't break often[1], tend to be fast and usually my client is a happy bunny.

I can fix anyone's code, even when I've never used the language before [2] and it was written by an outsourced programmer who quite obviously only read "how to write SatanScript in 28 days" and then was locked in a room for 2 years until his program kinda worked if you held it upside down while reciting the words to Annie.

I am confident I am a good coder at this point in my career, and much better than many of the programmers I have met. There are a handful I have met that I know are better than me.

I would only have a vague idea of how to do a integer => string conversion with base N without googling it. So am I shit? Am I suddenly a useless programmer because lazyjones only likes people who studied CS? Even though I can understand that code in a glance and rewrite it, often better or clearer than the SO example?

You have picked an arbitrary, and extremely rare in the programming world, standard. No-one needs to write their own string handling routines any more.

Programming is hard and there are many different flavours.

And yours is an old fashioned favour from the early 00s. Stop judging people by it.

[1] Apart from my very bad habit of making a minor last minute tweak or bug fix, not testing it, and introducing an easily fixed bug

[2] They're all pretty much the same after you've used 3 or 4.

> I can fix anyone's code, even when I've never used the language before [..]

You can jump into any codebase and solve core architectural problems like precise garbage collection, eventual consistency, or miscellaneous dead locks? I'm not making up contrived examples, these are some of the problems my friends and I are currently dealing with at work for different companies.

> I would only have a vague idea of how to do a integer => string conversion with base N without googling it. So am I shit? Am I suddenly a useless programmer because lazyjones only likes people who studied CS?

I've never had to do integer => string conversion until asked in an interview either and I still did it. It's not a difficult problem. Anyone with a basic understanding of division and string manipulation should be able to reason out a solution.

> You have picked an arbitrary, and extremely rare in the programming world, standard. No-one needs to write their own string handling routines any more.

I wrote my own C++ string library before std::string was introduced. I contribute to Rust which has its own string, big number, vector libraries and much more. The web site I work on gets >130M monthly uniques and we have extended Python's string, dictionary, iteration, and datetime modules because the standard library isn't enough.

> [Programming languages are] all pretty much the same after you've used 3 or 4.

Then you haven't used enough languages. Try functional programming via Haskell, or dependent typing via Coq, or concurrency via Erlang, or memory safety via Rust.

The world is a really big place. I know people infinitely smarter than me doing incredible things, and there are many more like them. Stop being limited by your own experiences.

Yeah, probably, but that's one of my skills, I have fixed a lot of bugs.

But take a step back. What are you trying to say? You're better than everyone who hasn't done these things? You're somehow a real programmer and everyone else isn't?

And look how big your penis is!

Seriously, what were you trying to achieve with this comment? What have you demonstrated? You're a specialist, you know certain things other people don't. So what? It doesn't make you any more of a programmer than I am.

And seriously, don't puff up the differences between languages, in the end every language is just a different way to take some data, transform that data and emit that new data. What happens in between is nothing particularly complex, it's simply the sheer number of those steps that can happen that make it complex. The whole point of languages is to make it easier to express something. Not harder.

I honestly don't know what perceived slight you were responding to. Carry on believing only the highly specialized 0.1% of programmers are real programmers if you want. Stop being limited by your own snobbish elitism.

Wow, dude, chill out ... in my opinion, wting did not write anything, that gives you reason to accuse him, that he is an elitist. He simply pointed out, that you are limiting yourself with the kind of believe, that there is no need to know how to solve simple problems on your own, and give you examples of things that he was able to do, because he did not limit himself in such a way ...
>>I would only have a vague idea of how to do a integer => string conversion with base N without googling it. So am I shit?

If you receive a programming task like the above (with a relatively clear specification, very little state to manage, defined domain of the desired function, and the input and output of the function are most likely primitives in your language, your standart library probably have lots of utility functions to work with these primitives), I will expect, that you should be able to do it without googling.

Your solution may not be the most effective/short/clean, but it should work. If you can not do it without googling, well ... yes, I do think you are a shitty (or just out of shape for the moment) programmer.

You will need more programming exercise, in order to know more algorithms and aproaches to solving problems, and/or learn better your language and its standart library.

I'd tend to agree with lazyjones. I doubt that his expectation is that you would know all the tricks for making the most efficient integer => string conversion routine ever, but I certainly would expect any competent programmer to be able to write an integer => string conversion routine without really thinking about it, not because anyone needs to write such code much anymore, but simply because a competent programmer should have sufficient mathematical understanding to see the obvious solution to the problem. This isn't about writing string handling code, but about demonstrating understanding of very basic mathematics using a trivial problem that should need a line or two of code in most programming languages to solve.
> would only have a vague idea of how to do a integer => string conversion with base N without googling it. So am I shit?

I would probably not hire you unless you could actually back up your dubious claims ("I can fix anyone's code ..."). The funny thing is, while I am judging people by their ability to solve a particular problem (which admittedly may have an age bias), you are judging people who studied CS based on the fact that you didn't but are still full of yourself.

I'm not judging them. There are great programmers who studied CS. Is a worthwhile thing to add. The best programmer I know studied CS.

It's worthwhile, if you can actually program.

It's unfortunate that a lot of people have to wait till they've gone to Uni, studied CS, gone into the real world, got a job programming, and found they cannot program.

> I would only have a vague idea of how to do a integer => string conversion with base N without googling it. So am I shit?

It sounds very much like it I'm afraid. This is trivial problem solving. Your overconfidence + lack of problem solving ability are big red flags. If you're as good as you claim you are then you should know foundational principles. It gives you a far greater insight into programming than just grinding away with other programmers 'snippets'.

I feel like it's a pretty common phenomenon for people to have their pet somewhat-arcane "gotcha" problem that they feel is the ultimate decider of who's shit and who isn't. And you're on HN, so the responses are going to be way more pedantic than just about anywhere else.

Personally I think this example is way more reasonable than most other technical "gotcha" problems. (I say that because I could solve it despite not having studied CS and being still relatively inexperienced.) But at least they're not asking how many pickles you could eat before exploding if you were shrunk down to the size of a kitten's tongue and placed on a miniature rocking horse that may or may not be alive inside its sad plastic shell.

Copy/Paste is OK as long as you understand the code. If the code is elegant and you know what's happening there's no need to change it.

I would argue that the problem is not the copy/pasting but where to paste the code. As an iOS developer I download a lot of code samples from the Apple Development Website. In many cases on these samples the developers put a lot of code in Controllers to show how things are done.

Beginner developers will usually copy/paste the code as is in the controller and believe what it does by faith.

An experience developer should understand that the code was put in the controller for educational purposes and place the code where it belongs. A Model, Singleton, or leave it in the controller if it makes sense.

I have seen many sample projects included in full in final products. "It's from Apple, it must be good!"
> Then I'll throw them all away and code my own. Possibly it will share a lot with one of the answers, what I would consider a good approach

So basically you're in the business of reinventing the wheel all the time. I feel sorry for your employer.

Although rarely, it is worth it sometimes to reinvent the wheel https://www.youtube.com/watch?v=h7Tq3Gsj6lY :-)
It could be said that he is reinventing the wheel and trying to make it rounder, which is definitely a good thing.
wow... You must be from the school of re-inventing the wheel... most things that need to be coded have been done before by someone else and quite well... No one chops down their own tress when they want to build a deck. They take lumber that someone else preformed and make it fit their project. If you are writing all your own code every time on every project... You must get nothing done...
Libraries yes, copypasta no. They're maintained, have tests, and a download/follower count.
'They're maintained, have tests, and a download/follower count.'

While not exactly what you're saying, I feel that a good StackOverflow answer has the same general properties.

Agreed, but doesn't that mean the main premise is almost correct? It indeed seems like the skill of 'programming' depends on the development of a knack for Googling for the right terms.

I think it is actually the other way around: once you develop the skill of 'programming', you will know what to search for when you have a problem and you will understand enough of the puzzle to construct the last piece from the various results to your search query. If you don't know how to search for an answer to your problem, you do not sufficiently understand your problem.

I read that as tongue-in-cheek.
copy and paste helps to get the job done
I don't think so. A program is an infinite stream of jobs and is never quite 'done'. The less time you spend on keeping things nice and clean, the more frequent the jobs will be. After all, it still needs to be maintained.

Unless you are using a library, it's gonna be better long-term going for complete understanding. Even then, it's usually a great idea to understand what a lib does under the hood.

I guess it depends. A freelancer hired through oDesk by default has a clearly defined job and zero incentive to care about ‘nice and clean’.

Sometimes I just can't help thinking that the code I maintain has been optimized, foremost, for someone's job security—even when I know that the author is actually just of ‘get-shit-done’ type, and has been paid hourly.