Hi
I have a script which handles customer records and license keys and a lot of other stuff. I have one file which contain the main function. This function will take about 20 arguments, where one of them is “action”. This variable will tell the main function what to do: create, update, select and other. Each value will actually launch another function, for example createCustomer, updateCustomer. In addition to these main functions there are a lot of “smaller” functions which does many different things. As I said the main function is in one file, and the rest are divided into several included files. All of the files has about 10-15000 lines of code all together.
I use the main function in several other scripts. I am now thinking about creating this in a better (?) way using classes/OO. Since I’ve actually never created any really “big” classes yet, I’m hoping somebody could help me/point me in the right direction.
I should only create one class which contains all functions needed? Like this:
[code=php]class customerClass {
public $Action;
public $Name;
public $Email;
public function executeCustomerClass(){
if ($this->Action == “create”){
$this->createCustomer();
}elseif ($this->Action == “update”){
$this->updateCustomer();
}else{
//unknown action
}
}
public function createCustomer(){
//Insert new customer record
}
public function updateCustomer(){
//Update customer record
}
public function doSomeCoolStuff(){
//some small function doing something useful
}
}
But then I would have to have everything in one file, and then some readability would be lost? Anybody got some advice here, or should I just buy a book? ?
Let me know if you need additional info to be able to help me….
Thank you very much
Lubox