I am creating object oriented design for a simple app through which users can order food from restaurants. User can browse nearby restaurants, explore menu, add items to cart, and finally checkout.
For now I am concentrating on two main classes User
and Restaurant
and the interaction that a user can browse nearby restaurant. Lets say that there is a function called getNearByRestaurants(Location location)
. Which is the best place for the function to be? Some options that I thought -
- In
User
class. My confusion with this is shouldUser
class just have all the functions related only to a user, like changing email, credit card, etc. or should it have functions that can interact with other entities? - A new class called
UserActions
where all user interactions with other entities can be listed. - A class called
RestaurantRegister
, which can be a singleton. Any new restaurant would register itself using functions of this class.getNearByRestaurants(Location location)
can be in that function.