3 ms·
While it's not necessary to pull every block of code out into it's own function, its something a developer should keep in mind when writing code. A lot of peop
by RHSeeger 14y ago
While it's not necessary to pull every block of code out into it's own function, its something a developer should keep in mind when writing code.
A lot of people seem to thing that code duplication is the only reason to refactor code out into it's own function. While that's certainly a good reason, there are many others. For me, being able to test the code easily is a major one. The smaller the function (specifically the less branching and the less it does), the easier it is to test.
Obviously, it's a balancing act.