Alex Rivera | Logout

I have been writing PHP without "classes" for years... what am I missing?

Asked 2012-02-21T09:34:53.590
21

For the life of me, I can't seem to wrap my head around "classes" in PHP.

I have managed to write large, scalable, and popular websites without them.

What am I missing? (And how do I learn?)

Edit
Report

1 Answer

0

You are probably missing testability: I guess your functions call other functions, which in turn might call another function, right? So you will have trouble testing an isolated function. With OOP you assemble "heaps" of objects and can interchange each object with a "fake" one (called mock or stub) for a test. This way, you can test each functionality in isolation. Think of being able to test you output code without needing a database. Think of testing your controller code (the code which processes the request parameters and decides what action to take) without needing a web server.

answered 2012-02-21T10:22:38.067

Your Answer