From 128db9aef2e0b87869efce29241ea00bba0b19a6 Mon Sep 17 00:00:00 2001 From: ismayilmalik Date: Sun, 17 Mar 2019 11:27:03 +0300 Subject: [PATCH] added comments to builder pattern --- creational/builder/builder.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/creational/builder/builder.go b/creational/builder/builder.go index 3676d25..2ace196 100644 --- a/creational/builder/builder.go +++ b/creational/builder/builder.go @@ -1,5 +1,6 @@ package builder +// Product to build type PersonalComputer struct { ramCap int hddCap int @@ -8,6 +9,7 @@ type PersonalComputer struct { gpu string } +// Each builder should implement this interface type PCBuilder interface { SetRAM() PCBuilder SetHDD() PCBuilder @@ -22,6 +24,11 @@ type HomeEditionPCBuilder struct { pc PersonalComputer } +// You may ask "Wait? we can set those values on struct initialization.Why +// brand new pattern for it?" and you are right. But remember this is just a +// concise implementation for with informational intend. In reality your +// construction methods will be more sophisticated, so struct initialization +// will not help. func (b *HomeEditionPCBuilder) SetRAM() PCBuilder { b.pc.ramCap = 4 return b