Welcome Guest, Not a member yet? Register   Sign In
avoiding repetition of code
#1

[eluser]crumpet[/eluser]
Hi,
I've been working on a site for sometime now and am currently at a stage where I'm just going back through and trying to clean things up a bit.
All five controllers use a couple of the same functions and right now they just repeat.
The most important one is _run() which all the methods call to display a page. Each controller's version of _run() is slightly different however they all share a few declarations that are exactly for same. For instance they all have a line of code which declares a $this->template['accountInfo'] variable so the loader file knows whether to display a login box or account options box. And they all do things like set the $this->template['title'] variable. However they differ for variables like $this->template['currentTab'] which is different for each controller (determines which tab appears selected in the navigation). Basically what i want is a way to do this
Code:
function _run(){
   //Paste code from a file which contains the standard declarations that all controllers need
  
   //declare the variables that are different like normal
}

can this be done??


Messages In This Thread
avoiding repetition of code - by El Forum - 09-03-2008, 11:02 AM
avoiding repetition of code - by El Forum - 09-03-2008, 11:11 AM
avoiding repetition of code - by El Forum - 09-03-2008, 11:27 AM
avoiding repetition of code - by El Forum - 09-03-2008, 11:46 AM
avoiding repetition of code - by El Forum - 09-03-2008, 03:00 PM
avoiding repetition of code - by El Forum - 09-03-2008, 03:19 PM
avoiding repetition of code - by El Forum - 09-03-2008, 04:21 PM



Theme © iAndrew 2016 - Forum software by © MyBB