Thanks for the input. I'm in the process of doing our homework for 
migrating to golang so we appreciate all that input to be able to avoid 
common misuse of the language.
I'm far from having perfect understanding on the language but I'm starting 
to get the differences with a «typical» OO language and how to leverage its 
strengths

I'd have to say this one: https://play.golang.org/p/QQvWxfOiMB seems 
interesting even though its a tiny bit more complex to understand so I'll 
definitely look into that little pattern with base/derived

- Julien

On Monday, 30 January 2017 11:01:15 UTC-5, jul.s...@gmail.com wrote:
>
> Hi,
>
> Where I work, we are currently experimenting with golang in order to 
> migrate our existing Perl codebase to golang.
>
> Although Perl isn't a pure OO language, it allows for a lot of the OO 
> patterns to be used. One of the patterns we do use is where a superclass 
> method wraps a series of call to other methods that can be overloaded by 
> subclasses.
>
> Here is an example of what I mean:
> https://goo.gl/hTnUI4
>
> Now, I've tried to apply the same principle in golang but failed as the 
> method attack isn't called on the right type:
> https://play.golang.org/p/ZHhaQhSrms
>
> I've scratched my head for a bit to find a solution for this, and the idea 
> I found was to wrap the prep+attack call in a function that isn't tied to 
> any of the two structs
> https://play.golang.org/p/7nK8xEV5rj
>
> The example above creates the behaviour I initially expected but I don't 
> find its as clean as when using the classic OO pattern.
>
> Now my question is, how do people usually translate this classic OO 
> pattern into golang other than the way I found ?
>
> Thanks !
>
> - Julien
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to