32 lines
1003 B
Markdown
Raw Normal View History

2017-05-03 19:48:29 +02:00
---
layout: pattern
title: Marker Interface
folder: marker
permalink: /patterns/marker/
categories: Structural
language: en
2017-05-03 19:48:29 +02:00
tags:
- Decoupling
2017-05-03 19:48:29 +02:00
---
## Intent
2017-05-23 01:38:02 +02:00
Using empty interfaces as markers to distinguish special treated objects.
2017-05-03 19:48:29 +02:00
## Class diagram
2017-05-03 19:49:25 +02:00
![alt text](./etc/MarkerDiagram.png "Marker Interface")
2017-05-03 19:48:29 +02:00
## Applicability
Use the Marker Interface pattern when
2017-05-23 01:38:02 +02:00
* you want to identify the special objects from normal objects (to treat them differently)
* you want to mark that some object is available for certain sort of operations
2017-05-03 19:48:29 +02:00
## Real world examples
2017-05-23 01:38:02 +02:00
* [javase.8.docs.api.java.io.Serializable](https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html)
* [javase.8.docs.api.java.lang.Cloneable](https://docs.oracle.com/javase/8/docs/api/java/lang/Cloneable.html)
2017-05-03 19:48:29 +02:00
## Credits
2020-07-06 13:31:07 +03:00
* [Effective Java](https://www.amazon.com/gp/product/0134685997/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0134685997&linkCode=as2&tag=javadesignpat-20&linkId=4e349f4b3ff8c50123f8147c828e53eb)