Archive for programming erlang

Code Review 6: Bowling Kata, Erlang edition

Posted in erlang with tags , , , , on October 13, 2010 by moffdub

I spent most of the past month interacting with the score server. The Armstrong book details two “stages” of distributed programming: running on two Erlang nodes on the same machine and running on two Erlang nodes on different machines.

First, I added some functionality to the server:

Continue reading

Code Review 5: Bowling Kata, Erlang edition

Posted in erlang with tags , , , , on September 15, 2010 by moffdub

So for this cycle of Erlang coding, I did a combination of coding and reading.

Code-wise, one of the most pertinent things I tried was extracting constants. My initial pass at this was to create a module with functions that returned the constants, but, as I thought, it lead me to an illegal guard expression compile error:

roll(on_frame, #frame{first_roll=First, second_roll=Second}, that_knocked_down, Pins_Knocked_Down) when (First =:= constants:all_pins_down()) and (Second =:= undefined) -> 
	{frame, #frame{first_roll = Pins_Knocked_Down, value = Pins_Knocked_Down}};

I quickly wised up and, through a combination of the Armstrong book and a Google search, I found that macros are the standard way to achieve constants in this language. Thusly:

Continue reading

Code Review 4: Bowling Kata, Erlang edition

Posted in erlang with tags , , , , , on August 25, 2010 by moffdub

Yeah, yeah, I bet you thought that I had slipped into my familiar “I don’t have enough time for this” mumbo bugspit of the hiatus. “Oh, it’s been three weeks since the last time he posted any code, he must’ve stopped.”

False.

Simply put, I had to weather our organization’s usual two-pronged quarterly software release, which involved a fifteen-hour day and two 3 A.M. wake-up calls. On with the code.

I’m not sure where to start. I was going to try to order this code review by the changes I made, but there have been so many, so I’ll just do this by module.

Continue reading

Follow

Get every new post delivered to your Inbox.