Welcome Guest, Not a member yet? Register   Sign In
I need good design ideas for my controllers?
#2

[eluser]mddd[/eluser]
If you have that many controllers and they are that long, my guess is you should try to move more of your functionality towards models / libraries.
You should think of the controller as the 'general manager' who looks at the big picture but doensn't handle too much of the details.
Functions that are more general, and do tasks that might occur in other sites, put them in libraries.
Functions that are specific to the project, put them in models.

Also, if you have the same information in different output formats, I would combine those controllers. So if you have some kind of list that is shown in your website but also available as an rss xml document, you could make 1 controller "list" and call that with an argument telling it what to output.

An abstract example;
Code:
class List extends Controller
{

function  __construct()
{
  // do things that always need to be done for the list
}

function index()
{
  // if no method is called, output the info as html
  $this->html();
}

function rss()
{
  // get the information you want
  $info = _get_some_info();
  // output it as rss
  $this->load->view('list-rss', $info);
}

function html()
{
  // get the information
  $info = _get_some_info();
  // output is as html
  $this->load->view('list', $info);
}

}


Messages In This Thread
I need good design ideas for my controllers? - by El Forum - 04-20-2010, 09:57 AM
I need good design ideas for my controllers? - by El Forum - 04-20-2010, 10:32 AM
I need good design ideas for my controllers? - by El Forum - 04-20-2010, 11:08 AM
I need good design ideas for my controllers? - by El Forum - 04-20-2010, 11:28 AM
I need good design ideas for my controllers? - by El Forum - 04-22-2010, 09:03 AM
I need good design ideas for my controllers? - by El Forum - 04-22-2010, 09:45 AM
I need good design ideas for my controllers? - by El Forum - 04-22-2010, 10:20 AM



Theme © iAndrew 2016 - Forum software by © MyBB