0

How to improve the code?

I've been learning programming for two weeks. Need an outside opinion. 1. What mistakes did you make? 2. How can you shorten the code without losing readability? 3. What advice can you give? https://www.sololearn.com/compiler-playground/c60l9sWxp80x

29th Jun 2023, 3:15 PM
Azeklir
Azeklir - avatar
5 Réponses
+ 3
The mistakes always appear, Don't exist a short way to learn... I advise you practice, practice and more practice... Nobody programming same than others.. So, feel free to programming like you want... with the time you will make your coding style.. Greating from Mexico and good luck in your way.. n.n
29th Jun 2023, 5:27 PM
Jesus Osvaldo Sandoval Solis
Jesus Osvaldo Sandoval Solis - avatar
+ 7
🔲 To shorten code without losing readability, consider the following techniques: 1. Use meaningful variable and function names. 2. Eliminate redundant or unnecessary code. 3. Utilize built-in functions and Libraries. 🔲 General advice for improving coding skills: 1. Practice regularly- Consistent practice is key to improving your programming skills. 2. Read and analyze code written by experienced programmers. 3. Seek feedback and learn from others. And Document your code.
29th Jun 2023, 4:15 PM
Kakashi はたけ
Kakashi はたけ - avatar
+ 2
it's always a tug of war between conciseness and readability. Readability is for the code maintainers or your future self, conciseness is for efficiency. A self-explanatory code is better than one full of comments.. use comments only to clarify important or obscure parts. Practice and learning from others is always a good strategy. Consistency is another good thing to have. If you find a style or formatting that works for you, stick to it. It makes understanding your code at a glance easier and faster because you automatically know where things are.
30th Jun 2023, 4:10 AM
Bob_Li
Bob_Li - avatar
+ 1
Start with simple problems.. First solve a problem.. Write the code.. Then don't leave the problem. try to optimize your code. Try to solve the same problem with different approach. Solve problems daily.. You will yourself start finding the best approach to solve problems.. If you are unable to solve a problem. Then read the tutorial related to that problem. Then solve it.
1st Jul 2023, 1:15 PM
Jayant Vishwakarma
Jayant Vishwakarma - avatar
0
Thanks for answers. They motivate.
1st Jul 2023, 11:03 AM
Azeklir
Azeklir - avatar