-
Notifications
You must be signed in to change notification settings - Fork 15
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
General code style and conventions #37
Comments
Hey @mgstingl thanks for writing such a detailed message. I think there are many things to be improved in the code and I would be insanely grateful if "someone" would do it :D
I totally agree. I must admit that I have never learned any programm and I learn things while doing. I think I have started with a pretty much random come-as-you-go order. Now I'm trying to stick to Pythonic.
A good to know. Sounds like a huge improvement! :)
Souds great! Here I was just sticking to what ImSwitch did originally. But I would be grateful if you can file a PR :) |
Hi @beniroquai !
A couple of things I noticed which might improve maintainability and readability. Happy to further discuss any of these suggestions:
camelCasing vs. pythonic_casing
Firstly, an issue of casing in Python, common to most of the repository. As an example, in PositionerManager it would be more "Pythonic" to have no camelCase for properties and methods like forPositioning, which should look like:
It might make sense for the front-end, but it would be more consistent at least in the back-end.
Simpler initialization and default values
A nice "pythonic" one-liner for simplifying .json parsing and setting a default value that simplifies this:
would look like:
Parsing the setup .json file more efficiently
Similar to this, in the managerProperties (example_uc2_labmaite.json) of the ESP32StageManager things could be simplified with dicts, which are more compatible to the position attribute, and then nicely parsed with the previous 1-liner:
Then, the initialization would look like:
self.homeSpeed = positionerInfo.managerProperties.get("homeSpeed", {axis: 15000 for axis in self.__axes })
Including the self.setupMotor, which could be called just once, taking advantage of the axes attribute:
Kind regards!
The text was updated successfully, but these errors were encountered: