I'm new in OOP and I just started learning it. Its too complicated to determine the functionality of classes. Let's take an example:
We have an Address-book and an user want to add a new contact to it. In this scenario we have 2 classes:
- User: that determine the user that logged in.
- Contact: A contact object that consists of Name, Address, Phone Number, etc
And the questions:
- Who have to save a new contact?User class or Contact Class
- If we try to check the user's permission before doing anything where is the best place for it?
- Is it OK that these classes have a access to database?(Is it better to create 3rd class for doing query stuffs?)
Thanks for any good idea ;)