Coding ethics: reusing code someone paid you for, in another project?

Red Squirrel

No Lifer
May 24, 2003
67,407
12,144
126
www.anyf.ca
For those of you that do any coding for a living, like say web design, I'm curious what the ethics are of this and how you handle it.

Say you build a website for someone, you code everything up etc, and they pay you for it. Then you get another client who happens to want a website that is very similar. Do you charge them the same, and then code it from scratch again, or do you charge them less, and just reuse the code from the last project with minor changes? Legally, you can you even do this? Or does the customer technically own the IP to that code because they paid you for it? Kinda how record companies own an artist's productions because they pay them a cut of sales. That artist is not allowed to then sell their music independently or even use it for their own personal stuff. Does it work the same with coding?

I don't really do much of this other than the oddball project, but the concept kinda struck me while I was working on something and realized I could make a website (personal project) that ends up using a lot of the same code that I got paid for.
 

lxskllr

No Lifer
Nov 30, 2004
57,433
7,618
126
Probably depends on your contract and license. Generally speaking, all projects get the same price. If one is easier, due to reusing code, it's a bonus for you. You're getting paid for your accumulated experience. That can be modified if you want to give a break to gain future work or whatever.
 

DigDog

Lifer
Jun 3, 2011
13,500
2,122
126
I've always wondered how that works. Because i would imagine, if person A hires you to say, write a database management script, and then person B also hires you to write a database management script, you would likely wind up writing the same script, even without trying. You got a problem, you got coding knowledge, you would take the most direct path to the solution.
Or vaguely speaking in aimilar situations you would write the same code, always.
 

sdifox

No Lifer
Sep 30, 2005
95,052
15,145
126
Unless the contract stipulates exclusive ownership, you are fine. Reusability got us where we are today.

In reality no one is going to come after you unless it is the proprietary parts of the code.
 
  • Like
Reactions: paperfist

lxskllr

No Lifer
Nov 30, 2004
57,433
7,618
126
I've always wondered how that works. Because i would imagine, if person A hires you to say, write a database management script, and then person B also hires you to write a database management script, you would likely wind up writing the same script, even without trying. You got a problem, you got coding knowledge, you would take the most direct path to the solution.
Or vaguely speaking in aimilar situations you would write the same code, always.
That's pretty much all work. If you're reinventing the wheel every time, you either have the most interesting job in the world, or you don't know what you're doing. Assets belong to the client, eg logos and such, but otherwise it's your work unless the contract states otherwise.
 

DigDog

Lifer
Jun 3, 2011
13,500
2,122
126
Yes but let us imagine a contract does not allow reusability.

Option 1. You are pretty much screwed. You'll need to write code "wrong" from now on. It's as if i ask you to write a phrase describing your morning and the phrase "i woke up, had coffee, showered and went to work" is the most efficient way to write that.
You would then have to change that, say "i found myself awoke, then i had a coffee, finally i showered and went to my work".
Then it would get more and more unefficient, "as i lay in bed i noted my awokeness, proceeded to digest a coffee drink, and cleaned myself through showering before making my way to my work".

The inventor of a programming languafe would say, broadly speaking, for X problem there is an ideal way to solve through code; and you would ALWAYS want to write it that way.

Option 2 is that you on purpose write bad code.
 

purbeast0

No Lifer
Sep 13, 2001
52,859
5,732
126
When you charge someone, you aren't charging them for X lines of code. You are charging them for X amount of hours at a Y rate per hour. So if you decide to reuse code, chances are that you won't take as long to code it up, so you would in turn charge less.

It also definitely depends on how you wrote the contract as well if you can/should reuse the same code.
 

WHAMPOM

Diamond Member
Feb 28, 2006
7,628
183
106
For those of you that do any coding for a living, like say web design, I'm curious what the ethics are of this and how you handle it.

Say you build a website for someone, you code everything up etc, and they pay you for it. Then you get another client who happens to want a website that is very similar. Do you charge them the same, and then code it from scratch again, or do you charge them less, and just reuse the code from the last project with minor changes? Legally, you can you even do this? Or does the customer technically own the IP to that code because they paid you for it? Kinda how record companies own an artist's productions because they pay them a cut of sales. That artist is not allowed to then sell their music independently or even use it for their own personal stuff. Does it work the same with coding?

I don't really do much of this other than the oddball project, but the concept kinda struck me while I was working on something and realized I could make a website (personal project) that ends up using a lot of the same code that I got paid for.

