Lines of code !== Complexity - a podcast by Kent C. Dodds

from 2021-02-15T22:56:55

:: ::

https://twitter.com/DavidKPiano/status/1361353521648590853?s=19
What up folks Happy President's Day for those in the US I wanted to talk
about this tweet that I saw from David K. Piano that's his Twitter handle
his last name is Korshid and the tweet is can we stop with the myth thatmore code means more complexity? Sometimes less code means more edge
casings ignored which means willfully and dangerously ignoring complexitynot reducing it.
And he gives some a sample of some simple code that just awaits fetch fromAPI and then returns the data and it's saying here are some of the
ignored.Complexity error handling data validation timeout handlingcancellation interruption, etc. I super duper agree with David here and Ivery often will have people ask me about the complexity of some code
because there's a lot of it.
And the code that they're talking about is maybe some class name for
tailwind, you know, a tailwind has tons of class names or maybe they're
talking about inline styles with the CSS prop or sorry CSS and JS or likemaybe they're talking about.JSX and this component just has like 200 lines
of JSX or something.Whatever the case may be the number of lines of code is maybe correlated
but not necessarily correlated even with the amount of complexity. Youcould have a list of all the countries in the United States. And now that
would be that would be represented by a lot of lines of code.Sorry, did I say all the countries? I meant, like all the cities in the
United States. That would be a lot of code but it would not be complex.Atall. So the there's a very subtle if any relationship between the amount of
code and the complexity thereof and I think that it's an important thing to
to keep in mind.So just because there's a lot of code doesn't mean that this is going to be
a maintainability nightmare or it's going to be complex. I actually find
that prematurely abstracting some of that stuff because you think it's
complex can make things even more complex, for example, if you have a Idon't know some like tons of.
TSS or something like that CSS like class names or something you try toabstract that away with some fancy higher order component or something then
that would be even worse. Or if you like have a bunch of JSX and then youwind up trying to like extract these into little components then now you
have to worry about passing props and everything and that just increasesthe complexity.
Now, I'm not saying that's always the case but just keep that in mind.
There's not necessarily relationship between the amount of code and how
complex that code is. I hope that's helpful. I have an awesome day. Goodbye.

Further episodes of 3 Minutes with Kent

Further podcasts by Kent C. Dodds

Website of Kent C. Dodds