
Exercises in Programming Style - henrik_w
https://henrikwarne.com/2018/03/13/exercises-in-programming-style/
======
jboynyc
The author of this book launched a new open access journal called _The Art,
Science, and Engineering of Programming_ last year. Professor Lopes serves as
editor-in-chief. Much like the book, the journal focuses on the practice of
programming and its styles.

[http://programming-journal.org/](http://programming-journal.org/)

------
bringtheaction
> There is also an example with types, but this becomes very awkward to show
> in Python.

With the book having been published in 2014, and type hints [1] being
introduced with Python 3.5 released in 2015 [2], without knowing how the book
did it I guess this is one part of the book that could have been made better
in 2018.

[1]:
[https://docs.python.org/3/library/typing.html](https://docs.python.org/3/library/typing.html)

[2]:
[https://www.python.org/downloads/release/python-350/](https://www.python.org/downloads/release/python-350/)

~~~
faitswulff
I am planning on adding this book to my wishlist, but I agree with the
reviewer's note at the end:

> My only criticism of the book is the naming of the styles...In many cases,
> there are already establish names for the styles, but instead of using them,
> the author came up with her own. For example: Trinity instead of MVC, Things
> instead of Objects, Hollywood instead of Callbacks, Bulletin Board instead
> of Pub/Sub and Kick Forward instead of Continuation-passing. Those names are
> OK, but it is much better to stick to the industry standard ones.

I'd definitely include this change in a 2018 edition, too.

~~~
kerkeslager
MVC = Model View Presenter? Objects = Structs or Workers? Callbacks =
Continuations? Pub/Sub = Observer pattern?

Depending on what programming language background you come from, you may not
use the "established" names either.

~~~
barrkel
Generally speaking, solution to a terminology problem isn't to create
terminology n+1.

~~~
kerkeslager
That depends what the terminology problem is. If the problem is that you're
going to be criticized by a bunch of pedantic linguistic prescriptivists who
want you to use their terms in the way they want, creating new terms avoids
that criticism.

~~~
abiox
> avoids that criticism

is that really important to avoid? and one is just gaining new criticisms in
trade, no?

and of course, going bespoke and inventing everything yet again has it's
perks. maybe you'll get to be the person who "invented" a term, should it
catch on. great for the resume. :)

------
andrepd
Just one short note of appreciation for this book: Chapter 24 (Quarentine)
helped Haskell IO and monads "click" to me. Now I understand what they mean
when they say, for example, that "`IO String` represents not a string but a
computation that will return a String. You can store this computation (and
chain them), but they won't produce a value until you run them".

------
ahjones
The code associated with the book is all on Github:
[http://github.com/crista/exercises-in-programming-
style](http://github.com/crista/exercises-in-programming-style)

------
harel
This is very interesting. Not completely unrelated, a friend once told me he
can tell a lot about the personality of a person by looking at their code.
Years later I actually understood what he meant. Style does have some
correlation with personality. Psychology of code...

~~~
segmondy
Rubbish. Style has to do with habits picked up along the way. Nothing more
nothing else. Stop with the psuedo science. When programming in the large
(Enterprise). My style is Javaish very long names reactivateSuspendedUser().

When coding for myself, I prefer snake case to camel case and shorter variable
names.

Likewise in code, For work, I abstract and decouple to keep the code open for
future updates. For personal code, I write throwaway code. Given 2 classes
that I have developed for work or play. You will not be able to tell it's from
the same person.

~~~
n4r9
I think you're too quick to dismiss. All that your examples prove is that your
personal preferences are different to business style code. The fact that you
prefer snake case, shorter variable names and throwaway code is quite telling;
I enjoy programming puzzles like Advent of Code, and I always use long names
in camel case and try to never repeat code. I find that it reduces the mental
load and allows me to confidently code faster.

Also it's not pseudo-science. There are real, live techniques for identifying
programmers based on binaries:

[https://arxiv.org/pdf/1512.08546.pdf](https://arxiv.org/pdf/1512.08546.pdf)

~~~
mattherman
Identifying programmers based on their style is different than assuming people
with a certain style exhibit certain personality traits. Programmer A and
Programmer B could have almost identical styles, but that doesn't mean they
have similar personalities.

~~~
n4r9
Fair point, but I still think the comment I replied to was too quick to
dismiss. Especially the last sentence.

------
wickedwizard
I had this book as a student of Prof Lopes' class at UCI. One of the best
classes I had. Programming patterns/styles that senior programmers got through
experience were covered, which I liked a lot. As students we had to
compulsorily buy the book though.

------
mannykannot
This sounds like a very interesting book. The one small concern I might have
(I have only read the review) is that the sample problem might not be a good
case for some of the more complex techniques, such as introspection and
metaprogramming. I think we have all seen code that seems to have been
designed primarily to showcase all of its author's knowledge regardless of
whether it helps, and I would not want the book to be misunderstood as an
endorsement of that practice.

------
tzs
Note: its available on Safari Books Online. I would guess that a fair number
of people here have SBO subscriptions.

------
pjmorris
I like the review author's approach of writing his own version of the task
before reading, then looking for its closest match among the presented styles.

------
mathieubordere
Thanks for this! Added to my reading list ...

------
rs86
Amazing stuff!

