The benefits of keeping functions short
There are undeniable benefits to limiting the scope and size of our functions. I don’t like to focus so much on ‘keeping them short’, as I believe this can often lead to decision making based on cosmetics alone, but it’s a quick way to get the message across nonetheless. Regardless of which way you word it though, it’s an important piece of the clean code puzzle and it’s one which in my experience is often overlooked. What’s particularly frustrating about this, is that as a concept/rule it’s so easy to adhere to. Unlike SOLID for example, which you could argue takes an ongoing mental effort, or at least a fair bit of practice to pick-up.
Anyway before this post turns into a rant, let’s look at some of the benefits – and if you’re one of those full-page-function kind of developers, maybe (hopefully) I can inspire you to think twice next time around. Read more →