You hear about "single reason to change" when it comes to the scope of a class and how big to make it. However, my client repository I feel contains client-only methods that doesn't make sense for me to put elsewhere. Should I be creating many classes/repositories for the sake of thin classes?
Is my interface too big? Thanks!
interface ClientRepositoryInterface {
public function find($client_id);
public function update($client_id, $data);
public function setPreferredWalker($client_id, $preferred_walker_id);
public function setCashClient ($client_id, $is_cash_client);
public function isCashClient ($client_id);
public function setServicesRequested($client_id, $servicesRequested, $serviceRates, $serviceRateAdds);
public function makePayment($client_id, $amount, $date, $paymentMethod, $invoice=Null);
public function getBalance($client_id);
public function newClient($data, $servicesRequested, $serviceRates, $serviceRateAdds, $serviceTypes);
public function getPets($client_id);
public function getName($client_id);
public function getAddress($client_id);
public function getDogWalkerName($client_id);
public function getContacts($client_id);
public function hasServicesToInvoice ($client_id);
public function getServicesToInvoice($client_id);
public function getAmountToInvoice( $client_id );
}
You could create 3 separate interfaces, which a single repository could use.
Split things into logical groups:
Or create separate repositories, each with it's own interface.
Thanks Jay.
My only question then becomes, are model relationships unnecessary? For example, my getPets() method simply creates a Client model and then uses the defined relationship to get the pets with $client->pets.
I figured a getPets() method in a PetsRepoInterface would return all pets, not client specific.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community