Question

My question came from this question

It seems to be actual developing code for a real application. What If your contract says that all code you made for app of your employer is a secret? Isn't it risky to copy code fragments like that online (if you read carefully, it gives information about the database)? Wouldn't it be better to write something like this?

DataTable1 = datatable with a lot of data;
DataTable2 = other datatable with a lot of data;  

for (int i = 0; i < DataTable1.Rows.Count; i++)
{
    if (DataTable1 ["Field1"]).ToString() != SomeValue) // this statement doesn't work
    {
        DataRow dr = DataTable2.NewRow();
        dr["Field1"] = "";
        dr["Field2"] = "*" + DataTable2["Field1"];
        Datatable2.Rows.Add(dr);    
    }    
}
Was it helpful?

Solution

Thats part of the reason why an SSCCE (or in SO parlance, MCVE) is often suggested. Writing such is less likely to be an issue with copyrights, more useful to the person answering the question in isolating the issue, and likely more useful to the next person who comes to find it. Note that in many cases just doing this exercise of creating an SSCCE will help identify the bug without asking the question.

If your contract says that the code you write must not be disclosed, you should consider asking your employer about asking a question on Stack Overflow and possibly sending the question to the employer who can say "yep" or "nope" to the question before posting it to make sure that there are no issues with disclosing it as part of the question.

I will point out that for my own situation, neither Deserializing map key with Gson expects an object nor Apache POI autoSizeColumn resizes to minimum width contain any proprietary code from my employer at the time, though both were from problems that I had encountered while working on software for the employer.

OTHER TIPS

Besides of being bound to an NDA or not: It is in every case bad practice to leak any information of your company's code to the internet. The stuff proprietary to your company really doesn't matter in most of the cases: it contains no valuable information to solve your problem. So leave it out.

Everytime, when I am asking something on SO, I write as much pseudo-code as possible or try to scramble as much as possible.

If you have signed an NDA which specifies that you should keep in secret all code you have written for your employer, then by copy-pasting fragments of that code on Stack Exchange, GitHub or anywhere else, you put yourself to the risk of having a lawsuit.

The contract may specify the consequences of violating the NDA.

The fact that the code contains nothing special which can be used by competitors (and given the low quality of the actual piece of code, I hardly doubt any competitor will copy it) and doesn't contain sensitive information such as passwords doesn't change anything.

You should have read your contract more carefully (especially before signing) and avoid posting code online.

Wouldn't it be better to write something like this?

How close is the piece of code to the original is usually considered by the judge.

Licensed under: CC-BY-SA with attribution
scroll top