+ 9

What has helped us to apply better or innovatively the codes that we have learned? Please share examples.

As I learn coding, I find that applying the newly learnt code is the key. For example, more than once, it did not strike me that the solution was a 'loop' or 'switch' which will save me repeating many "if" conditions. So, I am sure there are many more stronger, better, and more innovative examples of simple one liners of codes which have replaced large chunks of repetitive codes that I often resort to. Accordingly, would love to learn, re-learn, play with such 'shorter break-through codes', so that when we learn a code we naturally think of all possible situations it can be potentially applied.

11th Oct 2020, 7:43 AM
Rafique
Rafique - avatar
1 Réponse
+ 3
"... so that when we learn a code we naturally think of all possible situations it can be potentially applied." I personally prefer to think the other way around. Learn the features that the language offers you and their pros and cons. When you are in a "situation" evaluate wich of those features fits better for the job and use it. This skill will come with practice.Reading others codes will also take you to another level. I think SoloLearn is a great place for this if you choose good samples, but you can check some websites that show public solutions for coding challenges too. I suppose it's common for beginners to write long, redundant codes. Trying to be concise and avoid repetition is a most when writting better code but don't fall into the trap of trying to write everything you can as a oneliner. Remember that our code should be easy to read and maintain too and many times the oneliner solution is not only ugly and unintuitive but even slower and more resource consuming than the longer approach.
11th Oct 2020, 7:53 PM
Kevin ★