Skip to content

Commit

Permalink
Use step-down rule for of the order of function policy (#77)
Browse files Browse the repository at this point in the history
* Remove current fct ordering policy

* Rephrase to use the step-down rule

* Lint
  • Loading branch information
cbartz authored Apr 22, 2024
1 parent c323aa6 commit a8df1ef
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -669,11 +669,14 @@ Without a logical order, it can be difficult to follow modules and classes as
the number of functions or methods on them grow increasing the maintenance
burden of the code.

On modules, where a function depends on another function, the dependent function
should be listed after the function it depends on. This means that the functions
with the fewest dependencies on other functions in the module should be listed
first. Functions should also be grouped logically. If functions have a similar
purpose, they should be grouped together.
Functions should be ordered according to the
["step-down"](https://dzone.com/articles/the-stepdown-rule) rule.
This means that a module should be readable from top to bottom,
with functions ordered by level of abstraction, from general to specific.
A calling function should always be above the called function.
Functions should also be grouped together logically. If functions have a
similar purpose, they should be grouped together.


On classes, the `__init__` method should come first followed by any other
factory methods, such as `from_charm`. The rest of the methods on a class should
Expand Down

0 comments on commit a8df1ef

Please sign in to comment.