Class Inheritance #153
Replies: 2 comments
-
Hey Pablo, once upon a time the Stairs class was completely contained within a single module. see version 1 for instance https://github.com/staircase-dev/staircase/blob/v1.0.0/staircase/stairs.py Version 2 saw a large refactoring and introduction of a lot of new functionality. I definitely prefer organising the functionality into separate modules, eg The use of the We do differ in that they will often define a function somewhere, such as If I remember correctly, the use of With regards to "Either layer is a method of stairs with the argument "self" or layers is separate function". I'm not sure I think of it as black and white as this. For example given the following definitions
the following are all equivalent
i.e. they literally are the same function
yet Hopefully that explains what was going through my head at the time. Certainly there are negatives. If I run |
Beta Was this translation helpful? Give feedback.
-
Yes, now I see why you did it, but as you said there are many negative aspects related to "intellisense", code autocompletion and static type hints, mypy will surely have lots of complains. On the other hand IDEs like Pycharm raise a warning "attribute not in class", in default the configuration. For me the combination of these issues are really bad. On the other hand, I still need to check with some more time the pandas approach that you provided, but somehow they manage to avoid any sort of issue like the ones I described before. So if you can adapt your current approach to avoid these annoyances would be great :) I think we could make a refactor on this, that will have bidirectional positive impact with the type hints I'm implementing etc, unfortunately I'm not familiar enough with the code to do such a big change, but I could help you testing different architectures and giving ideas. |
Beta Was this translation helpful? Give feedback.
-
I'm checking at the code, maybe to help a bit and provide it with some type hints in the near future.
Just wanted to raise that I don't fully understand the porpoise of the add_methods() and _add_operations() functions, why don't we use inheritance, or add them as methods inside the same class? Maybe I'm missing something, but for me, I find the usage of this function makes the code a bit hard to read-debug-improve.
For instance layering layer takes "self", but this is a function where self should be a class instance of stairs and as such the name self is confusing. Either layer is a method of stairs with the argument "self" or layers is separate function that takes a instance of stairs with "stairs_instance" (whatever name) instead of "self".
Of course I may be missing something, but I have never seen this pattern so far. Thanks anyway :)
Maybe useful [link]:(https://stackoverflow.com/questions/533631/what-is-a-mixin-and-why-is-it-useful) for the case.
Beta Was this translation helpful? Give feedback.
All reactions