Putting It All Together

Putting It All Together#

Using functions to promote modular programming serves a few key purposes:

  • Yields more concise code* by eliminating the need to write out code for the same task multiple times

  • Improves improve code readability

  • Helps us more effectively test and debug code

    • Because we are creating reusable pieces or building blocks of code, we can more readily pinpoint where things are going wrong or not working in our code.

  • Promotes code reuse and modularity by allowing us to define and call functions for common tasks

This may seem overly-complicated for a relatively simple program.

But imagine all kinds of more complex tasks we might want to accomplish in a programming environment- analyzing data, generating visualizations, creating textures, building interaction objects, etc. All of that becomes possible through functions- modular building blocks that can be combined to accomplish more complex tasks.