Category ArchiveCode Quality



Agile & Code Quality & Languages & Scala 16 Oct 2008 07:15 am

Rules of structured programming and Scala

Recently I have been reading “Clean Code A Handbook of Agile Software Craftsmanship” by Robert C. Martin. I was originally inspired to read this book after attending a talk given by Robert Martin at JAOO earlier this year in Brisbane where he talked about “Clean Code”.

With my current focus being on Scala, I find myself constantly thinking about some of the opinions and ideas expressed in the book in the context of the Scala Language.

While discussing techniques defining functions in “Clean Code”, Robert Martin refers to Edsger Dijkstra’s rules of structured programming.

Dijkstra said that every function, and every block within a function, should have one entry and one exit. Following these rules means that there should only be one return statement in a function, no break or continue statements in a loop, and never, ever, any goto statements.

… an excerpt from “Clean Code A Handbook of Agile Software Craftsmanship” by Robert C. Martin.

Why does this make me think of Scala? While the Scala language has both the for and while control structures built-in, the implementers of the language have chosen not to include the break or continue commands as part of the language.

I think it is a brave decisions for language designers to make the decision to exclude such entrenched concepts as the break or the continue command from a language. This exclusion will force coders to think a little harder about the best way to describe their intent in code. I think Scala have got it right.

Code Quality & Java 01 Aug 2007 01:30 pm

Enforcing Package Dependencies (Part 4)

Code Quality & Java 30 May 2007 11:07 am

Enforcing Package Dependencies (Part 3)

Code Quality & Java 26 May 2007 12:46 pm

Enforcing Package Dependencies (Part 2)

Code Quality & Java 22 May 2007 09:44 pm

Enforcing Package Dependencies (Part 1)