Alex Rivera | Logout

What are the benefits of OO programming? Will it help me write better code?

Asked 2008-09-25T19:42:52.340
28

I'm a PHPer, and am not writing object-oriented code.

What are the advantages of OO over procedural code, and where can I learn how to apply these ideas to PHP?

Edit
Report

2 Answers

7

One thing no one has mentioned is that OO code facilitates writing readable code:

sherry.changePhoneNumber();
phoneCompany.assignNewPhoneNumberTo(sherry);
sherry.receive(new PhoneNumber().withAreaCode("555").withNumber("194-2677"));

I get a strange satisfaction from such aesthetics.

answered 2008-09-25T20:25:17.777
3

It seems everybody is responding to your question literally, i.e., the specific benefits/drawbacks of OO.

You should learn OO, but not because OO has any specific magic that you need.

The more general form is:

  • Q: "Should I learn (OO, FP, concurrent, logic-based, event-driven, ...) programming?"
  • A: "Yes, learning a new paradigm is always useful, even if you don't use it directly every day."
answered 2009-03-21T06:12:08.843

Your Answer