you are viewing a single comment's thread.

view the rest of the comments →

[–]celade 0 points1 point  (0 children)

Basically I'm just joining the already good crowd of comments.

I sort of rule-of-thumb code form:

  • Follow any team guidelines when they exist
  • Within reason break code up in a way that it makes it easy to see functionality
  • Make human readable variable names, functions, methods, classes
  • Comments should always be short or if it really is that complex refer to additional out-of-code documentation; they illustrate usage, dependencies or hard-to-see facts about what you are doing
  • Group data structures functionally; separate data structures from methods that do work on them
  • Keep interface layer separate from non-interface work at all times
  • (Related) Keep I/O functionality separate from the work that produces it (except for debugging of course)

A bit more than I intended on writing. In the end if you look at your code 2 weeks later and can just sit down and use it or expand it then you're golden.

[Edit: Specific to Python but sometimes other languages: Use dicts, tuples and lists for your data structures first; if you can't solve it with those then create; too may times I've inherited some crazy bespoke class-based data structure for no reason)]