Welcome Guest, Not a member yet? Register   Sign In
CI, HMVC and Beyond
#2

(This post was last modified: 12-12-2014, 01:58 PM by mwhitney. Edit Reason: Fix the $this->load->view() arguments... )

HMVC gives you a method for calling code between modules and organizing your code into modules. Most of your questions really have nothing to do with HMVC, but instead with the general idea of separation of concerns in your code.

If you are creating a table in the database, maybe you should use the migrations library to manage the database tables and check the migration version in the model. If that seems like too much for your project, maybe your code to create the table should check whether the table exists first. With any code you intend to use in multiple projects, there is a balance between how much code you are willing to write (and execute as needed) and how much you are willing to assume about the environment in which your code will run.

AJAX vs. a whole-screen refresh: this is really more of the same. Personally, if I write a controller method which I intend to be available via both AJAX and non-AJAX calls, I do something like:
PHP Code:
if ($this->input->is_ajax_request()) {
 
   return $this->load->view('xyz'$datatrue);
}

// code to send the view to output 

Most of the time, though, anything I write which is just intended to build a partial view of some sort will just load a view and return it to the caller, rather than sending it to output.

Honestly, most of this is just sitting down and designing code for reusability. A good place to start might be a more general overview, like Wikipedia's page(s) on SOLID OOP design principles ( http://en.wikipedia.org/wiki/SOLID_%28ob..._design%29 ).
Reply


Messages In This Thread
CI, HMVC and Beyond - by Jerryafe - 11-17-2014, 06:20 AM
RE: CI, HMVC and Beyond - by mwhitney - 12-12-2014, 01:39 PM



Theme © iAndrew 2016 - Forum software by © MyBB