I have some questions pertaining OOP. I'm not an advanced user and I'm facing a problem which some may have experience before.
Basically I'm using MVC to work with my php projects. I tried to make the class as independent as possible. But I think this is rather tough. e.g:
I've got a class Car and User. User posts car info to a website, maybe to sell...
In class User, I have getUser basically to get user info.
So in class Car, I may have setCar, getCar, saveCar. To display these cars, I may have a displayCars(). in displayCars(), I may use getCar to get the list of Cars. but I may also need to use User::getUser to get the user information of users who have submitted those car. So in a way, displayCars is dependent on User::getUser.
So what should I do here?
You need more than just Cars and Users to model this problem. Conceptually, I would at least have the following:
Of course, this is heavily simplified -- there will be a lot more to it than this when you actually write the application. But I think that looking at the problem in these terms is a good place to start.