Top 5 Tips To Get Better At Programming
So in today’s topic, I’m going to be discussing five ways that you can get better at programming and writing code. Now, obviously there’s many more than five different ways that you can use to get better at programming and writing code. But these methods here are things that worked for me and things that allow me to write better, cleaner, more scalable, and easier to understand code, which is a really big deal.
Especially if you’re working for a company or you’re working on some type of team where other people are going to be looking at your code and your code is going to potentially live in a code base for a very long time.
Read Others Code
All right, so let’s go ahead and dive in the first way I have for you to write better code is to read other people’s code. Now, this is extremely important, especially if you’re working in some type of organization or you’re working in a team of developers on some type of code base, but reading other people’s code helps you a ton in terms of writing better code and understanding kind of different ways of going about doing things.
Speaking from personal experience here. When I worked at Microsoft as an intern, one of the ways I actually learned how to properly write code within the code base I was working with was spending a few days just going through the code base and just reading it, just trying to understand what was going on. And then every single time one of my teammates would put a pull request up.
So they would try to add some code to the repository. I would read through it thoroughly, try to understand it and try to see the way in which they were doing things so that I could kind of match that. Or on the other side of things, I could see what they were doing that I didn’t understand and kind of some counterintuitive logic that they were using. And then make sure that when I put up a pull request, I don’t fall into those same kind of floods. Now you guys will probably realize this, but whenever you read someone else’s code, the first thing you probably do is come up with a ton of criticism for it.
You say, oh, you should’ve done it this way. Oh, this is wrong. Oh, I don’t like this logic. Oh, there’s a better method. Oh, this doesn’t look very clean. That’s kind of what your mind immediately goes to because you have your own style of program. So what you can do is take all of that criticism that you’re applying to someone else’s code that or reading, and try to reapply that to yours in the perspective of someone else, reading your code to write good code, someone else has to be able to understand it. If you’re doing this in the context of some teams, some projects, some organization.
So the last thing we’ll say here, because I’m sure some of you will ask me, this is how do you actually go about reading other people’s code, especially if you’re not working for a company, if you’re not involved in some team project? Well, what you can do is go to get hub. You can read my code, you can read random repositories code. You can go look at open source code.
You can find unlimited code on the internet to go and read it just up to you, what it is that you want to read. And obviously you’re going to want to pick something that you’re somewhat familiar with so that it’s not a huge hassle to try to understand everything, but this is really important. And this will help you a ton just reading through other people’s code and understanding the way in which they have done things.
Work on Projects
All right? So the second way I have for you to get better at programming is something that I say on this channel constantly. And I apologize if you guys have heard it a ton of times and you’re getting tired of it, but this is to work on projects. Working on projects, in my opinion is probably the best way that you can get better at programming. Especially if you work on projects that you do not already know how to build.
A lot of people that work on projects will pick something that they’ve built a hundred times, they’ll go build a clone of something or they’ll build something that they’re very, very familiar with and comfortable with. What you should do is pick a project that is challenging something that’s outside of your comfort zone.
Something that you have no idea how to accomplish. And then as you work on this project, you’ll go and look things up. You’ll watch a few videos and immediately you’ll take that knowledge and actually be able to apply that into your code and see if you’re understanding it and learn a ton. The way that I got better at programming when I was young, was just picking a ton of projects that I had no idea how to do and just trying to build them now. Yeah, it took me a really long time to get through these projects.
But after, you know, the three weeks of coding this out and building a little application, I had learned a ton because I needed to learn that to work on this project. So there’s not really much more to go through on this, but working on projects is just a really, really great way to get better at programming. And if you’re not doing it, I highly recommend that you do all right.
Learn Data Structures and Algorithms
So the third way half of you to get better at programming is to understand data structures and algorithms and time complex the analysis. Now I know you guys are already upset at me. You’re going to say, well, I don’t need to know how to implement a binary search tree, or I’ve never had to write a linked list or whatever.
That’s not the reason I’m telling you to learn this. I’m not telling you to learn data structures and algorithms, because I think you’re going to go and implement these data structures and write complex sorting algorithms all the time. That’s not at all the reason behind this point. The reason behind this point is that by understanding these very fundamental computer science theoretical concepts, you are able to have some intuition on what is going on behind the scenes, in the programming language that you use.
So I’ll give you an example of what I mean here, but in programming languages, let’s go with Python. For example, you have a bunch of methods and functions that you can use that help you to speed up your development time, right? You have maybe functions, uh, like sort or search or find or count or whatever length you can go through. And you can come up with a bunch of examples. All of these functions, or these methods have some code behind them.
That’s actually performing these operations. They’re not just these magic methods that can just figure this stuff out. They actually need to do something. They have some code that makes up that method or function. And it’s helpful to know how fast that code is going to be relatively what that code is doing so that you understand if the method that you’re going to use, make sense in the context of your program
. Now I’ll give you an example here. When I was younger, I didn’t know data structures and algorithms. I didn’t know, time complexity, analysis. I didn’t know how slow or fast different methods were. And I look back at some of my code now, and I realized that a lot of times I was using all of these fancy methods and tools because, you know, I thought they were interesting and I thought they were going to make my program simpler and easier to write, but they actually made it extremely inefficient.
And I have a lot of code, even some on this channel, that’s running, you know, 200 or 300 times slower than it needs to be simply because I didn’t understand some of these very fundamental and core concepts. And if I did, I would have known that these methods were not the right thing to use in this specific situation. So really the whole point behind this point right here is that by understanding these concepts, you can understand what’s going on in these methods functions and very helpful tools in programming languages and know if they make sense to use or not.
Learn Design Patterns and Architectures
So the next way I have you to get better at programming is to learn design and architecture. Now, this is kind of, you’re getting out of the beginner stages, maybe in the intermediate, starting to get into advanced stages of programming, where you’re getting much better, the next step to really make yourself just a good programmer is to learn about design patterns and architecture. And what I mean by that is thinking about a system like a program, a system, whatever, as a whole, rather than just thinking about it on the individual parts.
A lot of times when you start writing code, you write very small programs, right? Maybe something that’s 50 lines, a hundred lines of code, maybe even something that’s a thousand lines of code that would still be considered a small program. And in those programs, it doesn’t really matter the way that you do things.
A lot of times, it’s totally fine to kind of go with, you know, like a half-ass way or to not really organize your code very well or to not structure things. Super importantly, you can kind of go in and tweak things if they’re wrong and it’s not a big deal, but as soon as you get into a very large code base, you know, you’re talking tens of thousands of lines of code. You really need to understand the way in which these different pieces of code are going to work together.
And the way that you’re going to structure your program, such that you’re not going to have to go back and rewrite 10,000 lines of code such that your program or your system is going to scale. If you have more users, you need to add something to it. And so this is kind of like, as you’re getting better at programming, you need to learn these things so that you can actually work on large systems and get out of the very hobby projects and realize how to work on yeah, just large systems and real code that you’re actually going to see in a production environment.
So there’s not really much more I can discuss there learning these things is not super simple. There’s not a ton of great resources online for them, although I am planning on potentially making some in the future, but it is just really important to understand how to kind of design a system. Now, even something simple, like UML diagrams, class diagrams, system diagrams, et cetera. Those are things that you probably want to know, and that are very, very helpful to learn.
Write Simple Code
All right. So I’m going to share with you my last way to get better at programming, but before I do that, I’m going to share with you kind of a quote line sentence, wherever you want to call it, that really helps kind of emphasize this point and will help you remember it.
Now I’m definitely misquoting this from someone. So if you know the original statement or quote, please do let me know, but it goes something along the lines of the simplest things are the most difficult to come up with or to create now at first glance or first thought, that seems contradicted. You think of that.