1
redheadedrod
MVC what is it and why it makes sense for xoops going forward.

What is MVC?

M - Model = This is the portion that DOES the work.

C - Controller = This is the portion that Controls what happens.

V - View = This is the actual user interface that the user accesses and views.

With Xoops we have a system that for years basically has consisted of a template that is loaded with values from a module. In other words we are already 2/3rds the way there with a standard module.

In my "advanced" java class our instructor explained this model in a manner where each component of an MVC design should theoretically setup in a manner that it can be pulled out of the program and replaced without impacting the program.

What this means for instance is the Model did all of the actual work. It communicates to the database, validates the data, or whatever other job the module is supposed to do. Such as calculate a date or whatever. When writing a Model it is a good idea to have it be able to stand on its own. It should NOT depend on anything being returned to it from the controller or from the view. It should only act on the data sent to it and return any results back to the calling procedure.

The view should also be able to work on its own. It should present data to the user or retrieve data from the user. In my Java class we had to have a console based View and a GUI based view. This entitled that the View wasn't directly dependent on any other component. It only showed what it was told to show and only returned what was requested.

The controller is the brain of the system. It will take input from the view, send it to the model to process and display results back to the view. In my Java class we had to build 2 different controllers to do totally different things with our Model and our View. This allowed us to have two totally different, but similar, programs by just changing the controller but using the original view and original model.

Separating your program into these three components helps in many ways. You can reuse your code easily in other modules and you could actually build a Model that could be used by many different programs or modules like a framework of a sort. You could also make it easier to be compatible with other versions of xoops by insuring all of your xoops related code is in the model. A service provider could be written much easier for xoops 2.6 as well.

Another thing it helps with is testing. phpUnit can test functions much easier in an MVC environment. It can really test the Model objects well since they are designed to be self contained. The controller can also be tested easier because you should be able to run controller functions without a view. The view may not need to be unit tested and may not be able to be unit tested.

Regardless to what some developers might believe MVC is here to stay. It makes sense and in the long run will make a developers life much easier by simplifying the code.

Rodney

2
Bleekk
Re: MVC what is it and why it makes sense for xoops going forward.
  • 2014/11/27 15:46

  • Bleekk

  • Theme Designer

  • Posts: 941

  • Since: 2002/12/14


is MVC part of xoops 2.6?

3
Mamba
Re: MVC what is it and why it makes sense for xoops going forward.
  • 2014/11/27 19:16

  • Mamba

  • Moderator

  • Posts: 11409

  • Since: 2004/4/23


Quote:
is MVC part of xoops 2.6?

It might not be in the first release, but the plan is definitely to have it. Richard has already experimented with a MVC design based on Mojavi framework, which was also the starting point of Symfony. This MVC-design done by Richard was kind of a "proof of concept" and was on top of XMF from Trabis.

But MVC is not standing still, and there is recently an interesting development toward "Action-Domain-Response" model by Paul Jones. You can read more about it here:
http://paul-m-jones.com/archives/5970

Richard has also looked into it and did some experiments with this concept, and he liked that approach.

I think that with the current work by Richard and with the MVC done by Eduardo in RMC, they should be able to merge the best ideas into a nice MVC design in future XOOPS version.

As you see, there is a lot of cool things happening in XOOPS, and once certain decisions related to architecture of the future XOOPS are made and implemented, things will move much faster.

Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

4
redheadedrod
Re: MVC what is it and why it makes sense for xoops going forward.

At this time It is my opinion from what I have seen that 2.6 will not be MVC but there will likely be some items setup with it in mind.

With modules it makes a lot of sense in many ways but for the core there is too much work to be done to make the changes to make it truly MVC at this stage.

There are other things that Modules can benefit from when in an MVC format as well. It makes cloning a module much easier because you can clone JUST the controller and the view if you like and leave the model alone.

I am excited by the combination of MVC and the Service Manager in 2.6 because it can make my previous "dream" of module libraries a reality.

Note that by my mentioning MVC making it easier to make modules 2.5.x and 2.6.x compatible only relates to the code differences. While there are attempts being made to make 2.6 backwards compatible with 2.5 modules there are additional features in 2.6 not available in 2.5. By making modules in an MVC format you should only have to modify the Model to work with 2.6 and hopefully only minimally if at all.

Rodney

5
vamptrix
Re: MVC what is it and why it makes sense for xoops going forward.
  • 2015/2/19 13:00

  • vamptrix

  • Theme Designer

  • Posts: 424

  • Since: 2008/5/3 1


I'd like to see that XOOPS 2.6 will be fully MVC, but I fear it'll take a longer while than that to see it actually happen (it will take a lot of work to get this in place).

It will be worth the effort though, as MVC has many benefits.

Login

Who's Online

256 user(s) are online (180 user(s) are browsing Support Forums)


Members: 0


Guests: 256


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits