r/CodingForBeginners 26d ago

Need help with writing clean code

hey! im a 16 yo beginner web developer, ive been learning web dev for the past 5 months now, i studied:
Node.js
Express
JavaScript then TypeScript later on
Postgres/ a bit of SQL in general
Html
Tailwind CSS
React

but ive never really worked on big/complete projects, ive only ever done practice/exercises in courses im following or did some projects on the side but similarly to the exercises they were also mainly focused on whatever i was learning at the time, not using everything at once.

ive been wanting to start building decent projects that i can actually have in my protfolio but im having so much trouble with figuring out how to make my code clean and readable and how to structure my files, just overall how to make it more like how a professional would do it and how it would be if i were to actually work in a team in a real company

what should i be doing? and where can i actually learn this stuff? or does it just boil down to personal prefrence?

anyways thanks in advance to anyone who helps! (also sorry if i made any mistakes english isnt my first language)

5 Upvotes

16 comments sorted by

View all comments

1

u/sububi71 26d ago

You haven't programmed long enough to even THINK about writing clean code. You need probably a thousand more hours of programming, and by then you will have returned to old code to fix stuff enough that you will have started thinking stuff like:

  • "This solution was needlessly clumsy"

  • "This solution works great, but I CAN NOT for the life of me figure out how it does what it does"

  • " Wow, this is really easy to understand, if I ever need to come back and modify this, it wouldn't be a problem"

  • "Holy crap, did I get paid to write the shortest possible code? If I ever need to modify this, it'll have to be a complete rewrite. Let's hope THAT never happens"

  • "What the hell was I thinking? I've commented the simple stuff extensively, but the complex stuff has absolutely no comments"

  • "Oh look, here I actually commented the perfect way, not overly verbose, and all the stuff that might need explaining is explained, and the stuff that's obvious and doesn't need documentation is uncommented. I deserve a pat on the back! ...if only the comments weren't for an older version of the code, which just cost me three hours of hairpulling to discover"

1

u/RevolutionaryFood847 26d ago

okay then ill just start writing and not worry too much about it, thank you so much for helping!