Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add contributing guide #7

Open
znicholls opened this issue Jan 12, 2018 · 3 comments
Open

Add contributing guide #7

znicholls opened this issue Jan 12, 2018 · 3 comments

Comments

@znicholls
Copy link
Contributor

Once we're at the point where we know what we're doing re development, it would be good to write a contributing.md document so that others can quickly get going. I'd prefer to not add this into the master branch until it's complete as I always find it very confusing when I get halfway through a document like this and then it suddenly ends/there's gaps. Or we could add it and have a clear warning that it's unfinished.

@znicholls
Copy link
Contributor Author

@richardcode @chrisroadmap

A few thoughts on some potential rules/guidelines:

  • Use test driven development. In very brief it means write your tests first, only write enough code to pass the tests, refactor the code once it's passing so you leave things tidier than when you started, repeat. If you want to read more have a look at this nature article or this intro guide (although even that is fairly long). If you want to read more in detail have a look (here or here.
    • The tests will also act as documentation and ensure consistency.
  • Create a style guide
  • Avoid code duplication wherever possible. A possible second step for us is to use a code analyser/linter to highlight code duplication where it occurs and run analysis of our code before any merges are executed (i.e. add linting to our continuous integration).
  • Take particular care to have the code say what it does clearly. Only resort to comments where you cannot explain why you are doing something any other way.
  • Limit methods to a maximum of 10 lines except in exceptional circumstances. Never ever more than 50 lines. Similarly try and have classes be responsible for one thing and one thing only. With this rule in mind, then try to have as few classes as possible.

Most of these thoughts from two books:

Right now I don't really care about documentation as the code should be fairly self-documenting if we follow the above. When we do get round to it we should work out how to use sphinx properly but that's a fiddle which is beyond me right now.

@chrisroadmap
Copy link
Collaborator

This crosses over with #6 but I've added my thoughts here.

I've added some simple tests in the branch unit_tests. I ran a few minimal examples and saved the output as numpy files. Running pytest performs the calculations and compares them to the saved output, for which an error will be raised if it doesn't agree. These tests are retrospective based on existing code, so this is not TDD, but in future I'll start with this framework when adding in new features. Furthermore the results for the RCP tests will not agree in the future when science changes are implemented.

@znicholls
Copy link
Contributor Author

Beauty. With practice we'll get better at writing better tests but as long as we're trying we're onthe right path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants