If you like reading PDFs of presentations, here’s a PDF from a Twitter employee named How We Built Tools That Scale to Millions of Lines of Code.
Back in 2013 I read the book Clean Code by Robert C. Martin, and in an effort to keep that book alive with me a little while longer, I decided to make my own “Cliffs Notes” version of the book on this page. One of my favorite notes from below is that a language named LOGO used the keyword
to in the same way that Scala uses
def, so a method named
double would be defined as
to double... instead of
def double..., which seems like it would help developers name methods better.
A long time ago — 2005, to be exact — I read this article named Making wrong code look wrong, and it was a big influence on me. These days I don’t know how many people use variable naming conventions, but when working on web applications I still like the “us” (unsafe) and “s” (safe) convention for handling user input. As Joel Spolsky discusses in that article, that convention has a good way of making wrong software code look wrong.
(I originally wrote this blog post in 2012, and it seems like it has held up well over time.)
One great thing I’ve learned from Scala and functional programming over the last few months is this:
Make your variables immutable, unless there’s a good reason not to.
“Immutable” means that you can’t change (mutate) your variables; you mark them as final in Java, or use the val keyword in Scala. More important than you not changing your variables is that other programmers can’t change your variables, and you can’t change theirs.
“Talk is cheap. Show me the code.”
~ Linus Torvalds
“Show me your flowcharts (source code), and conceal your tables (domain model), and I shall continue to be mystified; show me your tables (domain model) and I won’t usually need your flowcharts (source code): they’ll be obvious.”
~ Fred Brooks, “The Mythical Man Month”
As a quick note, if you want to embed a Scala source code example in your Scaladoc comments, just put the source code block in between
}}} characters in your comments, as shown in this example:
“The first law of software quality.” From this Twitter page.
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 14.2, “How to paste and load blocks of code in the Scala REPL.”
You want to experiment with some code in the Scala REPL, and typing it in or trying to paste it into the REPL won’t work.