Is it too long ??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
11th Nov 2017, 4:47 AM
Shou Ya _
Shou Ya _ - avatar
4 Answers
+ 2
As long as it works, it shouldn't be too long.
11th Nov 2017, 4:51 AM
Learnsolo
0
You have a lot of duplicate code. Putting it in a function that is called in both places would make it easier to get running initially and maintain in the future. However, as Learnsolo stated working is more important than length.
11th Nov 2017, 5:13 AM
John Wells
John Wells - avatar
- 1
@<Learnsolo> The longer the code, the more likely you will encounter instruction cache misses ;(
11th Nov 2017, 7:35 AM
aklex
aklex - avatar
- 1
Too long? no; as long as it works - just like @<Learnsolo> said. refactoring the code, e.g. into function like @John Wells suggest help with ease of read, easier to maintain & reduce programming mistake; modern compilers will automatically refactor the code to optimise it's execution when it compiles your code.
11th Nov 2017, 12:19 PM
Alex Tjahjana
Alex Tjahjana - avatar