-
Notifications
You must be signed in to change notification settings - Fork 30
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
adapter: Refactor XML and JSON de-/serialization methods #166
adapter: Refactor XML and JSON de-/serialization methods #166
Conversation
extract methods
extract methods
extract methods
extract methods
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 don't think it's necessary to create a new function for amending HasExtension
/HasSemantics
/etc. attributes in each (de-)serialization, as they only have one usage each and thus don't aid in reducing duplicate code. I wouldn't mind them for the purpose of shortening the other function though, but that wasn't too long either IMO.
But while you're at it, you can now also put the _amend_*_attrs()
functions in a dict with the corresponding type and perform the isinstance()
checks in a loop over said dict.
Maybe you can also unify the naming of the amend_*_attributes
and extend_with_*_attrs
functions to amend_*_attributes
, which fits best IMO.
The purpose of the refactoring is not only reducing duplicated code, but also improving readability. |
Good Idea! But may any problems occure because of the order? |
|
I believe this refactoring made the code more readable and I don't have any strong opinions on the remaining details, so I let you two work them out. |
# Conflicts: # basyx/aas/adapter/xml/xml_deserialization.py
Removed calls to abstract method "__init__" with trivial body via super(), as unsafe
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.
Let's discuss the super.__init__()
removal, but other than that it LGTM
The methods for handling attributes of abstract classes seemed to me too big.
In this PR these methods are refactored. Mostly a method extraction refactoring was done, to simplify the methods and to keep less abstraction levels in a single method
The function
_expect_type
was renamed to_is_of_type
as it represents clearer what the func does.This PR is not relevant for the V3.0 release and can be merged later