Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 

How to share code for review and getting help (online)

Motivation

This document aims to provide some general guidelines for sharing source code which exhibits an undesirable behaviour, in order for it to be reviewed and corrected on online forums.

Guidelines

Short, Self Contained, Correct, Example

First of all, your code should exhibit the problem you are having and should be a self-contained, and a reproducing example. More guidelines can be found in “The Short, Self Contained, Correct, Example” (= SSCCE) page and in Stack Overflow’s “Minimal, Reproducible, Example” page (whose text is under CC-BY-SA).

Reducing the code

If the code is too large, please consider reducing it to a more minimal example that still exhibits the problem (see the bisection method ). Namely, you can try gradually removing parts of the code while each time ascertaining that the problem can still be reproduced until you have reached the shortest possible code. Often, doing that will be enough to find the culprit reason for the failure and to fix it.

Show the Whole Code

Please don't share non-runnable pieces and fragments of your code, see “Show Us The Whole Code” .

Share code - not screenshots

As a general rule, it is a better idea to share the code as text, as that can be compiled and run.

When you do need to share screenshots of the code, try using a screenshot tool (such as the Print-Screen button), rather that a camera (e.g: a smartphone's).

How to upload the code

  1. If you are coding a web page, you can try sharing your code using jsfiddle .

  2. Otherwise, if your code is self-contained in one file, you can use a paste site such as ideone or paste.debian.net. If you are using an IRC chatroom, don't floodpaste the code to the channel because this is slower and more annoying than using a paste site and may get you kicked or devoiced out of the channel.

    If the code you are sharing is a reusable component, you can use Bit to isolate it and share it so that it can be installed or imported in other projects.

    Some other types of forums allow you to quote a single and self-contained codebase using a notation such as “pre” tags, or using indentation or triple-backquotes, so it may be an option there depending on the forum’s policy.

  3. If you have more than one file in the project, then you should put it in a self-contained version control repository on a code sharing site such as GitHub , Bitbucket , or GitLab , so people can easily clone or checkout it.

Use a Continuous Integration (CI) Service

If you have the time, and solving the issue is important for you, you should set up a public CI service with a build and test script, and that reproduces the issue. This way, other people will have an easier time reproducing it.

Put the code under a usable copyright licence.

See "which licence should I use" .

Links

Project Links

Licence

This document is Copyright by Shlomi Fish, 2017, and is available under the terms of the Creative Commons Attribution License 4.0 Unported (or at your option any later version of that licence).

For securing additional rights, please contact Shlomi Fish and see the explicit requirements that are being spelt from abiding by that licence.

Releases

No releases published

Packages

No packages published