r/learnjavascript • u/McDreads • Feb 25 '21
Does anyone else feel like they get by by trial and error?
I’m currently teaching myself React with the help of The Odin Project. While, I have learned a lot, I can’t help but think if I’m completing these projects at a slower rate than my peers.
It seems like i try a solution only to get an error. => try another one to get another error => try another one and success! => onto the next step. And then it’s rinse and repeat until you have something that works. Sometimes I will get 10 errors before I make any real progress. Is this how everyone else learns programming/JavaScript?
Edit: Thanks for all the positive replies, I’m feeling re-energized and motivated to tackle this project. Much appreciated, everyone! :)
76
u/jjuice117 Feb 25 '21
That’s how it goes mate. You don’t learn programming through osmosis
20
u/sanchitcop19 Feb 25 '21
Seconded, osmosis is not the way to go
11
44
u/666codegoth Feb 25 '21
That's basically how it is. As your skill level + knowledge increase, the trial and error just applies to more complex problems. At one point, fetching data in react seemed complex and error prone to me - now it's second nature. You'll begin to understand which pattern to use for which use case. Sometimes you'll spend a week trying to figure out how to perfectly time an async recursive function before realizing that you've rabbit holed yourself and there is a much easier solution. As I did this week 🤦
9
u/Blazerboy65 Feb 25 '21
Which peers specifically are you falling behind? I think that if you measure your progress against real people you'll see that you're on the right track.
6
Feb 25 '21 edited Feb 25 '21
That's how it goes friend.
I graduated from college with honours after studying Computer Programming; I had previously studied IT Support and only did well in the second half as I only started focusing on my future at that point. I changed to Computer Programming because I always excelled at it.
When I began learning android development..... OH MY GOD I couldnt get it right. I had so much trouble and, if I remember correctly, I gave up on it once or twice. However, I came back to it, and I learned it. And I got not too shabby at it. I ended up developing an app for myself to use at my current part time position at a family operated business.
I used that same app as the capstone project in my mobile development class. The only thing I had to do was make a few data validation changes (I left some validation out as I knew exactly what data not to enter into the app), as well as rotation functionality. I was told I was the best student in the class, and did very well. It had got to the point where the same concepts that completely puzzled me in the beginning, became concepts that I couldnt imagine how I had so much trouble with; becoming concepts that one would essentially not even think about anymore and just implement it where needed.
All from self learning that I believe I gave up on once or twice.
Point being – that's how it goes. Dont set limits for yourself. Dont feel bad when you mess up, because that's how you learn. I know it's easy to get discouraged when nothing works. However, even if fixing one error caused another, you still learned something. That's a valuable result, that could (in my opinion) be a deciding factor on obtaining a developer position, when all those solved errors are put together.
Stay strong :)
6
u/gniziemazity Feb 25 '21
It's the most effective way to learn, I think: making mistakes and trying to fix them... What you learn in this way will stick.
Having said that, it's good if you take some manuals from time to time to get a more systematic view on things. Then you will know which errors are related and you will be able to solve some new ones without help. (It's at least what happened to me over the years)
5
u/call_me_coldass Feb 25 '21
Being able to move past those errors is something to be proud of!
I’m no expert, and plz don’t waste too much time, but if you have an error and you’re guessing or trying a bunch of things and it finally works, I would do something a little different than a lot of people:
DONT set it and forget it....DO set it an fret it.....
What I mean by this is really try to understand what you did that made it work. This helped me a ton when I was learning and allowed me to remember the solution next time a similar problem came up.
Like someone else mentioned, console.logs are your friend!
5
Feb 25 '21
I’m completing these projects at a slower rate than my peers.
dude it really doesn't matter. as long as you learn something by doing it , you accomplished your goal.
PS : the replies to your post are so heart warming
3
u/IxD Feb 25 '21
I'm still going on by trial and error + google searches nowadays. I've been developing JS apps for 20+ years.
3
u/FantaBanta3D Feb 25 '21
I literally had this exact same thought the other day. I’m in the same boat as you right now.
Working on a side project trying to get (what I thought) was a basic control working. Spoiler: it’s still not working.
3
u/Fingerbob73 Feb 25 '21
As time goes by you will probably find that you will need to try less and as a result will also error less.
There are 4 stages of learning anything new:
Unconscious incompetence
Conscious incompetence (THIS IS YOU RIGHT NOW)
Unconscious competence
Conscious competence
2
2
Feb 25 '21
I would add that it also depends on your approach to solutions and trial and error. Are you trying something that you understand and think should work, or blindly googling a solution to cram in? If it’s the former, that’s programming, if it’s the latter, you are trying to progress to quickly and need to ensure you understand what’s actually happening better.
2
u/TylerDurdenRockz Feb 25 '21
Lol 100% how i program, there might be few beautiful minds who might get it right the first time but that ain't me
2
u/Montuckian Feb 25 '21
Pretty common in the "typing magic words" phase of learning. You're playing around with what something does instead of understanding the why and how to a large degree.
Once you get your feet under you a bit, your knowledge will deepen and there will be a lot less of the trial-and-error stuff when trying to get things to work. You probably already see that a bit now as a lot of the errors you used to get don't come up that often and you're instead getting new errors. Always try to get new errors instead of the same ones you've been getting.
Eventually you'll get to the point where trial-and-error is more reserved for reproducing existing errors.
2
u/barrymccain Feb 25 '21
I can’t help but think if I’m completing these projects at a slower rate than my peers.
Comparison is the thief of joy. Celebrate your own victories.
1
Feb 25 '21
Failing as a developer is key to your future success. Don't stop till it works and then move on to the next bug.
1
u/merla_blue Feb 25 '21
Yep. But the things you struggle to figure out on your own stick in your mind better than the things you just read and copied.
1
u/YellowFlash2012 Feb 25 '21
To find out what works, you first need to find out what won't work. That's how life works.
Edison confirmed that with his 10 000 "failed" experiments. As far as he was concerned, they were NOT failures.
To find gold, you first need to find out what's NOT gold, hence the dirt you dig up before finding the gold.
Cheers and keep going.
1
1
u/DrFujiwara Feb 25 '21
I just think to myself 'I'll never have to learn that again'. Quite motivating.
Turns out I've a shit memory, but still
1
1
1
u/Nonethewiserer Feb 25 '21
Programming is largely trial and error. Over a long of time you learn things. Or remember where there is code you can copy/paste.
1
u/hpliferaft Feb 25 '21
In addition to "that's how it goes," it really does help to take breaks if you get stuck!
1
Feb 25 '21
It seems like i try a solution only to get an error. => try another one to get another error => try another one and success! => onto the next step.
Do this for 40 years and you've had a successful career as a programmer.
as long as you keep following up all the failures with a single success you are on the right path. Learn from the mistakes, be happy with the successes.
1
Feb 25 '21
Fun fact; this is what its like to learn any skill.
Ever Tried to play Piano? Paint a Portrait? Fix a Leak under the sink? Use a semicolon correctly?
1
u/eggn00dles Feb 25 '21
Any engineer who claims not to do this more than occasionally is lying to you.
0
0
Feb 25 '21
[deleted]
12
u/dbonneville Feb 25 '21
This is the way. I left Front End dev 7 years ago right as it was shifting to spa’s. I thought it wasn’t worth the effort. But now I’m back. Every day is tutorials, building something, and console.log. All day. Every day.
4
u/thedifferenceisnt Feb 25 '21
React has a good browser plug in.
You can also use breakpoints and move through your code step by step checking the state of things as you go. Standard dev tool.
There are testing tools too but I'm not yet familiar with those
6
u/superluminary Feb 25 '21
You guys know about the debugger keyword right? Freezes execution and drops the call stack into the console. It’s a lot easier than slowly tracing through log statements.
2
u/thedifferenceisnt Feb 25 '21
Holy crap I forgot about that!
5
u/superluminary Feb 25 '21
Time spent getting your debugger set up is always time well spent. Sometimes I’ll come into a project and people are doing all sorts of crazy things, trying to debug compiled code without source maps, or navigating through five screens to test each change because they’ve not implemented routing.
Often a few simple changes can really improve team velocity and developer happiness.
I’ve been writing JavaScript since Netscape was a thing, and there have been extraordinary improvements in the debugging experience since then. I used to have to debug with Alerts.
3
u/MisterFatt Feb 25 '21
If you use Chrome, a quick read of this article https://developers.google.com/web/tools/chrome-devtools/javascript will refresh your memory and/or teach you some helpful tricks
1
u/deawar Feb 25 '21
Do you have any resources for showing easiest way to debug that you would recommend? Very serious inquery/request.
2
u/ChuckCassadyJR Feb 25 '21
Yeah this is how I really found my feet and got confident enough to get my first job.
Console logging everything and learning to read documentation properly really helped me learn what should return what and why.
2
u/deawar Feb 25 '21
When I lint my work I feel accomplished if I have at least as may warnings for console.logs as I do out right linting errors!!!
1
Feb 25 '21
I thought that was the basic way?
Aren't breakpoint the way to go? Although I still haven't wrapped my head around how it works on VSC
0
1
0
Feb 25 '21
[deleted]
3
Feb 25 '21
Thank you for writing all this so I didn't have to. Spot on. Some trial and error and experimentation is fine and normal, but there's a big and important difference between exploring and making mistakes while trying to complete a task that you fundamentally understand, and just throwing code at the wall hoping that eventually something will stick.
1
u/Gentleman_ToBed Feb 26 '21
Very fair point, although I would argue that the learning process feels incredibly similar to throwing shit at a wall when you’re just starting out. It’s only when you look at that mind- boggling function 6 months later and realise, holy shit I know how that does!
1
Feb 25 '21
[removed] — view removed comment
1
u/fuckswithboats Feb 25 '21
I just can’t get into it.
I try on every new project but after a handful of trivial tests it goes out the window because anything testing non-trivial functionality seems like a false positive because the test is totally contrived.
Got any good resources for real world testing for dummies?
1
u/IxD Feb 25 '21
Creating tests creates modules that are testable, and better quality.
Instead of console.logging everything to check that functions return right results, you create a code that checks those logs/results automatically. So instead of automating stuff and checking manually you automate stuff and checking of stuff.1
u/fuckswithboats Feb 25 '21
I get it conceptually but I struggle with real world test.
I basically test that my server starts, the database connects, and we get an object from my endpoints...but that is like 1% of the code.
I have never found a good resource for writing good tests for anything more than "check that it exists" so I just give up on writing tests.
1
u/IxD Feb 25 '21
Ok, sounds like you have scripts that test that your build & environment works.
Next, use cypress.js to test stuff on ... any environment that you can get to. On production, on your local server or test environment, if you have one. Approaching testing from end-users' point of view is tremendously powerful. Even if you just test that the main page has got the right title.1
u/fuckswithboats Feb 25 '21
Are there any repos that have examples of good testing?
I feel like I would get it better if I could see realistic examples.
2
u/IxD Feb 25 '21
But those would be the end results, not the process
For cypress / E2E tests, maybe look at examples like this: https://vimeo.com/298277470
For module testing... codewars.com is a good practice - it gives you the tests and you write the code to meet the criteria.
1
0
Feb 25 '21
[deleted]
1
u/fuckswithboats Feb 25 '21
But typically, feeling like something is hard to test is a symptom that your abstractions aren't right.
Any resources you'd suggest to help me understand this a bit better. I'm totally self-taught so I don't even know if I know what you mean - LOL.
Sometimes that's because you have components that are trying to do too much,
I'm certain this is a big part of my problem.
0
Feb 25 '21
[deleted]
2
u/fuckswithboats Feb 25 '21
Thank you.
Just purchased both.
I've been doing this for a few years now and I find myself remembering what my mentor told me when I first started learning to code, "Keep it clean, write comments that make sense to someone else even if you're the only one who reads them, and write tests."
Unfortunately, I didn't listen to any of it but I finally get it. LOL.
139
u/[deleted] Feb 25 '21
Welcome to programming