mesh-adaptation / mesh-adaptation-docs

Documentation source for Animate, Goalie, and Movement
MIT License
2 stars 0 forks source link

Methods order #21

Open ddundo opened 5 months ago

ddundo commented 5 months ago

Currently we do not order methods in any particular way, which hinders readability. Could we decide on an order and add it to the wiki?

There doesn't seem to be a PEP suggestion, but I guess most common ordering is: magic methods, public methods, private methods? And then alphabetically within them? I'm not sure what would be best

ddundo commented 5 months ago

There is a nice flake8 extension for this: https://github.com/best-doctor/flake8-class-attributes-order. Unfortunately it's not implemented in ruff (yet) but we can take a look there and see what good ordering practices are

jwallwork23 commented 5 months ago

Hm. I am familiar with ordering methods according to private, protected, public in C++ but it's not something I've ever even thought about in Python.

Personally, I prefer the methods to "build up" in the sense that you start with the constructor (__init__), then have some foundational data structures/properties and getters, and then move on to more complicated methods that interact with other ones. (I realise there are probably parts of the codes where this isn't enforced - I've never really tried to). In any case, it would be impossible to automate with a tool (unless it was an AI!).