Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is MVC in ExtJs a one-size-fits-all solution?

We have been using ExtJs for a long time, and now, with the advent of MVC pattern in it we are facing a critical question of whether to use it or not in the times ahead given the approach we had been following so far.

In our application, we have similar screens, like 40 similar screens for generating the reports and so on. These report screens would be having a form with buttons - PDF, CSV, EXCEL. All the buttons would be having same functionality at every screen, that is, submit the form to a url and generate the specific report.

The approach which we had been following was to create a custom class, say reportscreen class, which extends the window class of ExtJs.

This custom report screen class would already have buttons with their handlers defined (given the fact that the functionality is similar for them for all the screens) and will also have a form present with a function setFormItems(). Any instance of this class would provide the items for the form using setFormItems() and the url for generating the report.

This approach not only helps us in reducing the development effort to a great extent, but also allows even a new member of the team to use the class & create a new screen.

Now comes in MVC, the most advised pattern, and the approach shared above is definitely not as per MVC pattern. But then, do we need to really move to MVC pattern here?

Using the above approach, we are not only able to save the effort, but also have a greater control over things.

The purpose of asking this questions is to know about the exact advantages we shall get if we implement the above scenario using MVC pattern and move away from our current approach.

Thus, what extra things would MVC bring to the table in the context above? And also, what would be the best way to implement such a thing in MVC pattern?

Thanks for any help in advance.

like image 245
netemp Avatar asked Dec 01 '25 08:12

netemp


1 Answers

Do you need to use MVC? No. Assuming you've already got a structure that works well for you, if it's not broke, don't fix it. If you were starting a new project I'd recommend using MVC, but I wouldn't refactor a whole bunch of code for the sake of it. If you did use MVC, you would follow a similar approach. You'd have a base view class where you dynamically push on the items in the subclass. You'd have a base controller to handle all the custom events, then subclass controllers to implement custom functionality on a "per module" basis.

like image 71
Evan Trimboli Avatar answered Dec 03 '25 04:12

Evan Trimboli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!