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).
Ryan is an engineer in the Sacramento Area with a focus in Python, Ruby, and Rust. Bash/Python Exercism mentor. Coding, physics, calculus, music, woodworking. Looking for work!
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