Django REST Framework serializer viewset

157 阅读1分钟

medium.com/swlh/build-…

Mixin 增加了python代码的重用。 其中有两个面向对象编程OOP的支柱:delegation 和 polymorphism 代理和多态。 Delegation 可以用两种机制来实现composition(explicit delegation) and inheritance(implicit delegation)

behavioural or structural delegation

Inheritance(继承):子类有父类同样的内部结构 www.thedigitalcatonline.com/blog/2014/0… www.thedigitalcatonline.com/blog/2014/0…

Delegation was introduced in OOP as a way to reduce code duplication. When an object needs a specific feature it just delegates it to another class (either explicity or implicity), so the code is written just once.

www.thedigitalcatonline.com/blog/2020/0….