abstract-class


What is the difference between an Abstract Class and a Mixin?


I just found an article on a framework in Java that apparently allows it to support Mixins and something called Composite Oriented Programming (which for all I know might even be the same thing...) I've also heard of/worked with AOP, and I'm not sure how it differs from this either...
At a language-agnostic level, a mixin just adds functionality to a class, and is more for programmer convenience and to avoid code duplication. An abstract (base) class forms an is-a relationship and allows for polymorphism. One reason why inheritance is overused is that it's an easy way to implement mixins without writing any boilerplate in languages that don't really support them. The problem is that you're declaring a polymorphic is-a relationship as a side effect, making your API more confusing and possibly adding ambiguity. Hence, newer languages like D and Ruby support mixins as native features, allowing a convenient way to add a bunch of functionality to a class without declaring a polymorphic is-a relationship.
Mixin is never meant as stand alone class. They just add some functionality to the class you declare. In Python they can be easily applied by class decorators. For example you could decorate your class with Singleton mixin, making your class a singleton.

Related Links

Typescript multiple inheritance workarounds?
Class diagram usage in UML
AutoMapper and Base Types
Abstract Class Initialization
Covariant return types
Empty abstract function cannot contain body
Using Visitor Pattern to detect intersection between two shapes
mongodb lift class Snippet needs to be abstract
Abstract class as return of wcf ria method
OpenKinect - FreenectDevice abstract?
Intercepting method from abstract parent on derived instance using DynamicProxy
In an UML diagram, when should a class be abstract?
Abstract Class is a good practice?
Java - Using Abstract classes properly (problem with COLT)
Technical reason for using Abstract Classes in C#/Java
What is the difference between an Abstract Class and a Mixin?

Categories

HOME
date
vbscript
keras
deezer
homebrew
iterator
grep
alfresco
sqlite3
packages
ios-charts
phaser
event-handling
fallback
try-catch
openrefine
invantive-sql
karma-jasmine
google-pagespeed
excel-2007
telerik-reporting
crosstab
semantic-analysis
react-css-modules
virtualdub
web-api-testing
nat
preg-match
media-queries
react-chartjs
functor
gammu
io-redirection
dartium
serve
dynamics-crm-2013
starteam
code-search-engine
c11
twitch
webix-treetable
quadratic-programming
atomicity
jquery-nestable
python-c-api
typescript1.8
statsd
colorama
r-forge
capacity
cudafy.net
lync-client-sdk
smart-table
or-tools
medium.com
thrust
bstr
flash-cs5
bgp
bluegiga
pagerank
historian
kendonumerictextbox
splash
web-controls
geonetwork
dia
sorl-thumbnail
google-style-guide
asp.net-dynamic-data
eol
typo3-neos
industrial
ms-project-server-2010
spring-io
back-stack
sabredav
http-unit
dmoz
multipage
infobox
xdomainrequest
cinema-4d
gallio
ubuntu-9.04
w3wp

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App