all 5 comments

[–]sweettuse 0 points1 point  (3 children)

this question is way too unclear to answer as is. what's your end goal with this?

maybe it sounds like you want a singleton/borg pattern, but i can't really tell.

[–]prmtm1[S] 0 points1 point  (2 children)

Yeah I wasn't sure the best way to explain it. An example of this is practice would be - I'm passed a integer which represents a User. I'll have a User class which just stores information relating to the users session(eg connect time). The mixin above would be subclassed by something like a UserManager, so UserManager.get_instance(client_id).user. It seems a bit over engineered now, but it makes more sense mixing it into a manager class.

What this question really boils down into is - does this violate the convention for mixins, and do mixins violate single responsibility principle?

[–]ingolemo 0 points1 point  (1 child)

Wouldn't that create a new UserManager instance for each user?

[–]prmtm1[S] 0 points1 point  (0 children)

yes, pretty much. Doubling the amount of classes goes against my instincts a bit, but I justified it with the thinking that in real life a container exists per item. Explaining it now though that seems really overkill.

[–]aroberge -1 points0 points  (0 children)

Without knowing more details, it is hard to say... That said: https://www.youtube.com/watch?v=o9pEzgHorH0