Learning OOP

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
devil78
Forum Newbie
Posts: 7
Joined: Wed Aug 22, 2007 1:08 pm

Learning OOP

Post 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!
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: Learning OOP

Post by Zoxive »

My #1 would be to go PHP5, because it is dropping support in about 18 days, and PHP5 has more OO Goodies.
devil78
Forum Newbie
Posts: 7
Joined: Wed Aug 22, 2007 1:08 pm

Re: Learning OOP

Post by devil78 »

Ok, I totally agreed! PHP5!

What do you think about my exercise? Is this a correct way to work?
Selkirk
Forum Commoner
Posts: 41
Joined: Sat Aug 23, 2003 10:55 am
Location: Michigan

Re: Learning OOP

Post 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.
User avatar
junix
Forum Newbie
Posts: 5
Joined: Tue Sep 25, 2007 2:10 am
Location: MSU, Philippines
Contact:

Re: Learning OOP

Post 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....
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Learning OOP

Post 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.
(#10850)
Festy
Forum Commoner
Posts: 28
Joined: Wed Jan 30, 2008 10:01 pm

Re: Learning OOP

Post 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.
Post Reply