+ 4

The Nuance of Coding

I can read and write and Identify(with a bit of syntax reassurance) Loops, switch, ifs, conditionals, Arrays, variable declaration, particualr methods.. but i dont know proper hierarchy, i dont know when it's important to put certain things wherever.. i mean i could write everything in the main method and what's wrong with that? I'm trying to look at certain things people who are paid to code do...

5th Jul 2018, 1:20 AM
capt picard
capt picard - avatar
3 odpowiedzi
+ 5
A lot of professionals share open source code on GitHub. I would recommend looking at code on there and trying to recreate it or make changes to it etc. At the end of the day there is nothing better than coding for yourself. I think a lot of people are scared of writing bad code so they end up not coding at all. In the beginning your code will be bad, that's just a fact of life. But you will only get better if you keep doing it every single day. Don't be afraid of bad code, especially on SoloLearn! Everyone here is learning anyways so CODE AWAY!
5th Jul 2018, 3:00 AM
Logan
Logan - avatar
+ 4
As you start practicing and write larger programs, you will discover for yourself the reasons why certain patterns are more efficient than others. For example, yes you can write everything in main if it is a small program, but it is not scalable to larger piece of code, where you need to make it easier to reuse code, troubleshoot, or work in teams.
5th Jul 2018, 7:12 AM
ifl
ifl - avatar
+ 3
There are four reasons to split code in blocks. Firstly, it saves your time and effort if you use some piece of code repeatedly. You write a function or method and use it instead of rewriting the same code again and again. Then it makes your code easier to debug and maintain. When code is split in blocks, you can search for an error not in your entire code, but in a shorter piece. Third it makes code reusable and enhances the teamwork. Function, method or class keeps all its gears inside and you can easily plant it into any code not minding variable name conflicts. And last, but not the least, it makes your code more readable and comprehensive. So keep this four reasons in mind, when deciding, whether to put a piece if code in separate block or not.
5th Jul 2018, 7:23 AM
Дмитро Іванов
Дмитро Іванов - avatar