Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Samples coming with SDK are intended to provide best practices. So logically it looks perfectly valid to take code from them. But usually samples come under licenses, for example a lot of samples from Microsoft are released under Microsoft Public License (MS-PL).

Samples are usually published to provide best practices and common reusable code. But how can I use code from samples if they are under rather strict licenses?

share|improve this question
    
What SDK are you talking about? –  Anna Lear Feb 22 '11 at 15:47
    
@Anna Lear♦ any. Silverlight examples come under MS-PL, Android SDK are under Apache License. –  Andrey Feb 22 '11 at 15:57
add comment

5 Answers 5

up vote 2 down vote accepted

I've never been in a position where I wanted to copy & paste code from a sample directly into my app. What I usually do is I read through the sample and then re-implement it in my code. I am not a lawyer, but I believe it is then my code and not subject to the sample's license. Mind you, when I say I re-implement it, I don't mean just retype straight from the SDK's help page. I study the sample until I understand it fully and then I can easily produce the code I need.

share|improve this answer
add comment

The general advice I've received (from various company and institution policies) is to never copy code without express permissions, regardless of the source. It is not just the licensing problem, but also a copyright problem and can quickly become messy and costly to sort out.

share|improve this answer
add comment

Typically, from what I have seen you end up leaving the copyrights in place and provide appropriate documentation showing where you got it from. Much like an APA citation in a paper.

share|improve this answer
add comment

As with most standardised code, leaving the copyright information in tact is a good approach and where it is dominantly visible where it's being implemented. In most cases, contacting the original development team that created the code is somewhat a bit of a hassle and something you'd rather not do. After all, the sample code is for developers to use and modify - by 'modify' I would include implement too. Why deter people from using samples?

share|improve this answer
add comment

It's like with any other source code: either meet the terms of the license or do not use the code.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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