Skip to content

Factory Functions: Suggested style tidy-up and phrasing tweaks #29212

@mao-sz

Description

@mao-sz

Checks

Describe your suggestion

The factory function lesson is a great lesson but understandably tricky given the wealth of info to be taught.

Recently I've noticed a few questions where confusion stems from not quite following or even missing some comments, or otherwise questions about why the lesson's code style differs from other lessons (in case that is a signficant factor).

I think the following tweaks can help streamline the lesson a little:

  • Reposition some comments to be above the code they directly refer to rather than below
  • Split some code blocks so that some "bare" comments become normal lesson text, aiding in visibility and separating examples addressing separate concepts/steps.
  • Adjust code style to be a little more consistent with previous lessons (e.g. using a function declaration for constructor rather than traditional func exp assigned to variable).
  • Expand very slightly on opening paragraph for the section on IIFEs to help answer the question "well why can't we just write a normal factory function then call it once instead of wrapping it in an IIFE?"

Path

Ruby / Rails, Node / JS

Lesson Url

https://www.theodinproject.com/lessons/node-path-javascript-factory-functions-and-the-module-pattern

(Optional) Discord Name

No response

(Optional) Additional Comments

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions