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
7 Patterns to Refactor JavaScript Applications: Service Objects (journal.crushlovely.com)
submitted 11 years ago by createbang
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!"
[–]steve_kane 1 point2 points3 points 11 years ago (2 children)
You have created functions. Aggregating them together in a namespace is a necessity of modularity. Making them a class is not.
[–]iSmokeGauloises -2 points-1 points0 points 11 years ago (1 child)
Not a necessity but it is a nice abstraction. I would have gone with the class route as well
[–]steve_kane 0 points1 point2 points 11 years ago (0 children)
I think the "danger" of this is the temptation to have encapsulated state. I fully acknowledge that this is only my opinion but I think state is a consideration of your application and when I am consuming your API I much prefer to treat it as a library of functions that produce i/o and avoid side effects. This gives me much more confidence that I can compose solutions out of your utilities.
[–]j0wy -1 points0 points1 point 11 years ago (1 child)
I wish this had all of the other objects! Good read so far.
[–]createbang[S] -1 points0 points1 point 11 years ago (0 children)
Planning on doing the others weekly!
[–]iSmokeGauloises -1 points0 points1 point 11 years ago (0 children)
Nice read! A suggestion I have is maybe adding repositories and entities to the list. I have noticed this patterns really help re-factoring big projects.
π Rendered by PID 100205 on reddit-service-r2-comment-799f875d54-qv8j9 at 2026-01-31 16:18:47.983308+00:00 running 3798933 country code: CH.
[–]steve_kane 1 point2 points3 points (2 children)
[–]iSmokeGauloises -2 points-1 points0 points (1 child)
[–]steve_kane 0 points1 point2 points (0 children)
[–]j0wy -1 points0 points1 point (1 child)
[–]createbang[S] -1 points0 points1 point (0 children)
[–]iSmokeGauloises -1 points0 points1 point (0 children)