Hi @dogweather. I like your ‘hey’ function but have a few thoughts. Recently I’ve been coming round to the idea that, in general, fewer functions is better. Why? Because more functions = more surface area for your code which makes understanding/maintaining it more difficult. This view has been articulated (in some form) by Linus, Carmack, and Blow which lends it some credibility. That is not to say that monolithic, ginormous functions are good, but that perhaps programmers have been underestimating the costs of abstracting into multiple functions. Your solution has 7 functions. For contrast here’s my single-function solution:
defmodule Bob do
def hey(input) do
cond do
String.ends_with?(input, "?") -> "Sure."
String.upcase(input) == input and String.downcase(input) != input -> "Whoa, chill out!"
String.trim(input) == "" -> "Fine. Be that way!"
true -> "Whatever."
end
end
end
http://exercism.io/submissions/03d9b6c8dbba45f79ac817ecd356a65a.
This might be overthinking a simple exercism exercise, but that’s the point of them. To start discussion! ![]()


















