Jump to content

Recommended Posts

I've been developing with PHP for about 6-7 years now, since I was around 13-14. I've always used the procedural coding style when ever I've undertaken a project, whether it be for myself, or freelancing.

 

I've read up on OOP and it's advantages/disadvantages and whatnot, but I just cannot grasp how it can be used effectively.

As far as I see it, its a bunch of functions wrapped in a class, which is loosely similar to just normal PHP functions within procedural coding.

 

Why would someone use OOP over procedural?

 

I would like some individual input on this, because I would like to better my knowledge of OOP and maybes start using it for future projects of my own, till I am comfortable enough to use it for freelance work.

 

Just looking for your insight to the benefits of OOP, and your honest opinion on whether its worth learning and why.

 

Thanks in advance, Paul.

Link to comment
https://forums.phpfreaks.com/topic/266617-oop-am-i-missing-something/
Share on other sites

I've read up on OOP and it's advantages/disadvantages and whatnot, but I just cannot grasp how it can be used effectively.

As far as I see it, its a bunch of functions wrapped in a class, which is loosely similar to just normal PHP functions within procedural coding.

 

You can't have done much reading then.

Well spotted, but I'm asking for your opinions on OOP, not your opinion on my post, or my current research (or lack of).

 

I don't want to waste time researching something that I feel wouldn't benefit me, if someone had a few valid points as to why they use it, or prefer it, then it would lead me to look into it more.

As far as I see it, its a bunch of functions wrapped in a class, which is loosely similar to just normal PHP functions within procedural coding.

 

That's because online tutorials are generally shitty and hardly ever show why OOP can be efficient and flexible.  Instead, they begin and end with syntax and canned examples like a Cat class deriving from an Animal class.

 

Get Matt Zandstra's book, then the Gang of Four's book.  They will illustrate real world examples (especially the GoF book).  Suffice it to say that there's a reason why OOP skills are generally required by professional grade dev shops.

That's because online tutorials are generally shitty and hardly ever show why OOP can be efficient and flexible.  Instead, they begin and end with syntax and canned examples like a Cat class deriving from an Animal class.

 

Get Matt Zandstra's book, then the Gang of Four's book.  They will illustrate real world examples (especially the GoF book).  Suffice it to say that there's a reason why OOP skills are generally required by professional grade dev shops.

 

I will definitely have a look at those, I agree most of the online tutorials aren't the best, they never were for prodecural either.

I have wanted to have a look into OOP for sometime, but could never bring myself to spend the time researching and learning if it wasn't going to be beneficial, when it could be time spent working.

Some of the benefits of OOP are:

- encapsulation

- polymorphism

- code reuse

- abstraction

- modularity

 

For very small projects, OOP may not seem to have any benefit. In fact, it might be worse -  by over complicating the problem.

 

In my opinion, this is an excellent book on OOP, and how it applies to PHP.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.