5 Nooby Coding Mistakes You NEED To Avoid

preview_player
Показать описание

In this video, I will be showing you the 5 most common programming mistakes that I've seen made literally every single day. Every programmer has made these same mistakes at point in their programming journey and this video is going to help you fix them very quickly and ensure that you don't write code like this.

⏳ Timestamps ⏳
00:00 | Mistake 1
02:52 | Mistake 2
06:40 | Mistake 3
10:37 | Mistake 4
14:20 | Mistake 5

Hashtags
#coding #mistakes #programming
Рекомендации по теме
Комментарии
Автор

1. Simplify longer conditions into one variable.
2. Simplify nesting by reversing the direction of the condition.
3. Avoid ladder statements (several if-else) by:
a) Creating a dictionary. Map the different values via key-value pairs.
b) Alternatively, create an array and each value in the array corresponds to an index.

4. The Mega function. Split it up into logical smaller units of code
5. Remember to check for Edge Cases. Check for all possible things that can go wrong
a) Raise custom errors that tells the user exactly what exactly went wrong and how to fix it.

InfoSecGSO
Автор

6:40 An alternative that you can leverage: match and case. It generates a look up table during run-time so it matches instead of checks.

RileyMeta
Автор

As in a conversation I had with a manager of some years ago said:

Supervisor. "I'm not going to tell you how to do it..."
Managed. "Yeah, but you'll be the first to let me know if I'm doing it wrong."

We worked well together....

vcv
Автор

It's nice to see these coding advices/tutorials again. Got a bit more used to that content format rather than to the "How to become ____" videos through all the years I've been learning from your channel.

pycat
Автор

Thanks, Tim for the advice... as always... you are my hero!

balloney
Автор

Great straightforward content
I always learn something
Thanks Tim!

andreadelcortona
Автор

While the first example fix is fine for a general case, it has a different problem. It uses an if statement to just return true/false. In this simple case, just return the boolean expression.

johnbennett
Автор

Hi Tim, I just found this interesting new topic of research on Machine Learning talking about how the new way of doing it in the future might likely be with liquid neural networks rather than static traditional ones. There were things like energy efficiency and learning new information during run-time (like how the human brain's neuroplasticity enables it to adjust to changes on the fly) that are supposed to make it mimic the human brain way more than traditional networks. So I thought you might be interested in this topic and potentially make a video about it if you think the topic's worth exploring! Also, love your videos :)

Sadeem-oy
Автор

this guys really make me wanna keep learning no matter how unmotivated I am, thanks a lot Tim!

Ko_Choso
Автор

Best practices is what I need, how the syntax works is what the docs are for, this video here is added value to go pro.

StuartLoria
Автор

Tim, I love your approach in solving problem. Separating different components of program into functions. I gained alot with this your approach in one of your content. "Learn Python with one Project" ❤

alimihakeem
Автор

Thank you for your tips Tim! They are all so useful in daily life 💪

kapibara
Автор

Hey Tim can you do a video discussing Devops roadmap

JosphatKangethe-ypmh
Автор

I would argue that the following code is a much better solution for Mistake #2. It showcases the use of the *range* function, the *filter* function, and *lambda* functions.

def process_numbers(numbers):
# store range once instead of repeatedly
# recreating it while iterating over list
proper_range = range(2, 100, 2);
return filter(lambda n: n in proper_range, numbers);

However, if the range is large, for example between 2 and then we would want to avoid storing such a large list in memory, and instead manually apply the evenness and range checks, as shown in the code below.

def process_numbers(numbers):
return filter(lambda n: n % 2 == 0 && 0 < n < numbers);

Additionally, we could use *inner functions* to make the code perhaps even more readable, as shown below.

def process_numbers(numbers):
def is_even(num):
return num % 2 == 0;
def is_within_range(num):
return 0 < num <
return filter(lambda n: is_even(n) && is_within_range(n), numbers);

johnanderson
Автор

In #5 you don’t need to check if the length is 0. Just put “if numbers:”

TN-cxqi
Автор

YES, it looks clean. But naming variables and functions is hard :D

willyhorizont
Автор

Good solution for the second example. But if you don't care about performance, there can be short clear alternatives. In this case using "if number in range(2, 100, 2):" is much clearer. Just make sure you never do this in code that might be called a lot.

johnbennett
Автор

In 4-fixed file, should we write necessary functions for process in a separate file, and then import into the main file?Is it a conventional way to write code like this?I am beginner to this ?Really appreciate and love your work bro ❤

HtunWinSoe-hw
Автор

In the first mistake, you can also use all() Python function. It tests if all conditions (inside an iterable) are true. Else, return false

nasccped
Автор

I have seen some really bad code in my professional career

Even comments that say
We now call our recursive private constructor
Neeto “gag”

It was creating a n-ary tree from a list

dfields