cp-algorithms icon indicating copy to clipboard operation
cp-algorithms copied to clipboard

Adopt a code standard for implementation codes (umbrella issue)

Open tcNickolas opened this issue 7 years ago • 2 comments

Basic level:

  • enclose code in ``` tags instead of pre, code etc.
  • code style: spacing, indentation etc.

Intermediate level:

  • unify the way code reads parameters and reports output. A lot of code has comments instead of reading input - we could, for example, wrap such code in a function which accepts a certain list of parameters, so that we don't need a specific input-handling code, and still the code is complete and can be used as a library method.
  • use the same language for all generic code (i.e. code which doesn't highlight some specific feature of a specific language). Some articles have the same code in C++ and Python, and the difference is purely syntax.

Advanced level:

  • make sure all code compiles and is covered by unit tests :-) We could use Jupyter to embed executable code in our articles.

tcNickolas avatar Oct 19 '16 17:10 tcNickolas

Great guidelines. What about how codes in both languages should be displayed? Should they be hidden in "spoilers" or such things? Should we place codes inside "spoilers" even when there is only one language available?

gabrielsimoes avatar Oct 20 '16 00:10 gabrielsimoes

Nice guidelines. After agreeing on common terms, we should update the contrib.md file as well stating the new rules which are necessary before sending a pull request.

likecs avatar Oct 20 '16 17:10 likecs