Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This may sound silly or obvious but this is my case; I work at a company that recently implemented SAP and I was the responsible to generate/migrate the master data of the company which let me learn a lot from this system. SAP comes with its own language known as ABAP and since the system went live I've been learning and programming with it. Before ABAP I worked as a freelancer in other projects with VB6, VB.Net, C# and ASP.Net building a lot of stuff, here I've made some utilities that are been using daily, so I came with long experience in programming.

At first ABAP was difficult but eventually after long analysis, googling and trial and error I became the guy who makes basically all the development in SAP from reports, to user-exits, enhancements, BADIs, tables, dynpros, etc. Daily I learn more and more because of all the requests I receive which makes me investigate and code a lot everyday. It has become challenging and funny at the same time. You could be very productive in ABAP once you get into.

Ok, the question is - can I post how I resolved a certain thing in SAP? That implies that I'd publish production code. I feel doubtful about this.

share|improve this question

closed as off topic by Justin Cave, gnat, JeffO, Josh K Feb 11 '12 at 5:01

Questions on Programmers Stack Exchange are expected to relate to software development within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

You can always post how you solved a problem without publishing direct code snippets. However, the company you work for (in all the countries I've worked in) owns the code you produced, so you'd need permission from someone there I'd think. – Joel Etherton Feb 10 '12 at 17:45
I find the question surprising. Can you not simplify, cleanse, rewrite or otherwise make the code not production code? Blogs contain mountains of explanations, code fragments, code summaries, code rewrites. Why can't you "cleanse" the code? – S.Lott Feb 10 '12 at 17:56
@S.Lott - Depending on the law where he lives, and the contract he signs, his employer may still own that "clean" rewrite, and not want it published. – Craige Feb 10 '12 at 19:31
"it would reveal internal details that are specific to the company business". You've said that without offering any explanation of why this is necessary. You keep repeating it without providing any evidence. If you cannot sanitize, cleanse, summarize or otherwise remove details, then, you're not talking about "code". You're talking about "business process". – S.Lott Feb 10 '12 at 21:09
Did you really just use legal and ethical as synonyms? ;) – back2dos Feb 10 '12 at 22:43
up vote 10 down vote accepted

I would say that it is clearly wrong to publish code you have written as part of your contract with your employer. That code is owned by your employer and you probably don't have either the legal or the ethical right to publish it.

Publishing knowledge you've gained as part of your employment is a much greyer area. Broadly I would suggest that;

  • If it's knowledge you've learnt for yourself, not relating to proprietary systems, then it's probably okay to write a code snippet from scratch and publish that.

  • If it's knowledge you could only have gained by working for your employer than you probably should not publish it.

  • If it's knowledge relating to proprietary company systems then you should not publish it.

Bottom line is that if you are concerned then talk to your management and get their, preferably written, consent before you do so.

share|improve this answer
+1 for "talk to your management". Can't get any more clear than hearing it straight from the horses mouth. – Craige Feb 10 '12 at 19:37

It depends on a lot of things, but if its just a short segment of code that anyone could reasonably expect to implement, then ethically I'd say its ok, you still may be violating copyright law though. Copyright laws are really grey and open to interpretation when it comes to code.

The thing you really need to watch for is parts of code that use a certain algorithm that may be patented or a trade secret, things that fall into this category should be fairly obvious though.

It should be obvious, but changing variable names and removing comments specific to your place of employment (TODOs) should be done if they use terms with special meaning to your company.

share|improve this answer

As long as its not proprietary information or a proprietary problem being solved then it should be easy enough to change your production code to make a generic example of the problem being solved. Be very careful however to cleanse the code of anything proprietary or identifiable.

I'm not saying to post production or proprietary code, I'm saying use that as a base to make a generic example to illustrate a solution to the problem posed.

share|improve this answer

It is generally accepted that any code written for your employer belongs to your employer. Even if you take production code, and clean it up so that it is something else that you aren't using in production in order to post it on a blog or on a Q/A site, your employer still owns the code.

In most cases, there is generally little harm in posting small snippets of code for the purposes of solving problems. Your boss should accept that you sometimes need to go outside the company to seek help when you can solve the problem entirely in house. If your intention however was to post something interesting to a personal blog, you may find yourself on shaky ground.

The best way to cover yourself both ethically and legally is to send your boss an email asking for permission to post your code snippets (cleansed or otherwise). Even better, ask your boss what the company policy is when it comes to posting code snippets to blogs and Q/A sites, and what your reasoning is, then leave it to your boss to tell you what is permitted. Try to get this in writing as either a letter/email or in a policy document - such as an employee hand book.

share|improve this answer

It is common for "work for hire" types of contracts to have a clause where you as an employee give up the copyright. There are some local variations to what extent you give up the copyright, but as a general rule you are not allowed to publish code or other documents that is specifically owned by the company as that would become a copyright violation.

That said, you can go usually around the problem by writing an example instead. You should ask the management of the company about posting it as well if you believe it is too close to production code. Try to reason by leaning towards goodwill and that you're not revealing any production code.

share|improve this answer

You should be very hesitant to do such a thing, and should certainly consult with management to make sure that, legality or ethics aside, it's something of which they approve.

On the other hand, illustrating a technique using a code structure you developed is perfectly ethical. Usually production code is not the clearest example of a technique anyway, since domain variables and extraneous function calls stand in the way of making your point as clearly as possible.

share|improve this answer

If you're that worried about it, just ask your employer. Say, "I get a lot of programming help on a site called Stack Overflow. I just wanted to make sure you're okay with occasionally posting small snippets of code in my questions and answers."

In my experience, they're unlikely to object, especially for code that's only incidental to your work or only used once then thrown away, like migration scripts or utilities. I've had them okay even more substantial working code, like a plugin or module for third party software.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.