I've been doing this for a while now and my code has been noticeably cleaner.
This is also a great way to introduce the idea of methods to complete beginners. I used this recently in a Java intro class.
In the beginning we pretended many "complicated" methods already existed (readNumber(), isPrime(int), etc.), but as we learned new things, we started filling them in. That way, we could focus on the program logic before learning about all the language specifics (which is a very good thing for when they switch to a different language).
I'm a Sr. Software Engineer at Flashpoint. I specialize in Python and Go, building functional, practical, and maintainable web systems leveraging Kubernetes and the cloud. Blog opinions are my own.
I've been doing this for a while now and my code has been noticeably cleaner.
This is also a great way to introduce the idea of methods to complete beginners. I used this recently in a Java intro class.
In the beginning we pretended many "complicated" methods already existed (readNumber(), isPrime(int), etc.), but as we learned new things, we started filling them in. That way, we could focus on the program logic before learning about all the language specifics (which is a very good thing for when they switch to a different language).
That’s really cool! I hadn’t thought about using this idea while teaching. I can see how that would make functions/methods more natural