3 ms·
A single line function makes sense because it allows you to alter functionality later without worrying you forgot about some instance of that pattern: def
by yummyfajitas 13y ago
A single line function makes sense because it allows you to alter functionality later without worrying you forgot about some instance of that pattern:
def logUnexpectedError(t: Throwable) = log.error("Oops: {}", t)
After I get it together and start keeping proper metrics:
def logUnexpectedError(t: Throwable) = {
log.error("Oops: {}", t)
statistics.errorCounterByClass(t.getClass()).inc()
}
- ufo 13y agobut on that opther hand, this means added complexity in all the cases where you dont overload it. Whoever reads the program will always have to keep overloading in mind.
- pedalpete 13y agohence a good naming convention. If the function name is clear, than it shouldn't be a mind drain at all, particularly if it is only a one line function.