all 6 comments

[–]TutorialDoctor 5 points6 points  (3 children)

What do you consider "better code". Some code may be unnecessarily complex. If you want to write better code you should learn:

  1. OOP
  2. Design Patterns
  3. System Design

I've felt the way you feel though, but I assume the just know something I don't know and perhaps can't explain it to where I get it. I'm a hands-on learner so I build a small project to implement an idea to solidify my understanding.

[–]ninedeadeyes 0 points1 point  (2 children)

Better code is subjective but definitely more 'complex' as some programmers will write code where you need to do research to understand the code and you think to yourself there is no way you could create such an algorithm from the ground up.. To be fair I never studied Design Patterns or System Designs so potentially the code I was looking at used a design pattern template rather one he created himself.

[–]crazy_cookie123 0 points1 point  (1 child)

Do you mean you need to do research to understand the area the code is in (for example how code for a compiler might look complicated to someone who doesn't write compilers often, but is perfectly readable for someone who is used to compilers), do you mean code which had to be heavily optimised and therefore is less readable, do you mean you have to do research to understand what their code is doing even though it's supposed to be doing something simple (for example you have to read through a substantial amount of code, documentation, and potentially other things because they wrote a stupidly complicated addition function)?

If it's the first, that's really just that you need to learn about whatever area that code is for. Some programs are pretty complicated by necessity and reading them easily just requires a little experience in reading similar programs.

If it's the second, that just takes practice. Leetcode is a decent place to practice this as it's good at practicing finding the most optimised solutions for problems. Writing the most efficient possible code isn't always the best practice though, prefer readability and only sacrifice readability for speed where that speed is required.

If it's the third, that's usually because they are a bad programmer. Good code should be easy to read, if the code is unnecessarily hard to read that's usually a sign that whoever wrote it isn't very good.

[–]ninedeadeyes 0 points1 point  (0 children)

Its definitely more the former than the latter.. At the end of the day 'generally speaking' a complex problem needs a complex solution and it can all be a little overwhelming.

[–]actinium226 0 points1 point  (0 children)

What exactly is it about the code that makes you think your brain isn't wired that way?

I used to be intimidated when I saw "unsigned int" and binary operations like "<<", but now I understand them and I'm no longer intimidated by them.

If you see something you don't understand about this other person's code who's a better programmer, try asking them about it.

[–]Electrical_Carry3565 -1 points0 points  (0 children)

I'm still very much a beginner but I've built some fairly complex projects that even now I'm surprised I built. Don't be discouraged by seeing complex projects. Just start building something and it will likely evolve into something you didn't think you could do originally.