Codecat15
Aug 6, 2023

--

Please correct me if I am mistaken, but my understanding of your statement is that it suggests placing data-fetching logic inside the views?

While it is indeed possible to put logic inside views, it is crucial to consider whether it is the appropriate place for complex logic.

Doing so can hinder reusability and lead to code duplication thus impacting separation of concern

For example, if I need to fetch orders in the OrderView, I might write a function within the OrderView to accomplish this task.

Now, in the CheckoutView, if I also require fetching orders, should I duplicate the code to fetch the order? Doing so would violate the Don't Repeat Yourself (DRY) principle.

When logic is tightly bound to Views, it becomes harder to reuse them across different parts of the application or in different scenarios, resulting in code duplication and decreased code quality.

--

--

Codecat15
Codecat15

Responses (1)