yourbasic / graph

Graph algorithms and data structures
https://yourbasic.org/golang/your-basic-func/
BSD 2-Clause "Simplified" License
711 stars 64 forks source link

Corrected a comment in graph.go #6

Closed NikhilDesai27 closed 3 years ago

korthaj commented 5 years ago

Nikhil, thanks for the patch!

On Tue, Oct 29, 2019 at 7:48 AM Nikhil Desai notifications@github.com wrote:


You can view, comment on, or merge this pull request online at:

https://github.com/yourbasic/graph/pull/6 Commit Summary

  • Corrected a comment in graph.go

File Changes

Patch Links:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/yourbasic/graph/pull/6?email_source=notifications&email_token=ACVN3SZAUB2MDIR7AJWTBYLQQ7MDNA5CNFSM4JGEG3WKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HU62MWA, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACVN3S32BC7HPTNOMQHDT6LQQ7MDNANCNFSM4JGEG3WA .

NikhilDesai27 commented 5 years ago

Hi Korthaj, I stumbled upon your graph library while reading your blog post about Go. Thanks for the blog post and the library. I would like to know your thought process behind designing the Iterator interface. I am a novice programmer and would like to know how you start designing libraries, or useful software systems/solutions.

korthaj commented 5 years ago

Ni Nikhil!

That's a really good and really hard question. :) I wrote a little bit about it in this article: https://yourbasic.org/algorithms/your-basic-api/ Here's the relevant section: Discover a well-fitting interface

The reason the print methods in Java and Go are so powerful is not only that they take any input, they are also able to handle that input in a sensible way.

In general, you want to find an interface that accepts everything your code can handle; and little or nothing else. This is typically very hard to do before you’ve had a good helping of your own dog food. That’s why I like the Go approach.

You start by writing concrete code, and in the process you discover interfaces that are increasingly accurate.

The graph.Iterator https://godoc.org/github.com/yourbasic/graph#Iterator interface is the result of my longest search for a well-fitting interface so far. I tried numerous graph data structures and implemented even more graph algorithms before finding a proper fit. There is no way I could have designed this up-front.

On Thu, Oct 31, 2019 at 4:31 PM Nikhil Desai notifications@github.com wrote:

Hi Korthaj, I stumbled upon your graph library while reading your blog post about Go. Thanks for the blog post and the library. I would like to know your thought process behind designing the Iterator interface. I am a novice programmer and would like to know how you start designing libraries, or useful software systems/solutions.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/yourbasic/graph/pull/6?email_source=notifications&email_token=ACVN3S6RE6GVDLGVTXW6WT3QRL23XA5CNFSM4JGEG3WKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECYGR7A#issuecomment-548432124, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACVN3SYCSUW7GRS5GMBR72TQRL23XANCNFSM4JGEG3WA .