Welcome to Gaia! ::

I'm pretty good with Procedural Programming in PhP, and now I need to learn the basics Object Oriented!

Does anyone know of some OOP information that's easier to understand? I've been looking up tutorials all day, and nothing is registering.
Sitwon's avatar

8,500 Points
  • Gaian 50
  • Member 100
  • Contributor 150
Object Oriented Programming is actually very simple. I could try to explain it, but I'm sure the the tutorials you've read have already done that. Really, the best way to learn is by doing. Start playing around with it and try to figure out what it's doing and how it works.

At it's very core, a class is just a way to group together some variable and some associated functions.
I had trouble learning OOP for PHP when I first tried. Then I learned Java and C#. Once you know OOP in other languages, using OOP in PHP seems alot more natural
Sitwon's avatar

8,500 Points
  • Gaian 50
  • Member 100
  • Contributor 150
At my job, one of the interview questions is to use classes to create a bicycle object, with the pieces extending or implementing each other as needed. I'd say that's a decent place to start.
Sitwon's avatar

8,500 Points
  • Gaian 50
  • Member 100
  • Contributor 150
Charley Foxtrott
At my job, one of the interview questions is to use classes to create a bicycle object, with the pieces extending or implementing each other as needed. I'd say that's a decent place to start.
I'm struggling to see how that is a good question. Are there more constraints that you have left out? Can you give an example of what would be considered a good/bad answer?
Charley Foxtrott
At my job, one of the interview questions is to use classes to create a bicycle object, with the pieces extending or implementing each other as needed. I'd say that's a decent place to start.
That sounds like one of the pathological misuse cases for OOP that I keep reading about.

I've seen a lot of books introduce OOP with bicycle and car concepts like that, where you've got wheel objects and the car extends the wheel and so on... But that always leads to bad design, and is never a good idea, and it shows a complete lack of understanding on the part of the author/questioner, IMO, because it's a strong anti-pattern.

(In this case, the "bicycle" object should contain two references to wheel objects, and a crank object that is initialized with a reference to the rear wheel object. At no point should inheritance of any kind be used in this example. ... Even then, I question whether it's necessary for there to be wheel objects at all.)

The majority of resources I've found on OOP development seem to focus on bad examples and misuse of the GoF Design Patterns.

I'm not sure there are any good resources on OOP itself.

There are a couple books on PHP OOP, but given the general state of the PHP community, I wouldn't even buy the book used, for the paper as kindling.
nouveau sereph's avatar

Shameless Enabler

Long ago, when I was just learning the basics of PHP OOP, this article really helped me wrap my head around why I should use it and the form required: LINK. I'm not entirely positive that that's where I read it, but it seems to float all around the internet anyway, so there's as good as any. Reading it won't make you a master, but it'll give you a great starting point; the original author was pretty talented.

Quick Reply

Submit
Manage Your Items
Other Stuff
Get GCash
Offers
Get Items
More Items
Where Everyone Hangs Out
Other Community Areas
Virtual Spaces
Fun Stuff
Gaia's Games