Home
Categories
EXPLORE
True Crime
Comedy
Society & Culture
Business
Sports
Technology
History
About Us
Contact Us
Copyright
© 2024 PodJoint
Podjoint Logo
US
00:00 / 00:00
Sign in

or

Don't have an account?
Sign up
Forgot password
https://is1-ssl.mzstatic.com/image/thumb/Podcasts125/v4/f3/de/0e/f3de0ec1-a1ff-ad7e-1d42-2ee41cae7253/mza_7142444209140500111.png/600x600bb.jpg
3 Minutes with Kent
Kent C. Dodds
235 episodes
8 months ago
👋 Hi there! I'm Kent C. Dodds (https://twitter.com/kentcdodds). This is a (week)daily podcast where I give 3 minute thoughts about web development. You can subscribe on iTunes here: http://kcd.im/3-mins-itunes and on RSS here: http://kcd.im/3-mins-rss
Show more...
Technology
RSS
All content for 3 Minutes with Kent is the property of Kent C. Dodds and is served directly from their servers with no modification, redirects, or rehosting. The podcast is not affiliated with or endorsed by Podjoint in any way.
👋 Hi there! I'm Kent C. Dodds (https://twitter.com/kentcdodds). This is a (week)daily podcast where I give 3 minute thoughts about web development. You can subscribe on iTunes here: http://kcd.im/3-mins-itunes and on RSS here: http://kcd.im/3-mins-rss
Show more...
Technology
https://briefs-production.s3.amazonaws.com/cover_art/34/Drawing__1_.png
Keep related utilities in a single file
3 Minutes with Kent
2 minutes 52 seconds
4 years ago
Keep related utilities in a single file
Hello there friends, so I was thinking this morning about utilities and you know these little utility functions that we write and we put it in like a utils modular or something and sometimes when we're running these we want to split things out to make it just.Easier to manage or something and and it's just kind of a natural thing at least for me to want to split things out into individual files, so each utility is in its own file, you know, if it's just a single line or something. I typically just keep it on one but if it's kind of complicated or maybe there are group of utilities that make a lot of sense together. I just feel naturally inclined to move those into a separate file. But what I've found is in my experience is that you're often better off just leaving utilities all in the same file and thenMaybe using code comments or something to separate different parts of that file because what what I found happens over and over again is one utility depends on another and that utility depends on this other utility which depends on the first one and so you have like a cyclic dependency or cyclical dependency sort of thing and so when you try to start pulling things out into different utility or into different files, now you have to extract the other files. Or other utilities into separate files as well ultimately leading to basically a lot of files that have just a couple lines of utilities. And I definitely don't see that as being any simpler. And in fact, it can be even more complex when you start adding type script and now you have types that you need to extract it to different files so you can use them together. So, but there is a reason that we like to keep our files shorter and that's because when when you have a really big utility that can be really complicated. I,Worked on a a backbone view that was like 3,000 lines long once and it was not fun and I did not like having such a big file, but I've been thinking about this and I think that the problem isn't necessarily the size of the file the problem is the size of the the individual component. And so and just the number of concerns it was mixing. That was what made it really difficult. And so yeah, the the length of the file that doesn't really matter all that much. It's the number of mixed concerns that makes things really difficult. So, I would encourage you to. Think twice before extracting utility files or your utility functions into individual files and maybe first try to organize that file a little bit to make it easier to manage. I hope that's helpful and interesting have a nice day.
3 Minutes with Kent
👋 Hi there! I'm Kent C. Dodds (https://twitter.com/kentcdodds). This is a (week)daily podcast where I give 3 minute thoughts about web development. You can subscribe on iTunes here: http://kcd.im/3-mins-itunes and on RSS here: http://kcd.im/3-mins-rss