I have a Client class that contains many attributes(about 100).In my html form however, I grouped these details into Personal, Medical, Employer, Payment, Beneficiaries etc.
When I designed the class, the constructor of the class was cluttered with all those variables. I thought of creating separate classes for the Personal, Medical, Employer, Payment and Beneficiaries details, just to reduce the number of fields in the main class.
class Client
{
protected Personal $personal;
protected Medical $medical;
protected Employer $employer;
protected Payment $payment;
protected Beneficiary $beneficiary;
protected $db;
function __construct($personal, $medical, $employer, $payment, $beneficiary, DB $db)
{
$this->personal = $personal;
$this->medical = $medical;
$this->employer = $employer;
$this->payment = $payment;
$this->beneficiary = $beneficiary;
$this->db = $db->getConnection();
}
public function register()
{
}
}
Is this the proper way to go? If it is ok, then how do I efficiently extract all the other information and save to their corresponding tables.
It looks like you're new here. If you want to get involved, click one of these buttons!