New to OOP

Hi all,

I am fairly comfortable writing procedural PHP but am spending some time trying to learn OO PHP. I can grasp the concepts and syntax of how to create and instantiate classes and use them but am looking for some guidance on what to include in a class and what classes to include in files. Take for instance a contact manager application (I wrote one a while ago and am using it as a starting point). There are not all that many tasks and want to get an opinion of where to put all the classes and methods.

Would you create an insert class and have methods that insert a contact and one for phone numbers and addresses or have a contact class that has methods insert, update, delete and a phone class insert, update…. You get the picture.

Thanks in advance

I would personally try to minimize the number of objects needed. So “have a contact class that has methods insert, update, delete” would be the better method.

Sponsor our Newsletter | Privacy Policy | Terms of Service