Being visually honest with F#

It’s been a busy month, some top qual­i­ty con­fer­ences – Code Mesh, Build Stuff, Func­By and NDC Lon­don – all cramped into the space of 4 weeks. It has been a blast, lots of talks and valu­able take­aways, and it was great to hang out with old friends and meet new ones. As soon as I find time I’ll put togeth­er some posts with my key take­aways from the con­fer­ences.

Dur­ing these con­fer­ences, Kevlin Hen­ney’s numer­ous talks have left a last­ing impres­sion on me. In his “Sev­en Inef­fec­tive Cod­ing Habits of Many Pro­gram­mers” talk at Build Stuff, he described the lack of visu­al hon­esty in code such as these:

pub­lic int howNotToLayoutMethodHeader(int firstAr­gu­ment,

    string sec­on­dAr­gu­ment)

and on what visu­al hon­esty means, he pre­sent­ed a num­ber of quotes from Daniel Higginbotham’s excel­lent Clean Up Your Mess web­site:

To answer the ques­tion “What is clean design?” most suc­cinct­ly: a clean design is one that sup­ports visu­al think­ing so peo­ple can meet their infor­ma­tion needs with a min­i­mum of con­scious effort.”

 

You con­vey infor­ma­tion by the way you arrange a design’s ele­ments in rela­tion to each oth­er. This infor­ma­tion is under­stood imme­di­ate­ly, if not con­scious­ly, by the peo­ple view­ing your design.”

 

This is great if the visu­al rela­tion­ships are obvi­ous and accu­rate, but if they’re not, your audi­ence is going to get con­fused. They’ll have to exam­ine your work care­ful­ly, going back and forth between the dif­fer­ent parts to make sure they under­stand.”

The quotes talk about lay­ing out infor­ma­tion so that their visu­al rela­tion­ships are obvi­ous and accu­rate.

So if you lay­out your method argu­ments in such a way that their visu­al rela­tion­ships are not accu­rate and you do that pur­pose­ful­ly, then you’re in fact being dis­hon­est.

image

 

As I sat there, I final­ly under­stood why F# pipes are so awe­some. I always knew it makes clean­er and more read­able code, it’s intu­itive, but I haven’t been able to find the words to explain why – the trou­ble with being able to under­stand some­thing with min­i­mum con­scious effort is that your con­scious mind can’t explain how it under­stood it.

Not any­more, now I final­ly under­stand it.

 

When we’re read­ing a piece of reg­u­lar Eng­lish text, we’re read­ing from left-to-right, then top-to-bot­tom. This con­ven­tion con­trols the flow of infor­ma­tion we receive as we read, so when we’re lay­ing out infor­ma­tion for peo­ple to con­sume, we lay them out in the order of left-to-right, then top-to-bot­tom.

image

But what about code?

When it comes to writ­ing nest­ed func­tion calls, some­how this flow of infor­ma­tion has been reversed!

image

With F#’s pipes (which has been adopt­ed in both Elm and Elixir by the way), we have final­ly man­aged to restore some san­i­ty and present sequence of func­tion calls in a way that match­es the way we con­sume any oth­er tex­tu­al infor­ma­tion.

image

Visu­al hon­esty right before your eyes!

 

Links

Clean Up Your Mess – A guide to Visu­al Design for every­one

NDC Oslo 2014 – Take­aways from keynote “it’s a write/read web”

NDC Oslo 2014 – Take­aways from “career reboot for the devel­op­er mind”

Take­aways from Theo Schlossnagle’s talk on Scal­able Inter­net Archi­tec­ture

Take­aways from Hewitt, Mei­jer and Szyperski’s talk on the Actor mod­el

Take­aways from Gael Fraiteur’s mul­ti­thread­ing talk