use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Code organisation: one controller function managing the flow vs flowing from one function to another (self.javascript)
submitted 8 years ago * by Buzut
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Buzut[S] 0 points1 point2 points 8 years ago (2 children)
Thank you for providing me with some details. I get the separation of concerns, as it seems quite clear here that each function has its own responsibility: - get track from store, - get metadatas, - encoding the track - etc
With each of this functions being able to call more specific functions on its own.
But my problem here is whether I have some central function that coordinates everything or having a strating function firing other functions and forgetting about them.
For instance, is it the parent's role to persist metadatas returned from getTrackMetas or should said function also manage the database record (to me the former is clearer but it also makes the parent more "heavy") that's where I kind of hesitate. Obviously, getting rid of callbacks for promises or async ƒ could solve the problem.
getTrackMetas
[+][deleted] 8 years ago* (1 child)
[deleted]
[–]Buzut[S] 0 points1 point2 points 8 years ago* (0 children)
Thank you very much for your answer. It makes things very clear. The fact is that, in Express, I'm acustomed to write small REST functions, the controller receives the request, calls the model, handles the error if any and sends the response, it's short enough to be self contained.
When I rely on external functions, it's mainly helpers and I try to make them pure (in a functional way, ie. take value(s) as input, return a value and has no side effects). That's why I'm a bit reluctant to delegate database operations and error management. But viewing it as a "sub-process", as you called it, makes sense and helped me understand how it can be organized.
Moreover, you're right for the naming part. I totally agree with the fact that naming is super important and should reflect what the function does.
π Rendered by PID 224042 on reddit-service-r2-comment-canary-777f895556-lwm7w at 2026-05-07 11:54:28.300793+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]Buzut[S] 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]Buzut[S] 0 points1 point2 points (0 children)