[go: up one dir, main page]

DEV Community

Carlos Yucra
Carlos Yucra

Posted on

Clean Code functions

I'm currently reading the "Clean Code" book, and I'm exploring the importance of good functions in software programming. In the beginning, when our code is concise, it's easy to understand both for ourselves and our team members. However, as we add more functionalities/code, our functions may grow, incorporating numerous lines of code. THIS IS NOT IDEAL

Here are some tips on functions that might prove helpful in your daily code.

Keep functions under 100 lines:

If a functions exceeds a hundred lines of code, consider breaking it down into smaller, more manageable functions.

Limit line length to 150 characters.

Shorter lines are easier to understand and facilitating quicker comprehension.

Focus on one thing.

Sometimes functions may have multiple tasks, try to break them down into smaller functions with distinct levels.

Ident level maximun of one or two.

Excessive information, sometimes referred to as "hadouken", arise when there are multple if/else levels in the code.

By following these guidelines, your code will become more readable and maintainable, making it easier for all (you and your team ;).

Top comments (0)