Let me explain this from a builders perspective: when a contractor wants a unique molding made, he pays for designing and grinding the special shaper blades, he gets the molding and the company gets to keep the blades. You don't buy a new hammer to pound in every nail.
 

Red Squirrel

No Lifer
May 24, 2003
67,407
12,144
126
www.anyf.ca
Yes but let us imagine a contract does not allow reusability.

Option 1. You are pretty much screwed. You'll need to write code "wrong" from now on. It's as if i ask you to write a phrase describing your morning and the phrase "i woke up, had coffee, showered and went to work" is the most efficient way to write that.
You would then have to change that, say "i found myself awoke, then i had a coffee, finally i showered and went to my work".
Then it would get more and more unefficient, "as i lay in bed i noted my awokeness, proceeded to digest a coffee drink, and cleaned myself through showering before making my way to my work".

The inventor of a programming languafe would say, broadly speaking, for X problem there is an ideal way to solve through code; and you would ALWAYS want to write it that way.

Option 2 is that you on purpose write bad code.

Yeah that's the part that gets me, and it happens in the music/art etc industry all the time. Someone writes a song, and it just so happens to sound similar or have similar lyrics to another, and they get sued. There's only so many possible ways to do something.

Also I don't do any contracts, not even sure how to do that, would that be an issue? It's more like "hey can you make a website for me I'll pay you" "Sure". I typically don't do it all that often as it's not really something I want to do full time, but while working on one site I kinda got an idea to make a personal site that would use same code and then it got me thinking. Not sure if I'll actually pursue it but it just got me curious.
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
For "making a website" work they probably aren't paying enough for exclusive ownership of the library code used. Unless there is a contract against it, reuse is normal.

It's different if you're doing contract work for a software company that plans to sell the results, like a website shopping cart vendor or someone selling wordpress plugins.

A grey area is something highly customized or industry-specific. Then they might have a valid complaint if you use the same code for a direct competitor's site.
 

DigDog

Lifer
Jun 3, 2011
13,500
2,122
126
Yeah but ...

See if i need to make a carbonara, i make it *exactly* one specific way - the "best" way. Every time. Doesnt matter who is paying me.

So if i write some code, im not sure about someone saying "ok you can never write this code again".
First, others would do it instead.


Ok thats not true, in practice, but in ideal world every coder would write perfect, identical code.

Second ... if you do write the same code twice, thats because that is the way you write code for that. There isnt another way.


Now, on large swathes of code, naybe even collaborations, ok. But on simple code?

Music has this problem too. You take a bunch of notes, arrange them in a particular patters, and bam! that belongs to you. Nobody can ever assemble them in that order again.

When it comes to copyright, it's really judged on a case per case basis; a human judge decides if the two compositions are equal or different enough. But you dont get copyright for chords or progressions. Nobody can copyright C#m nor can they copyright the chord progression of Purple Rain.

So my guess is that code follows the same rules. If it's basic enough, it will be considered not IP. If it's extensive and complex, it is IP.
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
If you're concerned about this, just write up something to the effect that you are only giving your customer non-exclusive perpetual royalty-free rights to use and modify the code as they see fit.

If something is a work made for hire then the employer might own the work, but that probably wouldn't apply to gaining exclusive use of all code in this kind of contract where you're coding using common shared code some of which is copied from sites like StackOverflow. IANAL but I'd guess they'd only own the work as a whole, i.e. the specific assembly of the pieces into their website not the pieces themselves.
 

Red Squirrel

