4 ms·
Any code that you write now will need to be edited in future for enhancement or bug fixes. If you are able to split individual steps or sub tasks of the main fu
by iamkp 8y ago
Any code that you write now will need to be edited in future for enhancement or bug fixes. If you are able to split individual steps or sub tasks of the main function into smaller sub functions, you would not be required to scan through the entire code in future for any modifications. If the functions are named properly, you can directly go to the function and edit it as required.
Also, assume that this big function breaks for some reason. Having sub functions will make it easier for you or anyone else maintaining the code to isolate it and track the source error in a much easier way.
So for me, functions are not just about re-usability, but also about maintenance and readability of code.