Re:Functions Should Be Short And Sweet, But Why?
by amag on Wednesday January 22, 2014 @04:22AM
(#7101659)
>> indeed, I have seen functions that contain only one line of code. Even if that is intended for reuse, it makes no sense
IMHO it can make a lot of sense. In many cases you can clearly specify the intention of that one line by putting it in a function with an appropriate name. Just look at the example from the OP:
IMHO it can make a lot of sense. In many cases you can clearly specify the intention of that one line by putting it in a function with an appropriate name. Just look at the example from the OP:
void HandleNop() { SPIDataPut(SPI0_BASE, HOST_REPLY_POSACK); }
When you want to handle a NOP, you're not interested in how that NOP is handled, you just want it handled...:)