From 6df1cb57f15c3aeed8e823b89f2a51adc7131b78 Mon Sep 17 00:00:00 2001 From: Serge Bishyr Date: Wed, 18 Oct 2017 16:38:00 +0300 Subject: [PATCH] behavioral/visitor: add more explanations to visitor implementation --- behavioral/visitor.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/behavioral/visitor.md b/behavioral/visitor.md index 48a1088..b6f3d11 100644 --- a/behavioral/visitor.md +++ b/behavioral/visitor.md @@ -4,6 +4,7 @@ Visitor behavioral design pattern provides a way to separate an algorithm from a It gives the ability to extend the existing object without modifying the object itself. ## Implementation +Implementation of a visitor that can add functionality to the shape structures. ```go type Visitor interface { @@ -34,7 +35,7 @@ func (l Line) accept(v Visitor) string { ## Usage ### JSON marshaller - +Using visitor to marshal shapes to JSON ```go type JsonVisitor struct { } @@ -57,7 +58,7 @@ fmt.Println(line.accept(&jsonVisitor)) ``` ### XML marshaller - +Using visitor to marshal shapes to XML ```go type XmlVisitor struct { }