Jump to content


Photo

Classes vs. not using them


  • Please log in to reply
4 replies to this topic

#1 insaynewrapper

insaynewrapper
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 17 July 2006 - 07:36 AM

I'm a pretty decent PHP developer, but I have yet to implement classes in my work, and I'll tell you why: I've never had a need to. I just plain and simple don't understand the need for oop when I'm working. I don't see the advantage of using it. What can I do through oop that I can't do otherwise?

Thoughts?

#2 CheesierAngel

CheesierAngel
  • Members
  • PipPipPip
  • Advanced Member
  • 105 posts
  • LocationBelgium

Posted 17 July 2006 - 07:46 AM

Using OOP is not a matter of extending the PHP code abalities. It's more a way to organize your code
so it becomes easier to extend a certain application or re-use your code. Classes are notting
more then a described object with the necessary variables and functions to manipulate the object.

#3 insaynewrapper

insaynewrapper
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 17 July 2006 - 07:51 AM

And I understand that, but I don't see how it's any more organized than not using them. Maybe you could give me an example...?

#4 CheesierAngel

CheesierAngel
  • Members
  • PipPipPip
  • Advanced Member
  • 105 posts
  • LocationBelgium

Posted 17 July 2006 - 08:02 AM

For example, you can create a class user so any information is stored in this object for a regular website visitor.
But if you 'as webmaster' want to log-in you want more privileges. So you make another class superuser extended from the regular user class and you can re-use the function and extend them without rewriting them.

#5 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 17 July 2006 - 09:46 AM

Your not going to get the concepts of oop explained in a simple forum reply, hell, I have several books, probably 6000 pages of examples and theory and Im still just comming to terms with it.

I suggest... if your interested in the whys... a good place to start is the book thinking in java, available free. ok... so its not php, but php and java share much the same syntax these days, and the oop concepts don't change.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users