this post was submitted on 20 Aug 2023
4 points (100.0% liked)
Transprogrammer
835 readers
1 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
Compartmentalize things so they all handle one thing individually and then you call those things from a main class is generally the way you’d do it.
Splitting things up will make your classes specific to a certain functionality and allow you to keep track of everything without individual files being thousands of lines, though sometimes they will end up that way anyway to achieve a single piece of functionality.
So for example you might have a service to call the api to get data, a service that exclusively posts to mastodon, etc.
You can write 500 lines of code to do something in your service and hide it away but then just call it like petInfoService.getPetInfo() from your main class and when you look at the flow it’ll make a lot more sense.
Any reason you chose typescript out of curiosity? Nothing wrong with it, just curious.
Feel free to post code if you need help. Just make sure whatever you’re posting or uploading to git doesn’t include any API keys.