DEV Community

Mixins for Fun and Profit

Dane Hillard on December 22, 2016

This post originally appeared on Easy as Python in December 2016. There are people out there who have the time, motivation, and resources to ...
Collapse
 
md1023 profile image
Maxim Nikolaev

All logging mixins were cut out from our project recently due complexity of a custom logging functions. We had no ability to set log level, so we replaced custom solution with a structlog.

My practice shows mixins are sweet way to make your code beautiful and human readable. But most of the time those solutions get ugly because you start to perfect them and spend too much time that you could've spent on simpler less perfect solution.

Collapse
 
easyaspython profile image
Dane Hillard

Well said. Mixins are a sort of design pattern, and as with other design patterns should be used where the problem is a great fit. The logging example is potentially a poor use case in the real world, but we have at least one use case like the network protected view that is still serving us well. If, down the line, the requirements of that use case change we might notice some pains too. It's an evolving judgment call!