Page 1 of 1

Learning OOP

Posted: Thu Jan 17, 2008 8:25 am
by devil78
Hi to all!
I'm studying the OOP programming with PHP4. I'd like to understand better this new way to program...
For instance, I'd like to create an application to manage a school.
So, I have:

- courses
- each course has many school matters
- each school matter has teachers/tutors
- each teacher/tutor has a name, a surname, etc...

I'd like that my application could generate:
- report about activities (stats)
- modules filled out with the saved data

How I can translate this problem in an object oriented code?

Hyphothesys:
a class "login"
a class to insert/modify/delete a course
a class to insert/modify/delete a school matter (extension of "course")
a class to manage people (extension of "course")
a class to generate documents
a class "research"

What do you think? Someone can help me to understand better this problem?

ciao!

Re: Learning OOP

Posted: Thu Jan 17, 2008 9:01 am
by Zoxive
My #1 would be to go PHP5, because it is dropping support in about 18 days, and PHP5 has more OO Goodies.

Re: Learning OOP

Posted: Thu Jan 17, 2008 9:12 am
by devil78
Ok, I totally agreed! PHP5!

What do you think about my exercise? Is this a correct way to work?

Re: Learning OOP

Posted: Sat Jan 19, 2008 12:04 pm
by Selkirk
Try a book called "object primer" by Scott Ambler. It uses a school in its OO design exercises and examples. Many other books do as well.

Re: Learning OOP

Posted: Wed Jan 23, 2008 2:48 am
by junix
yea i also agree to run into php 5, you will find out ways to design object oriented programming.
There are lots of functions supports in OOp.
Thank you and God Bless Guyzzzz....

Re: Learning OOP

Posted: Wed Jan 23, 2008 3:13 am
by Christopher
I think you need to separate the things in your system, like classes, teachers, students, etc. and the things that can be done like login, insert, modify, delete. You may have objects for the things in your system and other objects to abstract things like database connections, the session, the request, etc.

Re: Learning OOP

Posted: Thu Jan 31, 2008 6:10 am
by Festy
The classes of your system can be -
- school
- teacher
- student
- course
- login
- report
etc.etc..

Then in course class you can have methods like insert_course(),delete_course(),modify_course() etc.
in teacher class you can have methods like add_teacher(), delete_teacher() etc.
in student class also you can have methods like add_student(), delete_student() etc
in report class you can have methods like generate_report(), modify_report() etc.