Mixins is an actively used design pattern created in 1980.

39Years Old
  • Mixins ranks in the top 50% of entities I track
  • the Mixins wikipedia page
  • Mixins first appeared in 1980
  • I have 15 facts about Mixins. what would you like to know? email me and let me know how I can help.

Languages with Mixins include julia, python, racket, ruby, typescript, xtext

Example from julia:

# Including the same code in different modules provides mixin-like behavior.
module Normal
include("mycode.jl")
end

module Testing
include("safe_operators.jl")
include("mycode.jl")
end

Example from python:

# https://easyaspython.com/mixins-for-fun-and-profit-cb9962760556
class EssentialFunctioner(LoggerMixin, object):

Example from racket:

(mixin (interface-expr ...) (interface-expr ...)
 class-clause ...)

Example from ruby:

module A
   def a1
   end
   def a2
   end
end
module B
   def b1
   end
   def b2
   end
end
class Sample
include A
include B
   def s1
   end
end
samp = Sample.new
samp.a1
samp.a2
samp.b1

Example from typescript:

// https://www.typescriptlang.org/docs/handbook/mixins.html
class SmartObject implements Disposable, Activatable {
}
// Note: still need to do some runtime ops to make that work.

Example from xtext:

grammar org.example.domainmodel.Domainmodel
       with org.eclipse.xtext.common.Terminals

Last updated November 21st, 2019