I'm following a tutorial which I think is written by someone who doesn't know what he's doing (already caught 2 obvious mistakes and the rest of code is messy). But I don't want to discredit the guy completely, so I'm asking here about something else that I don't understand.
First of all, I will send a 100 brownie points, my 2 pets, and a box of chocolate to whoever can explain to me what is going on with this code.
He's using module-based architecture. Module name is frontmodule
. Module has MVC. And module has an internal library
of its own.
/modules/
/frontmodule/
/models/
/views/
/controllers/ -- the /module controller is here (undestandable)
/library/
/Controller/ -- the /module/library controller is here (why?!)
/Action/
First comes the confusing part. Why each module has an internal library, and why that intenal library has its own controllers
and actions
. Is this a best practice? I'm thinking this library could be moved to a plugin that the module can use. Not sure..
Now comes the interesting part.... in addition to each module having its own internal library, there's also a Common library shared by all modules (see it below at the same folder level as /modules
) and that Common library also has its own controllers and actions (just like each internal libraries have their own controllers and actions)
/modules
/library/
/Common/
/Controller/ -- the /common/library controller is here (why?!)
/Action/
/Helper/
/Plugin/
So we have 3 controllers:
- the module controller
- the module internal library's controller
- the common library's controller
Now here's the insane part that I think is over-complicating life
He says: A module controller extends the module’s library parent controller which also extends the Common library controller.
class IndexController
extends Frontoffice_Library_Controller_Action_Abstract { ... }
abstract class Frontoffice_Library_Controller_Action_Abstract
extends Custom_Controller_Action_Abstract { ... }
So I guess:
- the module controller =
IndexController
- the module internal library's controller =
Frontoffice_Library_Controller_Action_Abstract
- the common library's controller =
Custom_Controller_Action_Abstract
where module controller
extends module internal library's controller
and module internal library's controller
extends common library's controller
Has anyone seen anything like this before? My guess is that this code won't be easy to maintain, but maybe those more experienced with zend can tell me what this guy is trying to achieve. The app structure is a little too messy. I think he's abusing MVC instead of using it to simplifying the app and its maintainability.