I am creating an object oriented design for a cab-calling app like Uber. I have some of the classes listed. I am having trouble in designing behavior between the classes. For example, I have these two classes -
Customer and Driver
A customer can call drivers and a driver can accept a ride request from customers.
So my thought is Customer class will have a function contactNearByDrivers(). And Driver class will have a function like getRideRequest()
I have two questions here -
Where should the actual implementation of contacting nearby drivers and confirming driver's response should be? My thought is that there can a utility class, lets say
CustomerDriverInteraction. This class will actually have functions for contacting near by drivers and recording their responses.contactNearByDrivers()function inCustomerclass would instantiateCustomerDriverInteractionand call its functions . Is this a good way of going about it?Once a driver accepts a request, the customer and driver need to be linked together for a ride. Should there be another class called
Ride?Rideclass will have aCustomerandDriverobjects as their members, among other fields. Is this approach correct? What are are the better ways of designing it?