My senior coworker rejects my code on the basis of not being optimal

Posted by Justkeepitanonymous@reddit | learnprogramming | View on Reddit | 108 comments

So I finally got a job as a junior after ling searching and a couple years of learning programming alone in my spare time with little guidance besides online tutorials. I am new at this and of course the code I write is far from being optimal, I know that. I also know that it takes time and practice to get good and you can only get so far with online tutorials. Real practice is what I need and I am aware of it. But I do get dishearted when after I work hard on a task given to me by my senior he just rejects it outright because it works slower than it could be programmed to work. Like, I used an approach resulting in let’s say O of n squared where he knows that it can be done in O of n logn. I know he’s right, I know I can do better, but it is very demotivating to get rejected outright. I wish he’d take a look at my code with me and show me where and what I can optimize. Not just reject me. I’m scared to tell him though. Did you get the rejection from senior coworkers when you were a junior or were they more flexible towards you and your abilities?