Every single time I learn a new computer language, I challenge myself to do the Number to Word Converter with that language. What I mean by "Number to Word" converter is I input a number and it spits out the word. Usually I do this with recursion numbers 1 - a million.
ex -
2 prints out two
53 prints out fifty three
and so on..
The thing is I found out a new algorithm I can use. What I usually do is go by standard place to place, convert the number to a string and use recursion for each placement. But I found out I can do it another way. Function by function. So I can make one function for the tens place, another for the hundreds place, another for the thousands place, and so on. Then put it in an array and conclude the algorithm like that.
The thing is I'm asking what would be better. A guy mentioned this on the logo forum (logo computer language, when I was learning it) that he used an algorithm that makes many functions with small lines of code. I made one function with a lot of lines of code. I argued that with his algorithm he would have to add more code if he wanted to update it, while I had to add one statement to update it.
Can someone tell me, which would be better? One big function with a lot of code or many functions with small code in them?
Thanks ;)