10 Newbie Programming Mistakes

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right so I assembled a list of 10 new mistakes that I see beginner programmers make all the time so we're gonna jump right into the list I'm gonna give you some things that you can remedy to fix what you're doing so tip number one or mistake number one is putting everything into a single file and it becomes giant so this is something that I actually recently did when I was learning flutter this past week I was doing that and I put everything into a single widget it's an easy mistake to do because it's kind of nice at the start of something to put everything in just a single file or a single function but it does not scale well at all and it doesn't work as your project grows so if you see that all over the place giant files it's a good idea to start splitting things up into smaller sections now of course this is not the there are some exceptions where you may want to have a larger function somewhere but in general you don't want to have just large files everywhere all right so number two problem is manually formatting code so I see people just going around and tabbing left and right trying to get things lined up and it's a total waste of time you should be using the auto formatter built into your IDE and just avoid the whole time-consuming process of making sure you have 4 spaces and python or whatever programming language you're using mistake number three is logging too much output this is specifically usually when you're debugging and I see someone trying to find the bug in their code and they just put in like a hundred print statements and then when they run their code they just get this massive log statement that they're now sifting through the logs trying to figure out what happens instead what you want to be doing is put a precise print statements and specific places that are meaningful when the value of this variable matters to the output and such like that where you're being specific about a small number of print statements compared to just putting a hundred everywhere all right mistake number four is not reading error messages so a lot of times the error or what you need to do is in the error message but you don't read the error message at all I see this all the time I even do it sometimes where I get an error and I before I even read the error message I'm going either back to my code or just copy and pasting the air into Google instead of actually just reading the air for being like oh yeah I know how to fix that I can just do what the air message says to fix it so this is an easy one where it's just like a gut reflex ups on air I'm gonna go change my code wait a second read the error message it usually has something what you should be doing all right number five is copying pasting code that you have no idea how it works this is something that gets really bad if you keep doing this in multiple places because what I notice is you just have a little bit of baggage every time you copy paste code there might be chunks of it that you don't understand and aren't needed when you use that code in other places and now you just have unused code that's running for really no reason and it's just cluttering everything so make sure you understand the code before your copy and pasting it and if you're gonna take a piece of code and put it in another place feel free to clean out some of the parts that you don't need before doing that all right tip number six is not using or the mistake number six is not using the right data structure so I commonly see this really not with people just not using dictionaries or hashmaps that's the most common one I see is where instead of using a map they are using lists and so they're looping over to lists which is not very efficient and it's just it's slow you should be using a better data structure to be doing that operation and so if you don't know what dictionaries or hash maps or how they work highly recommend learning them because a lot of times the answer is to use them especially if you're the common case I see is you loop through a list and you want to see if an item is in the list and so you loop through the list and you just have nested loops and it gets really slow instead of doing that put everything into a map and then look it up and oh of one time it's way better to do that so in general look for the right data structure if it's awkward with what you're doing you probably can find something that is better format for your data alright mistake number seven is using multiple if statements instead of doing if-else statements so if you just have if after if after if in each if statement only one of them should really be true then you should be putting them in if else's and making sure it just flows like that it's easier to read as other people read your code and also it doesn't make sense to do multiple condition checks if the first one is true the second one you know is going to be false and so on alright mistake number eight is doing too much pre-processing basically what happens is at the top of a function or a file or something you basically just compute all your variables and then you have if statements that maybe you be conditionally running stuff and because you did all the processing up front some of the variables may not be used in your computing stuff you really don't need so look at how you're doing things look at your flow of logic and if you're not using a variable until a low part of an if statement don't compute it at the very top of the file way to a further down point basically be lazy about generating the data or computing values only compute it when you need it now of course there are some exceptions to that but in general you don't want to just compute everything at the beginning the next one is large unorganized commits I sometimes do this myself and it is quite bad so it's it's something that lazy programmers and new programmers do where basically you're fitting way too much stuff that is not related to each other into a single commit you're waiting too long to commit things and then you have part a of your code being committed with Part B of your code and they have nothing to do with each other you should be splitting these things up into two commits or in smaller commits so make sure you do small commits that are atomic just what you change and it gives you better air or commit messages that are nice and short too this is specifically important when you need to reset or go back and change it commit or you don't need to commit anymore it's very easy to just get rid of the last commit when it's small it's harder to go back and just get rid of half of the commits because you committed to things that are not related to each other and you only need half of it or something like that alright the last mistake that I see is putting secrets or artifacts and to get or on github pushing it up to github this can be anything that you really don't need and get stored there the most common thing I see in JavaScript is putting and node modules on github or in your git and then also putting like API keys and so none of those things that you want the the way to remedy this is you should be using environment variables go Google those if you don't know what they are you should be using those for all your API keys and all your secrets and then also for say node modules you should be creating a dot get ignore and make sure you have all the things that you don't care diversion out of git so those are two important things all right so those are the ten things that you should avoid as a programmer ask yourself if you're doing any of these things I commonly find myself doing some of these things and you just want to make sure you go back and fix some of them as you do them
Info
Channel: Ben Awad
Views: 281,040
Rating: 4.9038463 out of 5
Keywords: Newbie, Programming Mistakes, 10 Newbie Programming Mistakes
Id: oAtazW3rIUg
Channel Id: undefined
Length: 7min 18sec (438 seconds)
Published: Sun Mar 31 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.