Rss subscribe!
It's free.

about

A blog about web development and starting up online.


who

Eran Galperin is the techfounder, an Internet entrepreneur and web technologies expert.

25 May

Money(I know I’m due the last part on Models in the Zend Framework. I’m getting there, it’s a pretty long rant so it’ll be here eventually)

Continuing with (PHP) development best good practices:

2. Object Orientation

Object Oriented programming is a software architecture methodology that became mainstream in the mid 1990’s. It means different things to different people, and there is much debate whether it’s any improvement over more traditional procedural programming. I won’t get into that debate, but I’ll quickly recap why I consider OO very important for a serious developer:

  • It provides structure and modularity to your code. While you can duplicate that in procedural programming, OO gives you language tools to deal with it (classes).
  • Code re-use. Modern OO languages (PHP included) give you inheritance and polymorphism in addition to containing code segments in functions (methods in OO lingo).
  • Encapsulation (or code visibilty) is another OO methodology trait that give you more tools when designing interfaces for your code. It relates to the idea of code re-use by hiding implementation details from the outside, therefor promoting better interfaces to be created. PHP5 implements code-visibility features such as the ‘public’, ‘private’ and ‘protected’ keywords.
  • Static types. Static methods and members of a class can replace the use of globals and defines almost completely, reducing global namespace pollution (read a little about why globals are ‘evil’).

In addition, almost all professional code packages are written completely in OO programming. So if you have any intention of using some very powerful code libraries, you better get along with OOP ;-).

Extra reference material:
PHP manual on OO (read also the part on PHP5 specific features)
Wikipedia - Object Oriented Programming
Introduction to object oriented programming in PHP
OO versus Procedural Programming in PHP

Previously: Coding standards, Next up: Refactoring

Share this article: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • DZone
  • del.icio.us
  • Technorati

Posted under PHP, Web development

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Some rights reserved, Eran Galperin
CC 2008 - The Future