What are the three reasons for the principle of keeping functions small? | SoloLearn: Learn to code for FREE!

0

What are the three reasons for the principle of keeping functions small?

4/27/2019 8:26:10 PM

Wanangwah

9 Answers

New Answer

+7

I like the concept of 'one unit, one task'. Let your function do exactly one clearly defined thing that can be expressed in a telling, shortish function name and doesn't need an overly large interface.

+6

I've always heard that if a function can't fit on one screen on your monitor, it's too big. Try to find ways to make it smaller.

+6

My methods/functions have not much to do: * do something with a value * return it or print it If the method needs a lot of calculations or other stuff then I write a method for the method. I think this keeps the code readable. Diego Lol :D

+5

Where is it claimed that it is 3?

+4

For readability and effectiveness

+4

Why not four? Why not two?

+3

Why not forty-two?

+3

Diego, that would with necessity lead to less objections!

+1

Jason, asking for three doesn't mean they are only three, they might be more. To me, it's the same as to say, "Give me five coding languages?" And you know that out of thirteen, you only give five. By the way, the three I can give are, readability, understandability and testability