Had an interview about an elixir dev contractor position this week, with the tech lead and the commercial director. I have had less distracting interviews. I think I’ll have to give up maintaining my elixir knowledge and dynamic languages overall. I’ll say something about the interview and point to some discussions/presentations about typed languages, for those interested.
The interviewer had some questions about / suggestions for a function I wrote:
@spec format_HH_MM(integer) :: String.t
defp format_HH_MM(nr) do
nr = abs(nr)
if nr < 10 do
"0#{nr}"
else
"#{nr}"
end
end
Q: A doctest would be handy for this function. Did you write a unit test for it?
A: It is a private function, I could add a comment explaining it but I thought the function explains
itself, the calls to it make the use even more clear I think. I see no added value in a unit test here,
if the function had not been private.
Q: Did you write a test for a function calling this one.
A: This is an elixir learning project maintained by me only (this was an excuse, I did not feel like starting long discussions)
Q: You are using if else in this function. That is not usual in functional languages. How would you improve this function?
A: I answered with the usual alternatives. I said nothing about my opinion: in the case of this function I see no improvement with these alternatives (the interviewer clearly did).
The interviewer did not name the parameter of which the value is re"assigned". Which I find no problem either in this very short function.
Some links:
Gary Bernhardt, well known in the javascript world, seems to have found a way out of a lot of testing hassle. From test-driven to type-driven.
Guido van Rossum (python):
“Type-Driven Program Synthesis” by Nadia Polikarpova
She won an award from the independent national science foundation in 2020:
https://www.nsf.gov/awardsearch/showAward?AWD_ID=1943623&HistoricalAwards=false