2015-08-13 23:54:40 +02:00
|
|
|
---
|
|
|
|
layout: pattern
|
|
|
|
title: Double Dispatch
|
|
|
|
folder: double-dispatch
|
2015-08-15 18:03:05 +02:00
|
|
|
permalink: /patterns/double-dispatch/
|
2015-08-20 21:40:07 +02:00
|
|
|
categories: Other
|
|
|
|
tags: Java
|
2015-08-13 23:54:40 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
**Intent:** Double Dispatch pattern is a way to create maintainable dynamic
|
|
|
|
behavior based on receiver and parameter types.
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
**Applicability:** Use the Double Dispatch pattern when
|
|
|
|
|
|
|
|
* the dynamic behavior is not defined only based on receiving object's type but also on the receiving method's parameter type.
|
|
|
|
|
|
|
|
**Real world examples:**
|
|
|
|
|
2015-08-15 18:03:05 +02:00
|
|
|
* [ObjectOutputStream](https://docs.oracle.com/javase/8/docs/api/java/io/ObjectOutputStream.html)
|