I left Microsoft Technologies and shifted to Open Source around July 2006, that’s when I was first introduced to the LAMPP Stack (Linux Apache MySQL Perl PHP), though I started my journey with Perl but gradually moved towards PHP. Open Source Technologies and PHP have been my bread and butter since then, but I could never admire PHP like I admired C, C++ and Java, always felt limited even when I was applying OOP concepts with PHP but yes in spite of this I loved PHP arrays and the wide range of array functions. My first PHP OOP project happened in December 2007 where I got introduced to Zend Framework as well, since then I’m still in love with ZF but ironically still not fond of PHP, especially PHP OOP! PHP’s weaknesses as an OOP over Java repeatedly kept disturbing me, and this became my favorite interview question for any candidate who claimed to have PHP and Java OOP concepts. I would say about 25-30% of the people could hit chord somehow but rest failed miserably.
In the first section of this article I’ll discuss about the salient features of Object Oriented Programming, next section I’ll address the broad differences between PHP & Java, and in the final section I’ll try to lay down the key weaknesses of PHP OOP over Java.
Object Oriented Programming
Conventional or traditional programing using a high level programming language like C is termed as Procedure Oriented Programming where things happen sequentially, i.e., reading (input), computing, printing (output) take place in sequences. Functions or procedures are written to accomplish all kinds of computations, some functions are system defined and some are user defined.
Object oriented programming emphasizes more on data and data structures rather than functions or procedures; they are tied with the data on which they operate. Data is defined as objects and objects are supported by member functions which are part of the data structure. Object oriented programming takes a bottom-up approach in contrast with the top-down approach of procedure-oriented programming where small modules consisting of data and member functions unite to implement a large application. [Read more…]