Fork me on GitHub
Reply New Topic
2019/4/10 19:51:36
#1
Offline
Home away from home

MVC architecture, routers and other stuff

I've been looking into the MVC pattern, and came across a programming blog that has some very interesting articles about MVC and a couple of its descendants - MVVM and MVVMC. Also has some cool stuff about how to build a front end controller to handle routing.

https://r.je/

It took me a few reads to get my head around it. I thought I had been doing MVC, but it turns out not in a very strict sense. Anyway, I'm trying to build something using a front controller and the MVVMC pattern, which is basically MVC except the view gets split into two components (a view plus a 'viewmodel') to decouple the view from the model and allow each component to be substituted or re-used. Together with the front end controller/router it gives you a lot of flexibility.

Worth a read if you have time (see the section 'MVC Related Articles').



2019/4/11 2:31:10
#2
Offline
Webmaster

Re: MVC architecture, routers and other stuff

I have already come across Tom Butler's articles (hard to forget him, with his exuberant hairstyle profile photo ) and he has some very interesting points, yes. I admit I'm also no rockstar developer in PHP to be able to follow the entire reasoning in 1 go. Some kind of url routing would be interesting to have in ImpressCMS2 (2.0 or a later iteration), for a start.


_________________

Me on Ohloh


2019/5/3 0:30:08
#3
Offline
Just can not stay away

Re: MVC architecture, routers and other stuff

I have made some progress with 2.0 and routing -> https://github.com/MekDrop/impresscms/tree/use-league-router . However right now I haven't figure out how to register routes for modules. But I hope somehow I will solve this and than this functionality will come to icms.



2019/5/3 6:50:12
#4
Offline
Webmaster

Re: MVC architecture, routers and other stuff

Yes, specific routes that take their input from the symlinks that are already present, with the fallback to 'standard' module routes. That would be great to have.


_________________

Me on Ohloh


2019/5/4 2:13:20
#5
Offline
Home away from home

Re: MVC architecture, routers and other stuff

What I'm liking about the router + MVC-type approach is that far less code has to run to deliver a page. eg. my current modules have Ye Olde Traditional handler classes for each object, and these are huge because they hold the code to handle all actions for their client objects.

With the strict MVC approach these monolithic handlers are getting chopped up into smaller model classes, each of which only deals with a specific page view (one or two different actions, as opposed to everything), and the router selects which one to load. So there's a lot less stuff to read for any given page load.



Reply New Topic extras
 Previous Topic   Next Topic
You can view topic.
You can start a new topic.
You can reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You can post without approval.