Clean up mixins #148
Labels
No Label
backlog
bug
duplicate
enhancement
feature
help wanted
invalid
question
wontfix
bug
duplicate
enhancement
help wanted
in discussion
invalid
priority
1
priority
2
priority
3
priority
4
priority
5
question
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: IT-Naturschutz/konova#148
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Status quo
Mixins are used to encapsule methods and attributes for all major datatypes, which are used in different models, e.g.
RecordableObjectMixin
provides the attributes and methods used specifically for all recording related issues.There are some code fragments inside these mixins, which assert the mixin to be inherited by another mixin or another regular class, e.g.
BaseObject
, which provides the attributeidentifier
:In here the attributes
identifier
andtitle
are being used, despite the fact they do not even exist on the mixin but only onBaseObject
. Therefore we assert silently that this mixin can only be used properly if combined withBaseObject
.For our current purpose, this is a handy solution, since all needed logic can be wrapped entirely in the mixins and we can focus on model specific methods on the main models, which inherits the mixins.
Why toDo?
However, what if we will extend our model base (someday in the future) by another model, which does not follow our current model architecture, based on
BaseObject
and proper mixins? The mixin methods could possibly fail, if a required attribute in the method does not exist on this new model, since it's structured differently.Solution
We would need to restructre the code a little bit to be safe for such an occassion:
Using this approach we will have a lot cleaner mixins, since they only focus on their existing attributes. On the other hand, of course, we will move all these different code fragments into the model classes, which will grow in size (a little). Furthermore there will be redundancy, since formerly in a mixin placed logic will now need to live in
Intervention
,Compensation
,EMA
andEcoAccount
.After further research regarding best practices, it looks like Mixins are expected to behave like this. Mixins are generally seen as primary holding methods for other classes, which attributes are in most cases unknown to them.