If you write some code, generally you or your employer 'own' that code (I won't go into who 'owns' open source code because it's not what I'm talking about). It's yours/theirs to do with what you please. But at what point can you reasonably say "this code is mine"? It seems reasonable to say a 100,000+ LOC codebase written by in-house developers belongs to the company they work for. You could stretch further and say "this function is mine". It might be a very specialised function using an algorithm you created to perform some task, so really yes, that is yours because no one else created it, you did.
But what about boilerplate code and small snippets? What about "Hello World"? Millions of programmers have written a Hello World since the early 70's, but you couldn't say because you wrote one that you 'own' Hello World in your chosen language.
What factors distinguish code classed as something that can be owned from code "anyone could have written"? There's only a certain number of reasonable ways of achieving some programming task, and you surely can't claim ownership of any code that does the same thing just because you wrote one first (or can you?).
For example...
A friend of mine got a job for a trendy new startup (the kind where beanbags and having a wacky office environment took precedent over actually doing anything) that swiftly sank beneath the waves. He was given a project that could have been handled by one programmer and got through what he estimates as 10-15% of the actual programming before being let go. He also did all of the design phase and supposedly has documentation to prove it. I want (with him) to use what he already wrote to finish the project and launch it as our own, but he's worried his former employer may come after him and accuse him of stealing the company's (which is now defunct) property.
Ideally I'm looking for legal precedent if anyone knows of any, but I think it might be hard to come by if any exists at all.