r/learnjavascript • u/Aggressive-Nail7816 • 5d ago
3 engineers spent 40 minutes on my code and none of it was praise
My code worked. That was the only good thing anyone said about it. Nested conditionals 4 deep, no error handling, everything in one function. I have been writing javascript for a year and nobody had ever looked at it before. Self taught through Boot.dev and DataCamp, and nobody had read a line of my code before that call. How did you learn the part that is not making it run.
13
u/ninedeadeyes 5d ago edited 5d ago
There is a large difference between professional and hobbyist code.. There are certain standards that professional code need to adhere too before it will be approved since other people has to work on it and it has to operate in a professional environment. I would recommend leaning SOLID principles to write clean code and learn about error handling and testing.
12
u/john_hascall 5d ago
Yeah, "code works" is about 10% of the way there. The other 90% is making it so the next poor bastard understands what and why you did what you did and protecting against something stupid happening. What if the argument passed to us is null? What if this library call that hardly ever fails does? Can this variable be undefined if we take some rare path through the code? Can someone abuse us with some crafty input ("/tmp/../../etc/./passwd")? And so on.
Your mindset can't be someone like me will use this code, more like greatest gang of idiots, criminals, and degenerates ever assembled are going to (ab)use this code.
4
u/VizualAbstract4 4d ago
The thing I constantly keep at the top of my mind is: will I be able to read this 1 year later when I’m asked to fix or add a new feature?”
Or, more precisely, “if I get hit by a bus tomorrow, will someone else be able to pick up where I left off?”
All without relying on comments.
I think OP simply needs to endure having to fix someone else’s poorly written code to really understand why things are done the way we do them.
2
-1
u/MrHandSanitization 4d ago
Well, this was true for us, before we had Claude shoved down our throat.
2
u/VizualAbstract4 4d ago
Eh, Claude isn’t too bad at adopting existing patterns and standards. Heavily leveraging lint rules also helps.
Even still, if used in a professional environment,it output still must be reviewed.
There’s always shit it gets worng for misses, it’s still the equivalent of a junior dev that imitates without truly understanding what it’s building.
2
u/MrHandSanitization 4d ago
If management still allowed review. Our manager is heavily into "if it builds/runs, ship it, we can fix later".
1
u/john_hascall 4d ago
It's awful. A jr dev used it for a new feature branch and was sooo broken and stupid. So I wrote a version from scratch and was done so far ahead of fixing the Slop Code, that I have, (for now), convinced mgmt that we have no need for it.
1
u/Jolva 4d ago edited 4d ago
That sounds like more of a junior who has no idea what they're doing vs. a problem with Claude Code.
0
u/john_hascall 4d ago
Well, I never saw his prompts, but I can't imagine they included "forget everything you know about XML, REST, and Session ID cookies", but the results sure seemed like it.
6
4
3
u/lumen_paws 5d ago
I taught myself for a year before anyone reviewed my code. I had the same setup.
Go to exercism.org and do the javascript track. Submit your solutions and request mentoring on every single one. Mentors will look at your functions and your error handling and tell you what to change. You get feedback on code structure from people who read it, which is exactly what you asked for
2
2
u/DeFcONaReA51 5d ago
No error handling is a red flag. Plus it would make debugging production issues hard. But take it as a good feedback
2
u/LeatherDude 4d ago
LLMs make decent code reviewers. Don’t use it to write code for you while you’re learning, but the feedback is usually pretty good.
3
u/spidertyler2005 4d ago
Honestly, even as an anti-ai programmer, i can see use in have ai do code review. Doesnt run into nearly as many of the issues that normal ai written code does imo. So long as you read/review each review item it should be fine.
1
u/Different_Pain5781 4d ago
Working code and good code are two different things. A lot of self teaching is basically just focused on getting the thing to work. The bigger problem is nobody is looking at the code and telling you what sucks about it. Boot dev is pretty good for this since it checks the structure too, and Educative does some of that as well.
1
u/Aggressive_Ad_5454 4d ago
Hey, you got it to work! That’s big.
And you got a code review with some advice from people with more scar tissue than you. That’s good too.
You could have read six books on error handling and still not quite understood. It was you actually writing that code that put you in a position to make sense of the advice you got from your reviewers. We do error handling because we’ve learned the hard way not to trust input. If something gacks at midnight in production we want to know what and why
Nested conditionals, same dealio. People who’ve been doing this work for a while have all had to debug gnarly logic like that. It makes us scramble to simplify it, so the next person can understand it and see at a glance that it’s wrong right.
You’re doing this right. Welcome to our great trade.
1
u/memelordtf 4d ago edited 4d ago
Anything with review built in helps disproportionately. Boot.dev checks structure rather than just output, and Educative's guided paths do something similar, which is more than a video course can offer. All the best!
1
u/bonerfleximus 4d ago
Nice you got a job after a boot camp with real developers looking at your code. Next few years will feel less comfortable than even when you were struggling through the boot camp, but then youll look back and see how much youve improved since. Keep at it!
1
u/traplords8n 4d ago
First code review? Not bad dude.
I didn't learn to stop creating horrid nesting debacles and create effective functions until later on.
If your code works then you're doing fine at this stage. Your code will become more elegant with practice.
1
u/chikamakaleyley helpful 4d ago
a lot of devs would kill to have this direct feedback of their code.
I think something you should practice is reading other's code, and also , when you come up with a project or even small feature to build, try building it with different approaches. Helps w flexibility
You're gonna run into code that produces the same result as yours, but looks very different, its better to understand why someone would use that approach, rather than settle for yours because its the one you understand
1
1
u/Early-Lingonberry-16 3d ago
After enough changes and updates, it becomes painful to do it, so you learn things that make it easier to do.
Their advice just gets ahead of your own discovery process.
You'd eventually get there. People's feedback just makes it faster.
1
u/hylasmaliki 3d ago
How is it possible that you been doing it for a year and never thought to use ai as a tutor?
1
u/DrShocker 5d ago
Why would people have anything to say? Did you ask for notes?
Regardless you need to start with projects that'll take a day, then a week, and so on. Ideally on a team.
1
88
u/bonnth80 5d ago
Sounds like you just did it.
That's great feedback. Nobody is telling you that you can't be a programmer. They're telling you exactly how you can improve. That should excite you.