He's not suggesting you do: timeout := func(srv *Server) { ... }] NewServer("localhost", timeout) Rather, he's suggesting that you do: NewServer("localhost", Timeout(60)) Meaning that your package provides the various 2nd order function generators, as convenience configuration options. So a complex configured server might be created thusly NewServer("localhost",Timout(60),Speed(3600),Tls(certFile),Retry(3),LocallAddr("192.168.0.0.1"))
The talk was interesting. I wish he had shown the code for looping through the Term options as well. Also, if he has looked less on the screen and more on the camera/audience, it would have been even better due to better eyecontact. Nevertheless, the talk was excellent.
He addressed why he thought your second example wasn't to be preferred. As to the first example, having exported setters means that your type could not be immutable. Clear is better than clever, But if that concept is only ever applied to individual lines of code, it may force the higher level constructs those lines are part of into being more clever/complex overall.
He's not suggesting you do:
timeout := func(srv *Server) {
...
}]
NewServer("localhost", timeout)
Rather, he's suggesting that you do:
NewServer("localhost", Timeout(60))
Meaning that your package provides the various 2nd order function generators, as convenience configuration options.
So a complex configured server might be created thusly
NewServer("localhost",Timout(60),Speed(3600),Tls(certFile),Retry(3),LocallAddr("192.168.0.0.1"))
Excellent talk :)
Dave, regarding the Speed() function: Did you intend to have the user call Speed() first creating a closure value, then calling Open()?
-Pete
This is actually a pretty nifty..
The talk was interesting. I wish he had shown the code for looping through the Term options as well. Also, if he has looked less on the screen and more on the camera/audience, it would have been even better due to better eyecontact. Nevertheless, the talk was excellent.
Great talk, but horrible filming. What the point to constantly show presenter instead of presentation, especially when he explains the code??
Terrible advice. Whats wrong with:
svr, _ := NewMyServer("localhost")
svr.SetTimeout(60)
svr.EnableTLS(cert)
svr.SetRetry(3)
or:
opts := TermOptions{Speed: 115200, RawMode: true}
t, _ := NewTerm("/dev/tty", opts)
You don't need all these random disconnected functions. Clear is better than clever!!!
He addressed why he thought your second example wasn't to be preferred. As to the first example, having exported setters means that your type could not be immutable.
Clear is better than clever, But if that concept is only ever applied to individual lines of code, it may force the higher level constructs those lines are part of into being more clever/complex overall.
@@nakaimcaddis5531 His is the more 'clever' solution. Mine is much more simple.