Pysyft: Organize class methods and functions

Created on 18 Oct 2017  路  3Comments  路  Source: OpenMined/PySyft

Currently there is no order of how methods appear, for example, within the TensorBase class and in math.py. There is no strict convention for organizing methods and functions but a general pattern to follow would be:


class SomeClass(object):
def __magic_methods__(self):
"magic methods first, usually in alphabetical order"
def _private_method(self):
"worker methods next, also in alphabetical order"
def a_method(self):
"then normal methods, also in alphabetical order"`

Most helpful comment

I've gone through all the current code and organized it in PR #351, and it might be a good thing to add also to the style guidelines for the project so we can try to stay consistent throughout. Also totally agree with you, there should be a relatively easy to understand logic behind the class organization. We use draw.io quite frequently at my work for such things, so this could be a good tool for such a task.

All 3 comments

Totally agree with you there! And I will implement this for my Code as well.

I also see a problem with class organization and how they interact with each other, because often the docs aren't sufficient explaining code interactions. I suggest a small diagram or a flow chart to get ppl to get our code faster and of course also easier!

I've gone through all the current code and organized it in PR #351, and it might be a good thing to add also to the style guidelines for the project so we can try to stay consistent throughout. Also totally agree with you, there should be a relatively easy to understand logic behind the class organization. We use draw.io quite frequently at my work for such things, so this could be a good tool for such a task.

Sounds like a good idea, Im getting to it on my code!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

deevashwer picture deevashwer  路  4Comments

aristizabal95 picture aristizabal95  路  3Comments

samsontmr picture samsontmr  路  3Comments

jvmncs picture jvmncs  路  3Comments

robert-wagner picture robert-wagner  路  4Comments