r/learnprogramming • u/Total-Subject2763 • Mar 07 '23
Is it normal as a junior programmer..
To spend hours looking over the same block of code, trying to sort out ‘why the f*ck isn’t this working!?’, only to realize the error you made is so monumentally, and stupidly obvious that it leaves you feeling like a completely useless moron? Lol
195
u/insertAlias Mar 07 '23
Last week, I spent almost an hour debugging a particular error. I could not, for the life of me, understand why a particular bug I was working on just wasn't being fixed with the code I just submitted. It was doing things that it shouldn't have been able to do with the edits I made.
My error? I forgot to save the file before running the "deploy to dev" script. I was debugging the previous version of my code.
Another common issue: I'll bash my head against something for hours. Then call in another dev to look at my issue, only to realize exactly what the problem is while describing it to them. It's called Rubber Duck Debugging, and it's normal, but damned if it doesn't happen to me practically every time. I even try to do it without the other person, but for whatever reason, it still happens.
I've been doing this professionally for 16 years. We all make dumb mistakes and miss obvious issues. You just try to do better in the future.
23
28
Mar 07 '23
I find it so embarrassing when you explain the issue and you come up with the solution
46
u/EspacioBlanq Mar 07 '23
That's why you explain it to the rubber duck first.
The rubber duck doesn't judge
15
8
u/Pantzzzzless Mar 07 '23
I always try type questions out in really great detail, because 9/10 I answer my own question.
11
Mar 07 '23
Another common issue: I'll bash my head against something for hours. Then call in another dev to look at my issue, only to realize exactly what the problem is while describing it to them.
Oh man, this happens to me SO often. When I finally can't take it anymore and reach out for help, just the process of walking someone else through the problem causes me to finally notice it!
3
u/dysprog Mar 08 '23
Trying to serialize your mental graph of the problem forces you to touch the node that you've been ignoring.
→ More replies (4)2
u/PanopDev Mar 08 '23
My god,the amount of times I have had unsaved files in my folder causing shit to not work 🤬🤬🤬
I almost always look to see if save all is grayed out in vscode before checking my code now, but I do it so religiously that I forget to look for that for a while if I do forget.
2.2k
u/RubbishArtist Mar 07 '23
It's normal as a senior programmer too
494
u/captainAwesomePants Mar 07 '23
Can confirm. Been a senior dev for years. Have lost days to a single semicolon or using the wrong variable or something.
123
u/nedal8 Mar 07 '23
I spent HOURS the other day, trying to figure out why this websocket wasn't working right.. turns out I never deleted the old instance when I rescoped it.. So there were two with the same name.. Still not sure how that even ran.
22
u/toferdelachris Mar 08 '23
This sounds like a nightmare scenario. That’s when it boils down to “shut the whole damn thing down and restart”
What’s that? Production server? Did I stutter? Shut it all down!
136
u/chaoticbean14 Mar 07 '23
an IDE saves a ton of time in some of these cases...
Literally big red "You missed a semicolon" or "this variable isn't used", etc.
Once I started using tools like that? My time spent programming dropped through the floor. Of course, my time spent just thinking about the efficiency of the code - went through the roof.
But it's very rare I make those kinds of mistakes now - and when I do time wasted on them is extremely small.
123
Mar 07 '23
an IDE saves a ton of time in some of these cases...
Sure, but vim puts hair on your chest
/s
→ More replies (14)→ More replies (14)16
u/patternboy Mar 08 '23
I'm experienced with R but a relative novice with python. I've never done any programming without an IDE, but yesterday I was reminded of the limitations of IDEs quite painfully. I spent hours trying to solve a problem with a set of dictionaries not being populated properly using a set of nested for loops. I understand this is a relatively simple task for any professional developer/data person. I'd never done such a complicated set of nested loops before though, iterating through several different lists/dictionaries of different lengths to be consolidated (all originating from a powershell subprocess stdout string).
It turned out that a totally correct line was just indented one loop too deep and this was messing up the loops. Literally a backspace solved the whole thing. But the IDE didn't help any as there was nothing wrong with the syntax. I of course felt the excitement once it finally worked, but also felt frustrated and stupid, and retired to bed at 4am and had recurring dreams about solving problems with key:value pairs that I had already solved.
→ More replies (7)15
u/a_reply_to_a_post Mar 08 '23
these kids these days don't even use semicolons in javascript anymore
sick little bastards and their eslinting
→ More replies (5)→ More replies (7)6
u/freerider Mar 08 '23
I spent 3 hours on a similar If clause:
a = 4; if(a < 3); { std::cout << "a is less than 4" << std:: endl; }→ More replies (1)72
u/johnbburg Mar 07 '23
As a senior, your should be sure to blame other people's documentation and APIs first before you realize it's your mistake.
16
u/PaulCoddington Mar 08 '23
Don't forget to report it as a bug: the moment you have clicked the submit button you will have an epiphany that reveals exactly how you stuffed up.
→ More replies (1)5
u/a_reply_to_a_post Mar 08 '23
As a senior, your should be sure to blame other people
this is called "fucking your way to the top"
15
u/SalamanderOk6944 Mar 07 '23
25 years of development experience. I'm an idiot.
Actually, I'm pretty quick and amazed at how quickly I can dial in on the root problem of an issue.
But
Sometimes I get stumped on things, take the really long way around, have no idea how to even initially ask about a challenge I'm facing, try a million wrong things.. because it's fun to understand.
That said, if it's work related, then time is a factor, and I'll make sure someone is updated to my progress. I may have to switch priorities.
14
u/a_reply_to_a_post Mar 08 '23
right there with you...20+ years of imposter complexing my way to a paycheck
i get asked to mentor new devs and i kinda let them know right away i really don't know shit, i've just been around long enough to make some semi educated guesses and break things down in a way that can be digested by idiots like myself
5
u/daerogami Mar 08 '23
break things down in a way that can be digested by idiots like myself
therein lies the wisdom
7
u/we_are_ananonumys Mar 08 '23
Saw this spectacular tweet once, something like “junior developer means everyone can see why your code is wrong. Senior developer means no one can see why your code is wrong.”
5
3
u/samanime Mar 08 '23
Yup. Senior dev for ages. Spent two days on something incredibly stupid once I found it. :P
→ More replies (1)3
u/debugging_scribe Mar 08 '23
90% of the time I am stuck on something it turns out to be something dumb.
478
u/AlsoInteresting Mar 07 '23
Take a walk. And come back.
360
u/chartley1988 Mar 07 '23
Great advice for programming. TERRIBLE advice for cooking.
44
40
5
Mar 07 '23
On Halloween years ago I caught my kitchen on fire. And I caught my grill on fire once to lol. However the first incident wasn't really food related. The grill incident was. Got lucky both times, especially the kitchen incident with very little damage on one of the walls. And the only reason why the house didn't burn down was because I heard a very faint scream through my headphones. When I took the headphones off I realized someone was screaming my name and the entire trash can was up in flames up to the ceiling.
5
u/kitt614 Mar 07 '23 edited Mar 08 '23
My wife almost started a fire in our kitchen this Halloween. Seems like a bad day to use the kitchen.
(Edit to fix typo)
24
u/cranburycat Mar 07 '23
This really helps me almost always and I solve it within 5 minutes for which I spent close to 3-5 hours solving it earlier. I’ve had dreamt of solutions and it had worked out the next morning first thing!
20
u/AlsoInteresting Mar 07 '23
Yes. In between 2 dreams, the solution pops up. Then scramble to find a piece of paper to take notes
16
u/OrganicPancakeSauce Mar 07 '23
100%. Even after a decade of experience, I find myself needing to step away (which I never do) only to come back the next morning and immediately see what’s going on.
Fresh air, a nap, refreshing sleep - any of those things really belp
5
u/dysprog Mar 08 '23
I finally figured out That One Bug in the shower the other day.
Except that it was a bug from 5 years ago in software we don't use anymore.
4
u/codetrasher Mar 08 '23
I was going to suggest naps, as well. Mainly because fairly recently I was able to solve and refactor a logic bug with Angular/TypeScript code I had written a couple of months earlier. I knew the code structure sucked back then but it solved the issue I was having at the time so I committed and pushed it, but it came back to bite my ass a couple of weeks ago when a user reported a bug. I'm working from home and that day the kid was at home with flu, and usually on weekends and cases like this we take a nap or at least rest a while. That day I actually fell asleep for a moment as I was more tired than usual, and after waking up somehow the solution for my code problem came as clear as the day was, so I took notes of what I needed to do and started working. I was able to clean up the code tremendously with fewer if-elses and it solved the new bug, too.
I have plenty of other examples to share about the importance of taking breaks, naps or walks during (mental) work like programming. Bashing your head against the problem won't make you come up with the solution any quicker but taking your mind off of the problem actually could, more often than not.
→ More replies (1)13
u/corporaterebel Mar 07 '23
I go work out.
It's amazing that physical exhaustion can make your code so much better...
→ More replies (1)7
3
3
u/ceeBread Mar 08 '23
Go get a coffee, talk to a rubber duck, go for a walk. Those are things I do, and then go back and keep staringz
5
Mar 08 '23
The amount of times I’ve banged my head on a problem, took a break and came back only to resolve it easily has been about 100%
2
2
2
u/blah-blasphemy Mar 09 '23
That's the best advice. Take a break and you'll figure it out.
What also works for me is to sleep on it overnight. Right before i sleep, I debug in my head and usually solve it.... But if i don't, that's where the real frustration comes!!
47
u/ehr1c Mar 07 '23
I made a single typo once that I didn't clue into until three days of debugging, and of course I discovered it on a zoom call with my entire team who still makes fun of me to this day lmao.
8
u/SeltzerCountry Mar 08 '23
I remember once having to build a small application as part of a coding assignment and was working with two other guys. Somehow none of us noticed that we misspelled the SQL table name when creating it and then couldn’t figure out why our whole MVC setup we built to interact with that table wasn’t working haha. Once we figured out the table name was the issue we tried to start from scratch and somehow misspelled the same table name for a second time haha
25
u/mosenco Mar 07 '23
sometimes is because u spent too much without taking any break. I remember wasting the whole day for a bug, then after a small break "ohh the semicolon"
24
u/X5455 Mar 07 '23
It happens to most programmers, regardless of experience level.
This week I spent almost an hour trying to troubleshoot an endless loop because I forgot the trailing / on a path and I have 16 years of programming experience. 🤡
21
u/abyns3 Mar 07 '23
sounds about right.
Remember -- question yourself, not the code. A computer is always going to be honest.
19
u/Embarrassed-Green898 Mar 07 '23
back in the days ... I had an error for an entire day .. the function was called display() , and not diplay()
Nowadays IDE will flag this easily .. but this was 1990-1995.
16
u/nboro94 Mar 08 '23 edited Mar 08 '23
Me with 5 years experience:
Runs program, it produces unexpected results
Me: "hmmm that's odd" looks over the code, changes nothing and runs it again with the same results.
Me: "hmm I wonder why it's not working?" looks over the code, changes nothing and runs it again with the same results.
Me: "What the..!? This should be working!" looks over the code, changes nothing and runs it again with the same results.
7
u/mxzf Mar 08 '23
The worst is when every other one of those runs gives you unexpected results; every time you run it again it spits out something different as you slowly descend into madness and try to figure out what the hell is going wrong that repeated runs give different results.
→ More replies (1)
12
u/TunaFishManwich Mar 07 '23
Dude, i'm closing in on 2 decades of experience and that shit happens al the time. Don't beat yourself up. If it were actually obvious every time you would not be human.
9
u/RandomComputerFellow Mar 08 '23
90% of the issues are like this. By the way. It is not always "why the fuck isn't this working" but often also "why the fuck is this working".
8
u/PanopDev Mar 08 '23
The problem is, the solution is so easy it's the only place you don't look. If you've spent an hour investigating the same area(s) for the issue, it's often not where you are looking.
7
u/C0rinthian Mar 07 '23
This is why taking breaks is important. It gives your brain to catch up on processing.
6
u/Hk0203 Mar 08 '23
This is SO important.
It’s almost magical how taking a break and coming back to it helps you to spot the error in record time.
6
u/a_reply_to_a_post Mar 08 '23
yeah, that's the pro part of pro-gramming...
spend 3 hours writing a function, then 3 hours debugging it to realize you never called the function...with lunch and second lunch, that's a full day of coding
5
4
4
4
u/aevitas1 Mar 08 '23
Tunnel vision is a bitch.
I fix most of these bugs I am stuck on while taking a shower / driving etc. It takes stepping away sometimes to fix the problem you’re facing.
3
u/ChampionshipBusy2260 Mar 07 '23
Haha yeah everyone makes mistakes and it's all part of the learning process. So don't beat yourself up too much, just keep at it and you'll get better with time!
3
3
u/xRageNugget Mar 08 '23
14 years development experience. Spent 3h yesterday on missing brackets when calling cors() on an express server.
3
u/adamantium4084 Mar 08 '23
I once needlessly went down a rabbit hole of passing perl arrays as arguments due to a missing semicolon on a previous line. The error code was very misleading
3
u/terminatorgeek Mar 08 '23
As a junior, can confirm. Most of the time lately it has come down to me missing a fundamental understanding of the library I'm working with, or a quirk of the language, or just JavaScript being stupid JavaScript
3
3
u/DrockDrg99 Mar 08 '23
Yes, it’s normal for any programmer. Wait until you stare at a block of code you know SHOULDNT be working but it appears to be. That’s when your brain really gets scrambled.
3
2
2
2
2
u/Ezykial_1056 Mar 08 '23
I have .. 40 years sheesh .. of programming experience.
I spent a week looking at code to find a 2 character code change, literally 2 characters were changed in the bug fix. Obviously it impacted me, but what your describing is very normal.
The thing is, if it was obvious (to you), you never would have coded it that way.
The (to you) is a reminder WHY code reviews are awesome. A new pair of eyes looking at code can make a world of difference.
2
2
2
1
u/AndyOfClapham Mar 07 '23
Yes, me losing two hours yesterday because of an open calc bracket in the style sheet 😯
1
u/etoastie Mar 07 '23
My worst one of these:
A Spring Boot project I was making had an autogenerated configuration file that I generally didn't touch. I don't entirely know how, but I messed it up somehow, without ever learning about its existence. Eventually I had to modify code regarding a module where the change causes the system to crash with an opaque error. I spent over 2 weeks combing every possible file, and eventually resorting to copying and pasting every file into a clean module one by one. Eventually I noticed a missing key between my project's config and the clone's autogenerated config, and voila...
Some months later, I learned about git bisect, which would have been a massive help.
1
u/Runner_53 Mar 08 '23
Yes, of course.
But what you want to do is step through the code in a debugger as it goes sideways. Often this reveals the problem immediately. Just reading the code is for me the last resort. Only used for bugs that can't be observed in the debugger.
1
1
1
Mar 07 '23
I did this recently in a technical interview on an easy leetcode. It was so embarrassing.
1
u/TheSheepSheerer Mar 07 '23
It's normal at any time, with any activity actually.
If you stare at the same thing for too long, you begin to lose your train of thought.
1
Mar 07 '23
It isn't working, why? R= I don't call the function Continues to not working R= I don't call this other function here too. Continues to not working R= ...bro, wtf.
1
u/IndexOf0 Mar 07 '23
That’s completely normal. The best thing to do is honestly take a break and come back to it. You want to go into a state of diffused thinking.
1
u/maninblakkk Mar 07 '23
I've been trying to work out why my mod wasn't working for like 4h , the game was even pointing me to the exact line, turns out x and X are 2 diffrent variables.
1
Mar 07 '23
When I worked in JS it happened a lot not as much now that I work in Kotlin. But yeah common
1
Mar 07 '23
It is normal regardless of how seasoned you are.
You can literally spend hours searching for that extra space or missing semicolon.
1
1
u/young_horhey Mar 07 '23
Depends what you mean by ‘looking over’. Are you just reading over the code trying to figure it out in your head? Or are you using a debugger to step through the code & inspect variables etc.?
1
1
1
u/Kodiak01 Mar 07 '23
The trick to finding what you can't see is to start looking for something else.
1
1
1
Mar 07 '23
The most frustrating thing is when it was you that wrote the code originally.
What the heck is this doing? Why would anyone do this? Wait, this bit looks familiar...hang on...[checks history]...crap. why did I do this.
Then, usually an hour later
Ohhhh, right.
1
1
u/Head-Sick Mar 07 '23
Totally normal. God bless my fiancé listening to me walk her through lines of code. She's not a programmer or particularly good at computers, but if I am really stuck I'll walk her through line by line explaining in as easy terms as possible what I am INTENDING each line to do and I find that helps. I often use her facial reactions to help me scope where perhaps my logic makes no sense.
1
1
u/OzzitoDorito Mar 07 '23
I spent a good 30 minutes trying to work out why an authentication guard was not working, only to realise I was checking if(user.isCurrentlyLoggedIn) instead of calling the function if(user.isCurrentlyLoggedIn()) which evaluates to true in js. Probably another good reason to always do booleanFunction === true in JS lol.
1
u/Laxcougar18 Mar 07 '23
Yes. And this won't be the last time it happens. But it will happen less over time.
1
u/alexppetrov Mar 07 '23
I spent hours today going down the dependencies rabbit hole of our system because our lead told me to do something and i misunderstood and started investigating the whole process... It's how we learn i guess. The actual thing was like 30 minute configuration or something
1
1
u/kitt614 Mar 07 '23
100% normal.
I was in a business meeting and was showing off how we split our database schemas. I spun up a new schema and tried to launch the tool and kept hitting an error on render.
15 min later I realized I forgot an “i” in a word in my seed file. No one batted and eye (haha, get it?)
That silly issue revealed a vulnerability in the structure of that single component and I have since rewritten it to fail gracefully.
1
1
Mar 07 '23
I spent two hours wondering why my jquery wasn’t populating a drop-down only to realize I put the id in the wrong tag. I was almost ready to give up and hard code it in the Razor view
1
1
1
1
1
u/Koankey Mar 08 '23
Like spelling something differently in the JS file than you did in the index? Because that one has happened too many times to my dumbass. I'm surprised vscode doesn't catch it for me.
1
u/Tmath Mar 08 '23
Happens damn near daily. And not just with coding, spent twenty minutes troubleshooting our self-hosted got repo today before realizing my cli had a typo. And I've been doing this for a long enough time I don't wanna say the number of years.
1
1
1
u/CodeIsCompiling Mar 08 '23
Very normal - if you don't see the problem within 10 - 15 minutes start looking for a rubber duck.
1
1
u/xiipaoc Mar 08 '23
As a junior, yep. As a senior, on the other hand, you pull over someone else to look at it with you, and they spot it right away. If you're wracking your brain trying to figure out why something that obviously should be working isn't working, you screenshare to get some help debugging. It's good, by that point, to have done a lot of the things you need to try -- like the debugger, looking at API calls and request/response headers, whatever your application uses, so that whoever's helping you debug doesn't have to waste time.
1
1
1
1
1
1
1
1
1
u/Baldr_Torn Mar 08 '23
Most programmers will admit they've had those moments when they were stupid useless morons.
But some programmers will lie about it.
1
u/coalminexplorer Mar 08 '23
Try debuggers in case you are not using . With debuggers you can run code line by line , inspect all the variables and objects and conditions.
1
1
u/Perpetual_Education Mar 08 '23
If you’re staring at a block of code for hours (and we’re assuming it isn’t super deep / since you’re at Jr. level) - then it’s too long. It’s probably normal - but shouldn’t be. You should be able to ask someone for help. Using your resources efficiently is a huge part of software design.
If you’re senior enough that there’s no one else to go to for help, then maybe it’s just the way it is / but even then, you can hire some other eyes.
1
1
1
u/wirbolwabol Mar 08 '23
Wait till you start dealing with sql....I've been staring at a query(join all the things) that was part of a larger query of a total of 3 functions. Better part of a week trying to debug one issue which turns out to be three total issues...so far....
1
u/cheezballs Mar 08 '23
This is just the human experience, right? This never stops no matter how good you are, or it shouldn't anyway. If you can do it perfectly every time why do it anymore?
1
1
1
u/Blue_____777 Mar 08 '23
I think I speak for everyone when I say this is totally normal. The most obvious mistake is usually the hardest to find imo
1
u/abeassi408 Mar 08 '23
Welcome to programming. Learn by doing. Those mistakes now will teach you a ton. What you’re going through is absolutely normal.
1
u/johnothetree Mar 08 '23
7.5 years in the industry, just had that happen today. Welcome to the club!
1
1
1
u/Top_Orchid7642 Mar 08 '23
just yesterday spent a good couple of hours on a redundant [ ] which I don't even know why I put in the first place. realization came today morning in shower that it was redundant and messing up the whole array.
1
1
u/SAF1N Mar 08 '23
i used to forget linking css and spend hours trying to find out why css won't work. coding is not very human friendly so we make mistakes, it's normal.
1
u/ImMello98 Mar 08 '23
Just literally did this - was frustrated for like an hour about why a query hook in Gatsby wasnt working properly - fell down the rabbit hole thinking it was first plugin dependencies, then npm package dependencies, etc etc…
only to realize I imported something from “src/components/Module.js” vs “module.js” (Capitalized the first letter…)
1
u/Undreren Mar 08 '23
It never stops, and I can assure that we are all morons from time to time. Eventually you learn to cope with it.
Remember, we are just apes with bigger brains. Programming is an exercise in completely formal logic and reasoning.
While humans are quite capable of formal reasoning and rational think, I think the evidence shows that we as a species are not really consistently good at it.
Software is a lot like chess; the more experienced you are, the longer it takes before you have to think.
Focus on learning and develop a good intuition.
1
u/CheeseWithMe Mar 08 '23
It can happen but if you get stuck you should ask for help. Don't spend hours on it, a colleague might be able to spot in 5 minutes.
1
1
1
u/jay_thorn Mar 08 '23
Yes. Yes it is. And get used to it because even after you’ve been doing this for years, you’ll still have these moments from time to time. Develop a self-deprecating sense of humor to help deal with these moments when they happen, but don’t stress yourself out about them either.
1
u/cafari Mar 08 '23
I sometimes realize my brain is simply just tired. Sleep deprivation or mood swings or bored that day etc. Try to monitor your moods as it affects how often you get stuck. (At least for me) i try to assess my current state and if I feel tired or kind of off focus, I avoid particular tasks if possible.
1
u/madhousechild Mar 08 '23
Y'know what's even worse? Looking over code to sort out why it is working.
1
u/gamiseta Mar 08 '23
Assignment (=) vs comparison (==)
The mistake literally every single person does at least once when they're programming. Because it's a logical error, it doesn't pop up as a syntax error.
So yeah, everyone has that moment of "dude I'm so not made for this job" moment.
1
u/samsonx Mar 08 '23
You need fresh eyes sometimes. That can mean asking someone else to look at it or just waiting until the next day.
1
u/Any_Lead3 Mar 08 '23
This is absolutely normal. Any professional was once in your place, the more you practice the better you would get with the details. Keep practicing and stay persevering to make it work. Happy Coding
1
u/buritto-50-cal Mar 08 '23
That example of Einstein doing a menial job to work out a problem has never felt more relevant to me than when facing this kind of issue.
1
Mar 08 '23
Yesterday i spent 5 minutes trying to figure out why data wouldn't show on the webpage only to realize that i didnt start the backend server
1
1
u/TypicalOrca Mar 08 '23
Yep! And it's never going to end. Eventually you will just assume you're looking for some stupid shit and load it with a bunch of debug/print statements to figure it out. I've been doing this for over 20 years and I'm up at 5am trying to figure something out like this!
1
u/Classic_Associate535 Mar 08 '23
Was wondering the other day, why I couldn’t find a class im supposed to integrate into my code…. Searched for it in all modules but couldn’t find it. So I called my colleague and explained it to him. He immediately saw the issue. I just spelled the name of the class wrong 😑. That was hilarious and stupid at the same time 😅
1
u/Cyberdragon1000 Mar 08 '23
Me who put two ;; in the same line just 10 min before reading this : I'm with you on this one😂.
1
u/redmadog Mar 08 '23
It is normal for hardware programming, just to figure out hours later that your chip has hardware errors which still not on known errata list and your program is fine. Then you need to be crative and find turnarounds.
1
u/marvinshkreli Mar 08 '23
Talk to me when you accidentally push code that breaks master, then you’ll have the true junior experience
1
Mar 08 '23
I spent 40 minutes this morning staring at product schema wondering why it was trying to tell me a perfectly valid type of aggregateRating wasn’t valid.
The type was set as AggregrateRating.
The simplest problems are often the ones that take the longest to fix
1
u/reelSam2 Mar 08 '23
I often spend a few minutes looking at my code and forgetting what I was doing.
1
u/Clon003 Mar 08 '23
Yes, it’s common. And sometimes it’s ok to take a break and come back after a while.
1
1
u/exixx Mar 08 '23
I was doing exactly this last night and I've been programming for 30+ years. The blocks of code just get more complicated.
1
u/Germanball_Stuttgart Mar 08 '23
This happens often to me. Some of those problems left many weeks before I could fix them.
1
u/el_doherz Mar 08 '23
That's normal in lots of things.
E.g. I work with industrial machinery. It's not uncommon to see guys who've done 20 years with this specific kit miss things right in front of their noses.
1
u/boboguitar Mar 08 '23
Have you tried getting out a piece of paper and working through the first few iterations of your algorithm? When I was a junior, I felt like that really helped.
1
1
1
1
u/ncatter Mar 08 '23
No, that feeling is in no way resvered for junior programmers.
It is used by anyone at any skill level, if you have never had that feeling you haven't truly created anything.
It is so well known that there even is a kinda shortcut to getting through it faster called "Rubberducking", the general progression is the same however you just involve a second person, which often speeds up the process.
1
1
u/OmenTheGod Mar 08 '23
Yes thats normal as a programmer No Matter Ur Level of experience IT could and Very much probably so will happen.
1
1
u/stephan1990 Mar 08 '23
Yes, it’s normal. And the fact you figured it out is one step to becoming better at programming. Learn from your mistakes and you will develop skill eventually! Keep on learning!
1
u/uberdev Mar 08 '23
Yes. The best thing I've found is to walk away for a few hours and come back fresh.
1
1
1
u/k1v1uq Mar 08 '23
yea, take a break, go outside, get your mind busy with anything but coding, then come back and bam problem solved
1
u/WizzinWig Mar 08 '23
Its a human thing, doesn’t matter junior, senior, etc. i still do it as a senior, just maybe a little less at times. Also depends how focused or tired you are.
Try not to be hard on yourself when you see them.
1
1
u/USMCLee Mar 08 '23
I can't tell you how many times I've figured out the problem at home while drinking a beer.
1
u/usrlibshare Mar 08 '23
Oh don't worry, that's still the happy path.
Wait until you spend hours staring at a block of code asking yoursef: "Why the hell IS this working?!"
1
u/ImHeartless666 Mar 08 '23
It's normal and from my experience, taking a short break can do wonders. Or ask a fellow programmer to take a look at it.
1
118
u/dmazzoni Mar 07 '23
Yes, it's normal!
However, with experience you can reduce the time.
I think the biggest mistake I see a lot of junior programmers making is not checking their assumptions.
You added a new line of code, and you ran your program again. Now it doesn't work. You assume the problem is with that new line of code so you spend an hour studying that line of code.
Actually, it turns out the problem wasn't there. You accidentally typed an extra character at the top of the file while saving, and that was the problem all along.
How can you discover that faster?
By using version control, and testing your assumptions. Here's my exact thought process:
I believe the problem is with the line of code I just added, so if I comment it out the program should work again.
Wait, it's still broken! Now I know my assumption was wrong.
Thankfully I'm using Git, so I can do a "diff" to see what I've changed since the last time I did a "git commit".
Hmmm, I still don't see the issue, so let me stash my changes or save them in a branch called "broken" and go back to the last commit.
Hooray, the last commit worked!
Now my working assumption is that something that changed between my last commit, and the "broken" branch is the problem.
But, test that assumption. Go back to the broken branch. Is it still broken?
Yes, it's still broken. Now I'm confident the problem is in the changes on that branch.
Now I can approach this methodically. Look at every change, one line at a time. If I don't see the problem, I can still try reverting every individual change until I find the one that broke it.
It sounds tedious, but approaching it methodically like that will likely lead to finding the issue in a few minutes, rather than hours.
Oh, and notice that it's absolutely key that you use Git and commit frequently.