Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New to OOP in PHP question about defining classes

I am, as the title says, new to OOP but self taught in PHP. We have a system running built in procedural PHP which is getting a bit difficult to modify now due to its size. So I am investigating a re-write in PHP OOP to make it easier to maintain.

I am making lists of classes at the moment. Our system is for administering driving schools so we have the school, Instructors, Pupils and lessons which I can see will all be Objects and hence classes. My question comes from the fact we have one school but many Instructors, Pupils and lessons so when building a program we will need to display lists of these Objects. Therefore would a list of any of them be considered a class in its own right or when it comes to programming will it be necessary to create an instance for each Instructor, Pupil and lesson. Or am I missing something fundamental in the design of an OOP system.

As I say, just working out OOP so please be gentle with me.

Many Thanks Colin


Thanks everybody for the comments so far. The more I think about this the more I realise, at least for me. that a list of something in my system is an object. I imagine each item in a list will be a form, as it is now, so any selection of an item will result in a new script being run which will create a new instance of a Pupil, Instructor etc. along with executing methods for the new instance.

like image 795
Colin Martin Avatar asked Feb 11 '11 19:02

Colin Martin


1 Answers

I say forget frameworks....Each has its own nuances. Some don't even bother following MVC correctly (Symfony) and many have very conflicting tutorials thanks to otherwise positive frequent version updates (Zend) Get a real basic grasp of OOP concepts first, then learn specifics of a framework of your choice when and if you choose to go that route. While I'm certified on Zend, work daily in Symfony and have used CI quite a bit, I still personally prefer rolling my own, especially when working in heavily ajaxed applications.

This worked well for me quite a while back: http://www.killerphp.com/tutorials/object-oriented-php/

Good luck. Keep an open mind and be patient. While it seems like it'll take a lot more time, after a while it becomes second nature and is actually very beneficial.

like image 80
bpeterson76 Avatar answered Oct 05 '22 12:10

bpeterson76