Throwback to DevTalks Romania @Phil Nash - The top 5 JavaScript issues in all our codebases - DevTalks Romania

Throwback to DevTalks Romania @Phil Nash - The top 5 JavaScript issues in all our codebases

DevTalks Romania @Phil Nash - The top 5 JavaScript issues in all our codebases

Phil Nash is from Melbourne, Australia and works as a Google Developer Expert and developer advocate for Sonar. He enjoys using Ruby or JavaScript to create web tools and applications for developers. Phil was our guest speaker at DevTalks Romania 2023 talking on Main Stage about “The top 5 JavaScript issues in all our codebases”.


Here is a sneak peek down below from his session, but also check you can the entire speech right here.

Common JavaScript issues and how to avoid them.

Top five issues. Let's start at number five, we'll start at the bottom. And the top five issue that turns up in JavaScript projects 1000s and 1000s of them is that unused assignments should be removed. This seems like quite a simple one unused assignment. That is the idea of running some code like this in which you assign some sort of result to a variable. And then without using that, assign something else to it.

In this case, we've signed the result of adding bar and bounds to foo and then straight away, we assign the result to other function to it as well. If we do this, then that first line is completely useless, and doesn't need to be in our program. When I'm talking about clean code, I'm talking about the maintainability of this, what I mean is, if we have code that we're running, and that's in our code bases in our functions, that doesn't actually do anything, it just gets in the way, it makes it harder to understand what the program's actually doing.

Software development best practices.

There is one thing to consider with this, when you're summing prime numbers that are underneath a number, it is more complex than just returning a string based on a number that's passed in. There is inherent complexity in some of the things we do. But what we try to avoid is accidental complexity, adding complexity to a function simply by kind of writing it badly, or writing to longer function, just spending time. Yeah, adding more stuff to it to make it harder to understand.

Avoiding that accidental complexity is something we should be aiming for. The score the actual thing in our top five there, the actual problem is that cognitive complexity of functions should not be too high, to too high in plays a threshold. And the threshold we apply to this is 15. So, both are examples. So far, scoring, eight and one are fine under this threshold.

For more tech content, don’t forget to save your seat for DevTalks Romania 2024 and get your tickets here: https://www.devtalks.ro/tickets

DevTalks 2024 Powered by Main sponsor