Skip to content
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

Combine common code b/w Monster and User #14

Merged
merged 1 commit into from
Aug 8, 2020
Merged

Conversation

matthewjwhite
Copy link
Owner

Using **kwargs, we can easily pass all the parameters to the User
constructor in a dictionary without requiring the constructor to
contain parameters for the values that both it and Entity need.
Whatever User needs will not be in the **kwargs passed to Entity,
so Entity only gets the leftovers.

  • This model should help with instances of Pylint too-many-arguments
    going forward.

As part of these changes, I've also made it so that User is
instantiated directly using the DB document, as well as the Monster
being instantiated directly using the values from the YAML. This
requires that User/Monster/Entity member names match DB/YAML field names,
though transform functions could easily be created later on to switch
between what the YAML/DB needs and what the code needs. For the time
being, the simplicity is nice as I'm adding new fields, etc., though
the negatives are clear with an approach like this. It should not be
something that stays indefinitely.

Using **kwargs, we can easily pass all the parameters to the User
constructor in a dictionary without requiring the constructor to
contain parameters for the values that both it _and_ Entity need.
Whatever User needs will not be in the **kwargs passed to Entity,
so Entity only gets the leftovers.
* This model should help with instances of Pylint too-many-arguments
going forward.

As part of these changes, I've also made it so that User is
instantiated directly using the DB document, as well as the Monster
being instantiated directly using the values from the YAML. This
requires that User/Monster/Entity member names match DB/YAML field names,
though transform functions could easily be created later on to switch
between what the YAML/DB needs and what the code needs. For the time
being, the simplicity is nice as I'm adding new fields, etc., though
the negatives are clear with an approach like this. It should not be
something that stays indefinitely.
@matthewjwhite matthewjwhite merged commit 6cf37b7 into master Aug 8, 2020
This was referenced Aug 8, 2020
@matthewjwhite matthewjwhite deleted the simplify branch August 8, 2020 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant