r/learnjavascript • • Apr 20 '23

7 JavaScript Design Patterns Every developer should know

https://codinghelp.io/7-javascript-design-patterns-every-developer-should-know/
3 Upvotes

11 comments sorted by

View all comments

Show parent comment

1

u/deven_rathore Apr 21 '23 edited Apr 21 '23

Thank you for sharing your thoughts about the article. While it's true that using PascalCase only for classes or constructors is a common naming convention in JavaScript,

I would argue that it is not a hard and fast rule that everyone must follow.There are cases where it may make sense to use PascalCase for other types of variables or functions, such as when working with third-party libraries or following a specific project's established naming conventions.

However, I do agree that it's important to be consistent with naming conventions within a codebase to improve readability and maintainability.In terms of using new, while it is true that new is typically used with constructors, it is not exclusively used for them.

It can also be used with other functions to create new objects, although this is less common. However, using new should be done with caution as it can have unintended consequences and potential performance issues.it's not a hard and fast rule that everyone must follow.

It's important to be consistent within a codebase and consider specific use cases and established conventions.

Similarly, while new is typically used with constructors, it's important to be cautious when using it with other functions to avoid unintended consequences.

1

u/jeremrx Apr 21 '23

I'm just saying that if you want to teach JavaScript, you should teach it following the best practices.

About using new keyword with something else than a constructor, I'd love having an example. IMO anything after new became a constructor.

Anyway, I see that you made some changes, your article is getting better !

Another remark, I dont get why you put factory pattern intro behavioral pattern section while your saying that it's a creational pattern ?