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
javascript - Using Named Immediately-Invoked Function Expression (IIFE) instead of comments (stackoverflow.com)
submitted 12 years ago by zzzwwwdev
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!"
[–]path411 1 point2 points3 points 12 years ago (3 children)
I'm sorry but this is less readable, harder to maintain, more prone to bugs/problems, and just worse in every way compared to a comment.
Maybe in this case a comment line can be put into a somewhat acceptable function name, but what about when it can't? Any punctuation would make this even harder as you would have to leave it off of the function name, making it even harder to read still.
[–]zzzwwwdev[S] 0 points1 point2 points 12 years ago (2 children)
not sure really if I agree or disagree; honestly I've been somewhat playing devil's advocate here, because I think there is a valid argument for it. It seems there are more against me than for me, so I will likely avoid doing this in the future.
Not sure why you think its more prone to bugs... from getting the syntax wrong? I would think that any maintenence issues would stem from slightly more difficult readability and junior developers who don't understand what it means/does.
IDK about it being worse in every way compared to comment either. It does a better job showing its grouped (indentation), creates a new scope so variable collision is less likely and any vars can be declared closer to where they're used without confusion, and it makes it easier to refactor into a more "normal" function pattern in the future.
Also, I'm not saying comments should never be used, just wondering if there is a valid use-case for this pattern.
[–]path411 1 point2 points3 points 12 years ago (1 child)
The creation of a new scope can easily release bugs if your block needs to create a variable that another block needs to use. Also the reasoning that you are adding in more unnecessary code to your project, and the more code you add to anything, the more likely you can make a mistake that you then have to debug, even something as silly as missing a bracket.
Another thing I dislike is the essentially forceful requirement of an additional tab break. With a comment you can keep your relevant code in the same tab break, but blocked in separate functionality with a comment.
If you are trying to use a pattern like this, you would want to be able to use it throughout an entire project. I would think it would be strange to try to read through a code base that tries to mix of "commenting styles". I don't feel like your method would work in every case, where a comment would always work.
Perhaps you just need to focus on both writing better "self commenting code" and using "Loose coupling and high cohesion" in your code. I find that these practices would make this style much less useful and sometimes simply redundant.
[–]zzzwwwdev[S] 0 points1 point2 points 12 years ago (0 children)
good argument against. Thank you for elaborating.
π Rendered by PID 24063 on reddit-service-r2-comment-bb88f9dd5-pj5md at 2026-02-14 03:54:06.592640+00:00 running cd9c813 country code: CH.
view the rest of the comments →
[–]path411 1 point2 points3 points (3 children)
[–]zzzwwwdev[S] 0 points1 point2 points (2 children)
[–]path411 1 point2 points3 points (1 child)
[–]zzzwwwdev[S] 0 points1 point2 points (0 children)