this post was submitted on 20 Aug 2023
4 points (100.0% liked)
Transprogrammer
983 readers
6 users here now
A space for trans people who code
Matrix Space:
- #transprog:socki.moe
Rules:
- Don't be a meanie
- no *ism
- consider the feelings of somebody who might read what you say
- Don't shitpost
- Keep it wholesome
- Must be trans / programming related
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
In general there's a balance to be struck between too few files and too many depending on the complexity of your code, but I can think of a few reasons you might want things to be split out for this project. One example would be to split initializing the mastodon client to its own file, then when you're reading code that uses the client you don't have to think about how the client was initialized.
You're right that it can be confusing when tightly coupled code is split between a bunch of files; to use your example it'd probably be cleaner to write petgrabber.ts as an independent function that returns a result, then have a 'post to mastodon' function that takes generic arguments, and call them both from the main file, taking the results from the petgrabber function, formatting them and passing them to your post to mastodon function.