If I'm understanding the Template Design Method directly, it's summed up as
"Don't call us, we'll call you". In C++ or more object-orientated languages
than Go, inheritance and virtual functions is a valid way to implement
this. But in Go (or indeed in C or C++ if you're so inclined), it's very
easily implemented with function parameters:


I think the Strategy Design Pattern is more of a match for an interface.

With Go 1.1 we've got Method Values, so you can also pass a bound method
value as a function parameter. (You could do that previously with closures).

I think the important thing is to distinguish between the essential nature
of the pattern, and the implementation details that are specific to a
particular language or class of languages.


On Tuesday, May 7, 2013 6:12:42 AM UTC+9, drago....@gmail.com wrote:

I know Go is not true OOP language, but is there any way for "base class"
to call method of "derivated class" polyformically, just like C++ virtual
Thank you
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 25 of 29 | next ›
Discussion Overview
groupgolang-nuts @
postedMay 6, '13 at 9:42p
activeMay 8, '13 at 8:48a



site design / logo © 2021 Grokbase