Found a better solution to a problem at work - should I deter from posting the code snippet online?

softwareengineering.stackexchange https://softwareengineering.stackexchange.com/questions/216029

  •  30-09-2020
  •  | 
  •  

Question

I think most of us, programmers, used Stack Overflow to solve every day problems: looked for an efficient algorithm to do something.

Now imagine a situation: you have a problem to solve. Googled a bit, found a StackOverflow question but you are not really satisfied with the answers so far. So you have to do your own research: you need to do it because you want it in the company's app.

Eventually after some hours you have found the better solution. You're happy, you added it to the company's code base, then you want to submit your answer with a code snippet (just several lines) to the question you've found before to help others too.

But wait: the company's software is closed source, and you worked on it on the clock.

So does this mean I shouldn't post the answer neither at work nor at home to that question in the rest of my life, because I solved it at work, and the company owns that piece of code?

Était-ce utile?

La solution

Exposing proprietary company information is something you should never do. Most code snippets on Stack Overflow are far more mundane than that, however. Consider this example:

public static unsafe void SwapX4(Byte[] Source)  
{  
    fixed (Byte* pSource = &Source[0])  
    {  
        Byte* bp = pSource;  
        Byte* bp_stop = bp + Source.Length;  

        while (bp < bp_stop)  
        {
            *(UInt32*)bp = (UInt32)(
                (*bp       << 24) |
                (*(bp + 1) << 16) |
                (*(bp + 2) <<  8) |
                (*(bp + 3)      ));
            bp += 4;  
        }  
    }  
}

This method inverts the endianness of a 32 bit number, by swapping the bytes around. The difference between this implementation and a naive one is that this one runs twice as fast, but you can only run it on a little endian machine. It's being used in a proprietary program, but it describes a general technique, and does not expose anything confidential.

Autres conseils

I frequently post problems and solutions I run into at work, on company time with company code*. I've spoken to my manager directly about this, and he feels that the value the company gets from my time spent here far outweighs any concern about my time spent here in general.

*I'm cautious to obfuscate anything I think could be proprietary. Our in-house code is very proprietary, but would largely be useless to anyone without our proprietary hardware (which we don't sell).

I look at my questions & answers as helping myself as well as someone else down the road when they run into similar problems as I have.

How much would it cost your company for your additional time or lost time if you didn't have this resource?

As long as no compromising or proprietary info is given I feel that the posting solutions that you have found is compensation for answers that you have received.

The answer lies in the written legal agreements you signed with your employer (your contract) and with the jurisdiction under which those agreements will be judged. It is common for a legal agreement to list the jurisdiction which may or may not be the state you work in (though probably the country you work in, but not necessarily).

A great book is Intellectual Property and Open Source by Van Lindberg. From p. 185:

There are no legal repercussions for [a company] overreaching when defining "proprietary information." Several states limit the application of PIAs when an author or inventor doesn't use company property or time to create the new work... Even if state-imposed limits invalidate part of the PIA, other aspects of the agreement generally survive.

Read your contract. Disclose your intentions to your employer before you act. Then disclose your actions to your employer. Disclose these things in writing and get their response/permission when applicable in writing. At least that's what that book says.

I am not a lawyer, just interested in this stuff. This is not legal advice, just friendly suggestions. For myself, I don't casually make anything work-related public. I have made some things public after lengthy discussions with my boss, full disclosure, clear license labeling, and an agreement in writing about what I'm releasing, but that is rare.

I've posted code snippets online but I always edit the code so as to remove any references to the company, any customer data and often I rename fields/variables too. I basically end up re-writing the code so it can't be traced back to an employer. It takes a bit of extra effort but I think it's worth it.

Aside from the legal aspect you also have to think that you've been trusted with your employers property. If you freely post bits of it online then it looks like you lack discretion and can't be trusted. Even if you had permission a future employer finding your snippet from a search engine may not know this.

This is why I would tend to err on the side of caution.

Licencié sous: CC-BY-SA avec attribution
scroll top