Don't be afraid to get sloppy
Programming is usually thought of as something that's calculated and clinical. Before, I might have said that that's mostly just first impressions from people who have never done any programming, but that's not true at all.
When you read most books and blogs about programming, people mention that you always have to be DRY, that you should RTFM, that you should have well-defined views and models, that you can't mix presentation and content, etc. This gives the impression—yes, even to professional programmers—that things should be done in a straightforward way. It often implies that you don't really know what you're doing.
In reality, programming is a little bit like writing: authors rarely write something once and call it a story or even a whole novel. Ideas are pretty sloppy at first and as you put stuff on the page, the ideas begin to solidify.
The same goes for programming—especially when you're just starting out. It can take several iterations (or drafts if you want to stick with writing lingo) before you can get it right. So don't get frustrated if your code ends up being sloppy. You can always improve it!
Best part: It's easy to undo things. ⌘-Z that shit. You're not writing in stone, goddamn it!
Most of the time, this is what happens:
You start with a sort of outline of what your program is going to do, but you generally don't know all of the details. That's ok. That means trying stuff out and reading and failing and trying again.
When you're in the middle of writing your program, you sometimes end up going back to change a bunch of things. Maybe you end up finding patterns in your code or that it could be simpler if you did this sort of thing instead or if you named something differently.
If you're jumping into an old codebase, you don't usually know what everything does either. So you have to sort of feel your way around stuff. You end up searching for things and you try to delete or add stuff to see what they do. If you know git you can make a branch, fuck shit up, and throw that branch away! Computers 👏 are 👏 amazing 👏.
This is all normal! So if you feel inadequate because you feel like you don't know what the fuck you're doing, remember that this is all part of the process. Be comfortable with it.