is this how you do OO programming?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

crazytopu
Forum Contributor
Posts: 259
Joined: Fri Nov 07, 2003 12:43 pm
Location: London, UK
Contact:

Post by crazytopu »

theda wrote:
What is the use of OOP if all you're doing is a few this->here stuff? I'm not seeing the logic in the need for OOP, unless just for learning purposes.
Unless you know what you are talking about, i guess, reading up a bit on OO woudl have helped. In brief, OO gives you untimate flexibily when it comes to do modifications in the future, you can reuse things rather than re-inventing the wheel. It helps cut your developtment time significantly resulting in fast software development. What else do you need?
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

theda wrote:What is the use of OOP if all you're doing is a few this->here stuff? I'm not seeing the logic in the need for OOP, unless just for learning purposes.
Personally, the biggest value to me for OOP is encapsulation.

I can take a group of useful functions, that work on similar data (objects), and wrap it all together. I can then share that class with other people.

Functions aren't as useful, because they are ignorant of data. Procedural code isn't as useful, because its not easily added to other programs.

But beyond encapsulation, it also enables easy testing. Any given class has inputs, outputs, and expected results. By testing those results, you can build better code.

Its not just about whether you say $variable or $some->variable, its about *structure*, and keeping code seperate and reusable. Thats what allows one person to write 40k+ lines of code instead of 4k+.
pilau
Forum Regular
Posts: 594
Joined: Sat Jul 09, 2005 10:22 am
Location: Israel

Post by pilau »

Couldnt put it better. Besides, being able to program OO programs is something you should be proud of, it requires a lot of originality and knowledge of the programming language. Which, in other words, makes you better than other programmers.
Post Reply