Why should I keep my functions small?

Asked by blessing007 · 6 months ago

1 Answer

47
amorebise · 6 months ago Top Answer

Small functions are easy to test and easy to understand. Think of a car—it’s made of many small parts that are easy to fix individually. If the whole car was one solid block, you couldn't fix anything!

I always tell my students: one function should do one thing. If it's doing two things, break it in half. Your future self will thank you.

Log in to add a comment.