No Lifer
May 24, 2003
67,407
12,144
126
www.anyf.ca
I guess one way to draw it out would be that they are paying for my time to setup and manage the website (ex: the hosting, making sure it's online, and does what they want etc) and not to actually code it. Basically they are paying me to make it so that when they go to the url, they see what they asked for. The way I go about doing that in the background is irrelevant. Guess that would require a contract though so it can be drawn out that way.

If I was to do this more seriously I would probably want to get the legal stuff in a row like have a contract etc. I'm too small to bother with that at this point though, the legal fees would be higher than the money I make and I'm not making that many sites. I typically only really do it for friends/family. Like one site I'll be revamping soon is a food site, and implementing online delivery and credit cards. Chances are if I wanted to make my own site/service that used the same concept I'd reuse that code and modify it.

As a sort of side interesting note, when I was a kid I was way more into this and did websites for lot of businesses. One time I was doing a high school co-op at a business that also does the same types of services, and I did a lot of sites for their customers. One time one of my potential customers that I had done a quote for shows up there to get a quote on a site they wanted done. It was a rather awkward situation when they saw I was the one doing the websites lol. I think what ended up happening is I just told the business to take care of that one and disclosed how much I charged. Didn't want to actually compete with them.
 

PowerEngineer

Diamond Member
Oct 22, 2001
3,552
726
136
As it happens, I wanted a walnut dashboard for a rare sports car I have been restoring. None of the normal suppliers offered one for my car, so I ended up shipping the old one to one of them as a pattern and paid for the custom work to make it. The dashboard I received is very nice. Only weeks later I find that my supplier is now selling dashboards for my car at half the price I paid. In essence, I paid the cost for him to add it to his product line. I might be a bit miffed if I thought he would be selling lots of them. :p

Another thought provoking example could be around ownership of any knowledge or skills a person gains as a result of working for someone else. Unless there is a non-compete clause in a contract, the presumption is that that knowledge and skill is owned by the person and he/she can use them as he/she sees fit. I think that the ability to code websites (or anything else) fits into that knowledge and skill category.

I agree with what you say above about your customers paying for a service rather than for the methods or tools used to provide that service. It might not hurt to google the internet for some legal boilerplate that you could use without actually paying for legal help.
 

paperfist

Diamond Member
Nov 30, 2000
6,517
280
126
www.the-teh.com
When I buy pics for my website from gettyimages they sell 500 other copies of that same image to other buyers.

On the other side of the coin I just paid for some code. Since I didn't agree to anything exclusive I'm going to use that same code on other projects and not pay for it again.
 

gorcorps

aka Brandon
Jul 18, 2004
30,738
451
126
When you charge someone, you aren't charging them for X lines of code. You are charging them for X amount of hours at a Y rate per hour. So if you decide to reuse code, chances are that you won't take as long to code it up, so you would in turn charge less.

It also definitely depends on how you wrote the contract as well if you can/should reuse the same code.

I've never written code for a living, but this is how I imagine client based projects are often handled. I thought they were very time driven, so if you don't take as much time because you already wrote the code, you'd charge less.
 

njdevilsfan87

Platinum Member
Apr 19, 2007
2,330
251
126
I work with data, and anything that's general purpose will be reused as a starting point for me. General purpose as in it doesn't give away any algorithm or trade secrets. Visualization tools for example, will take in and display data fed to them, but not know how that data was generated. All they do is display data fed to them. Or frameworks that accelerate codes - same deal. I may have developed those codes on the job at some point, but only as a necessary or enhancing part of a much larger effort to solve some specific problem.
 

sourceninja

Diamond Member
Mar 8, 2005
8,805
65
91
Even with assignment of copyright, it's still not worth a re-write for a website. Unless it's some super specific and easily identifiable thing. Any good web design project typically includes open source libraries and tools. You can't give them ownership of those things and if you are doing EVERYTHING from scratch then honestly you have a very unique need or you are doing it wrong.
 
Feb 25, 2011
16,791
1,473
126
If you want to avoid the problem, take the code you've written that you think you'll probably re-use, and release it as an open-source library for the language/toolset you're working in. (Like a Python library or whatever.) When you add or modify it, it's obviously not billable work, but that's less important - most freelancers, in addition to their hourly rates, have "package" prices. ($250 for a logo design, $5k for a website, etc.) So you don't actually have to charge less.

Then just use that library in your paid work, like you would any other library. Your contract should include a line about what is and isn't part of the "product" you're selling, and you obviously aren't selling copyright privileges to "stdlib.h" or anything, so you're in the clear.
 

Red Squirrel

No Lifer
May 24, 2003
67,407
12,144
126
www.anyf.ca
If you want to avoid the problem, take the code you've written that you think you'll probably re-use, and release it as an open-source library for the language/toolset you're working in. (Like a Python library or whatever.) When you add or modify it, it's obviously not billable work, but that's less important - most freelancers, in addition to their hourly rates, have "package" prices. ($250 for a logo design, $5k for a website, etc.) So you don't actually have to charge less.

Then just use that library in your paid work, like you would any other library. Your contract should include a line about what is and isn't part of the "product" you're selling, and you obviously aren't selling copyright privileges to "stdlib.h" or anything, so you're in the clear.

I was thinking about that actually. The last php application I coded I ended up inadvertently basically coding a CMS, so I keep finding myself reusing part of that same code as it already has all the logic for login, user accounts etc so I could probably polish that and just GPL the whole thing as a basic CMS core library. Then when I code something I just write a new module for it or use an existing one. But basically it would all be stuff that's released to public.