JS Fun “duh” Mentals — Problems Can Slow You Down or Speed You Up
Today it hit me. Programming has changed me. I mean sure it has made me a cooler person and more annoying to be around if you don’t know code, because I’ll tell you about it anyways.
It has hit me that I am not only more accepting of problems but actually look at them as an opportunity. This is the completely opposite from what we have been taught in school where you get a problem wrong only leads to a lower grade.
There has been maybe one or two smaller projects I have done where pretty much everything went smooth and the code did what I told it to do. And it felt pretty good for a few minutes or hours afterwards. Then on to the next thing.
In contrast the other 98% of projects has had surprises and errors at every turn. This used to frustrate me and since I am not known for patience has always felt like I was getting behind or moving to slow when, actually, I was moving faster. Let me explain.
When everything goes smooth not much learning takes place. If you ever coded you are aware that when there is a “small” error many times you end up going down a rabbit hole and coming out the other end feeling like you’re an expert at something that you didn’t even know you were looking for.
For a current example I am doing a MERN application where I am using express and axios to feed an API. Not being able to do an update, PUT, to data on my API I did the normal console.logs from the beginning up to the axios function.
So then with feedback from stackoverflow I delved into the network tab to look at the network headers and match them to the Postman headers (Postman was actually working with the PUT request).
So now I know how to cross-reference what’s going on in the browser via my program with Postman.
In the middle of that and console.logging I got a few on the good old
and know I can show it via using “Alert(JSON.stringify(object,null,4))” but didn’t know how to show it via the terminal for the express part. I found an awesome module ,util, that does the same thing but on the back end. This was when I realized all I had to do was tweak my variable being called in my server.js file since it was an array in the schema. Yes, this whole time the api call and everything associated with it was correct but now I know how to verify and double and triple check that on every other project. And I can now act like I know what the difference is between x-www-form-urlencoded and application/json for formatting API calls.
As a tutor this is one of the concepts I am trying to leave with my students. Using problems as a way to speed up your learning of programming not just slowing your current project down. It’s our choice.
Follow me on Twitter