-
Notifications
You must be signed in to change notification settings - Fork 1k
Refactor callbacks #1487
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
Refactor callbacks #1487
Conversation
Integrate all callbacks into a single Callback class. Thus, reducing the (future) number of printcore attributes (all *cb attributes would be removed in a future release) and increasing printcore modularity. Also, by combining calls to callback functions and event handlers, we increase code reuse.
neofelis2X
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
I don't know much about the inner workings of the printcore, so I cannot give very specific feedback. Generally it looks like a great idea and a good improvement to the code. I run some tests on macos and everything works as expected.
- Is there a specific case that should be tested, aside from regular printing?
I had one comment on the documentation of the eventhandler, but thats about it.
Thanks a lot for testing it! I did not think of any particular test that needs to be done really. Not sure what might break. I guess users that use callbacks and/or addons (if there are any) could be affected the most. Other than that, pronsole and pronterface should (in theory) behave the same.
Good point, I should have elaborated on this. I'm suggesting the removal of many docstrings from methods from the |
|
Hi, I agree to what @neofelis2X wrote. I too think this is an improvement for the code. 👍 I took a look on the refactoring changes and did some tests for the windows versions. Everything runs as expected. The only thing I saw was, that we do not have all logging warnings as translatable strings, but this is something we can do later. (I hadn't translate all strings in the past for this part of the code) I haven't any real test scenarios for using Printcore directly, so I can't test this. Please let me know if there is something specific I can or should test in this regard. |
May thanks for reviewing.
True, that might be an easy fix though. I'll have a look. However, I'm unsure whether we should translate warnings and error messages from a library. I would've thought only the user apps (i.e. pronsole and pronterface) require translations. I'm unsure whether other projects actually translate their back-end libraries.
Unless you run pronterface/pronsole with addons, I don't think there's much more to test. Thanks again :) |
DivingDuck
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with the refactoring. Well done.
neofelis2X
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approval also from me!
Here is some more refactoring effort. As always this is up for discussion. In this case I'm suggesting some deprecations so we must have consensus on this. Also thorough testing would be nice.
The ultimate goal is to reduce the size of the
printcoreclass in order to increase modularity and therefore get code that easier to read and maintain. In this PR the idea is simply to:As of today, the total lines of code is not truly reduced because there is a lot of code kept for backwards compatibility. But, in the future, printcore will have less attributes (all *cb attributes would be removed) and less code lines overall.
Regarding the deprecations, the idea would be to release at least one minor version with the warnings in place for users to have time to adapt before releasing a major version which would finally remove the compatibility code.
Regarding the test suite. It now throws tons of warnings. This is intentional to prove two things: a) the same functionality we had before the refactoring is kept and b) the warnings are triggered and are the same as would be seen by users. Once the backwards compatibility code is removed the test suite should be updated.
Why did I change the name of callback/event "preprintsend" to "printpresend"? Because I had to change the signature of the callback function to align it with the event function. Such is a breaking change, so I had to come up with a new name to keep the old name still working until the removal takes place.
If anything else needs explaining/justifying please let me know.
Again, comments/suggestions/criticisms are all welcome.