In the first part, we explored the significance of the Strategy pattern in React projects and outlined its implementation. However, the approach pr...
For further actions, you may consider blocking this person and/or reporting abuse
@itswillt
About the conversion ...
We should go from application, not from the implementation.
Application needs the following:
Why do we need a recursion, when logorithms work well??
TS Playground
It seems strange ...
Hi, thanks for carefully reading through the article and having great feedback!
It's obvious that the logarithm solution works better. However, it's not the point of this article. Like I mentioned in the article, the recursion solution is a straightforward and intuitive one. Even a person without much knowledge about Mathematics can make it out with pure reason and logic. But again, algorithms or performance optimization are not what I want to focus on.
Thanks again for going over the article and showcasing the optimal algorithm. I never thought of using actual Math knowledge for it.
@itswillt
Firstly, I want to say that trying to write this article is a great effort.
It helps the community and the author's growth, so kudos to you.
However, it's tough to figure out the article's main point, unfortunately.
Let's talk about the title: "Applying Strategy Pattern in React" If we
switch "React" with "Angular" in your examples, does the article
mean something new?
Take the example classes like PricingStrategy; they stay exactly the same.
Even though the Pricing Cards scenario is related to the Strategy pattern,
as I mentioned in a comment on the first part of your article, this approach
might cause problems when trying to localize a site.
Two other cases: they are not about React, and they are not about the
Strategy pattern. The Strategy pattern is one way to satisfy the Open/Closed
principle, but instead of that, we end up with code close to extension without
modification.
So, if we want to illustrate how the Strategy pattern works in React, let's
concentrate on React itself. The Strategy in React has a well-known
incarnation: render/component props.
In your Pricing Card scenario, it could be a discount component that is
injected into the Pricing Card to introduce new functionality. For example,
it could prompt the user to choose how they want to receive bonuses:
In various regions or during A/B testing, this could be implemented in
different ways: using a select menu, radio buttons, buttons with links, etc.
If we want to discuss Strategy in specific domains, such as e-commerce
logic, unit conversion, or even CSS styling, let's focus on that. We can
use React to implement IO in the application, but it is clear that we should
not be talking about "Strategy in React."
So, I'd like to suggest to you -- separate concerns.
Cám ơn anh rất nhiều <3
Wait, you’re Vietnamese? We can exchange FB if you’d like to.
Dạ vâng, cám ơn bài viết tâm huyết của anh rất nhiều
facebook.com/share/tTjydVrD61AWBe1...
Thank you for sharing!
Cảm ơn anh đã chia sẻ!
Great read, thanks Huy
It's worth waiting for Part 2!
Love it!
Like!