4

I hate when programming books have shit code examples.

Just came across these, in a single example app in a Go book:

- inconsistent casing of names

- ignoring go doc conventions about how comments should look like

- failing to provide comments beyond captain obvious level ones

- some essential functionality delegated to a "utils" file, and they should not be there (the whole file should not exist in such a small project. If you already dump your code into a "utils" here, what will you do in a large project?)

- arbitrary project structure. Why are some things dumped in package main, while others are separated out?

- why is db connection string hardcoded, yet the IP and port for the app to listen on is configurable from a json file?

- why does the data access code contain random functions that format dates for templates? If anything, these should really be in "utils".

- failing to use gofmt

These are just at a first glance. Seriously man, wft!

I wanted to check what topics could be useful from the book, but I guess this one is a stinker. It's just a shame that beginners will work through stuff like this and think this is the way it should be done.

Comments
  • 0
    It's it by any chance published by Packt? 😐
  • 0
    @saintograph nope... Manning this one
  • 0
    Yes, code publications are not the best in textbooks, but they are uniquely simple in their own way. A friend of mine is a professional critic of programming literature and other educational books. For some reason, no one criticizes such literature. But everything that is printed does not automatically become an example to follow. A friend of mine makes a criticism, write to Samantha about this https://digg.com/@samanta-sam and she will make a good review of this book, it is published on different trust sites and listens to opinions.
Add Comment