<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/kotlin-design-patterns-visitor-explained-tgkwmgrar" -->

---
title: Kotlin Design Patterns: Visitor Explained | daily.dev
description: The Visitor design pattern allows for the separation of an algorithm from the object structure, enabling the addition of new algorithms without changing the...
canonical: https://daily.dev/posts/kotlin-design-patterns-visitor-explained-tgkwmgrar
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Kotlin Design Patterns: Visitor Explained | daily.dev
og:description: The Visitor design pattern allows for the separation of an algorithm from the object structure, enabling the addition of new algorithms without changing the...
og:url: https://daily.dev/posts/kotlin-design-patterns-visitor-explained-tgkwmgrar
og:image: https://api.daily.dev/og/posts/TGkWMgrAr.png
og:image:alt: Kotlin Design Patterns: Visitor Explained
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Kotlin Design Patterns: Visitor Explained

**[ProAndroidDev](https://daily.dev/sources/pand)** · 3 min read · 8 upvotes · 1 comments

## Summary

The Visitor design pattern allows for the separation of an algorithm from the object structure, enabling the addition of new algorithms without changing the object structure. It promotes open/closed principle, single responsibility, and extension of a class. However, updating all Visitors is necessary when a class is added or removed from the hierarchy.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://proandroiddev.com/kotlin-design-patterns-visitor-explained-21f474309210>

## Community discussion

Top comments from developers on daily.dev.

**@fayaz07** · 0 upvotes

> good read

---

Tags: [#kotlin](https://daily.dev/tags/kotlin), [#design-patterns](https://daily.dev/tags/design-patterns)

[View this post on daily.dev](https://daily.dev/posts/kotlin-design-patterns-visitor-explained-tgkwmgrar)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Kotlin Design Patterns: Visitor Explained","url":"https://daily.dev/posts/kotlin-design-patterns-visitor-explained-tgkwmgrar","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/kotlin-design-patterns-visitor-explained-tgkwmgrar"},"datePublished":"2024-05-07T16:05:24.967Z","dateModified":"2024-05-09T08:22:04.995Z","description":"The Visitor design pattern allows for the separation of an algorithm from the object structure, enabling the addition of new algorithms without changing the...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/4705ea9d3b73d4998dfddd2f1bfbe259?_a=AQAEuiZ","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/4705ea9d3b73d4998dfddd2f1bfbe259?_a=AQAEuiZ","isAccessibleForFree":true,"articleSection":"ProAndroidDev","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"ProAndroidDev","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/656c1eb1f1ef4f91936e86fc16545114","url":"https://daily.dev/sources/pand"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/kotlin-design-patterns-visitor-explained-tgkwmgrar","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":8},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"kotlin,design-patterns","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"ProAndroidDev","item":"https://daily.dev/sources/pand"},{"@type":"ListItem","position":3,"name":"Kotlin Design Patterns: Visitor Explained"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/kotlin-design-patterns-visitor-explained-tgkwmgrar","comment":[{"@type":"Comment","text":"good read","datePublished":"2024-07-18T09:38:47.844Z","url":"https://daily.dev/posts/TGkWMgrAr#c-O5RWMIdsg","author":{"@type":"Person","name":"Mohammad Fayaz","url":"https://daily.dev/fayaz07","image":"https://avatars.githubusercontent.com/u/35001172?v=4"}}]}
```

