Jump to content
Larry Ullman's Book Forums

Clips: What'S The Point Of Oop?


KeepLearning
 Share

Recommended Posts

version 0.5

 

Page 129

 

As I read this book, I keep scratching my head, wondering what's so good about OOP (Object Oriented Programming). The clips example is a case in point. Why write 5 lines of code when you can write just 2, like this?

 

$stockQuote = 'AAPL: $533.25';

echo $stockQuote;

 

I can modularize my procedural code by using includes. So how can all the fuss and bother of OOP be worthwhile?

 

I've read plenty of rationales defending OOP, written by people who studied it in college, but it seems more like a religion to me. Sorry, I don't mean to offend anyone.

 

I've read some books on OOP php, and I'm patiently reading through this one, only because I want to take advantage of the code that's automatically generated and tailored to whatever tables I need. But frankly, I will probably write most custom code, queries etc, as procedural php.  

Link to comment
Share on other sites

A couple of short answers...

 

1. The code you're pointing out isn't 5 lines because of OOP. It's way more than 5 lines because of OOP and MVC.

 

2. You've presented your question in a way that suggests there's no point in answering. You've already read "plenty of rationales defending OOP" (interesting phrasing, by the way, as opposed to "arguments for using OOP") and you're not convinced yet. The pragmatist in me says there's no point in answering: what can I say that you haven't already read? And can you even be appreciative of the benefits of OOP regardless? 

 

And, for the record, I say this as a person that's not religious about OOP. I understand its strengths and weaknesses. On some projects I use OOP and on others I use procedural. I'm not categorically for or against either approach. 

Link to comment
Share on other sites

 Share

×
×
  • Create New...