-
Notifications
You must be signed in to change notification settings - Fork 15.7k
Factory Functions: Lesson tidyup and content clarifications #30071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Some code blocks split to be easier to follow than trying to follow large comments
Style is more consistent with the rest of the curriculum as well.
Heading added as now required by style guide. Rephrased to link general concept of modules with the current lesson section.
Addresses common confusion with "why not just call the factory function once and omit the IIFE?"
Common confusion that IIFEs are a special construct and not just a func exp called immediately (due to immediate focus on the module pattern). The module pattern doesn't have to be used with factory functions only, just it's one of the more useful use cases.
javascript/organizing_your_javascript_code/factory_functions_and_module_pattern.md
Show resolved
Hide resolved
JustWaveThings
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I'll have a little deeper think about this section and repurpose this PR as more content clarification with a side of tidyup, rather than the reverse.
That sounds like a solid plan. I think your example code above is an improvement as well. Thanks for doing this Mao.
|
I don't have a huge amount of time right now but plan to rework the currying/closure section (as discussed above) in a separate PR in the next few days, or after this PR gets merged. |
javascript/organizing_your_javascript_code/factory_functions_and_module_pattern.md
Outdated
Show resolved
Hide resolved
Design pattern not the main focus here and singleton stuff isn't expanded on in this lesson. Avoid a terminology-based rabbit hole.
Because
Due to some inconsistencies with code style and usage of comments, some learners miss some things or get confused in the lesson flow when some parts are in normal text and some parts are in longer comments.
There has also been common confusion regarding the point of IIFEs or what IIFEs actually are (perhaps due to focusing immediately on a practical use of IIFEs without giving a more plain example of what an IIFE really just is - people sometimes overthink it's some special specific construct).
This PR
Issue
Closes #29212
Pull Request Requirements
location of change: brief description of changeformat, e.g.Intro to HTML and CSS lesson: Fix link textBecausesection summarizes the reason for this PRThis PRsection has a bullet point list describing the changes in this PRIssuesection