NYCPHP Meetup

NYPHP.org

[nycphp-talk] Code cleanliness vs. code popularity

Jonathan hendler at simmons.edu
Fri Sep 16 10:35:40 EDT 2005


I think you are bringing up some good points.
For example, at one of my previous jobs I had written a lot of objects 
with functions that operated on $this keywords. Many of the functions 
"needed" to be accessed in a static way like Class :: function(); and 
$this doesn't cut it. So I had to rewrite them. Instantiating classes in 
PHP used to be slow.

Where OOP can shine is when you think in terms of Business Objects and 
Business Logic. And a lot of non-programmers , who pay your salary, do. 
Flowcharts, forms, datasets all can be mapped easily to components that 
can be serialized and reused. Not only that, it's easier to abstract 
these terms to the point where there is code generation. PHP might have 
some cool procedures, but they are likely difficult to reuse with a 
simple include() statement.
That being said, sometimes OOP is just a way to give a set of functions 
a namespace.

I mix functional and OOP programming depending on context, and I try to 
be careful when I use OOP not to require instatiation on helper or  
utility functions.

Jayesh Sheth wrote:

>Hello all,
>
>I was recently reading through the phpBB source code, and had some
>observations to shares. In most of the pages / script files I looked
>through, there were 1000 - 2000 lines of PHP code, with no functions or
>comments. While the code itself is strictly procedural, it is also to
>the point, and not indecipherable.
>
>Still, some interesting questions came to me: how can one of the most
>popular PHP applications be written in eighties-style procedural code?
>Or, to rephrase it: are object-oriented design, (fancy) frameworks not
>useful in practice? How many of you have worked with commercial, open
>source or in-house frameworks? Have you found these frameworks to be
>useful in the long run, or do they just get in the way?
>
>I have long been a fan of PEAR (and other external / third-party)
>libraries. I much prefer to save myself work, when I do not have to
>reinvent the wheel. Still, in many companies, people prefer to write
>everything from scratch, often wrapped up in laborious frameworks. In
>your collective experience, what's the best policy for code development?
>In other words: bang it out, test it, ship it, receive feedback, fix it,
>and then back to the beginning again, or: huge design upfront, OO or
>functionized code,UML diagrams, and the 'f' word: a framework.
>
>I personally cannot write strictly procedural code any more, and I
>prefer a mix of functionized and OO code. Still, real world applications
>- popular real world applications, often totally avoid this approach.
>So, what gives?
>
>- Jay
>_______________________________________________
>New York PHP Talk Mailing List
>AMP Technology
>Supporting Apache, MySQL and PHP
>http://lists.nyphp.org/mailman/listinfo/talk
>http://www.nyphp.org
>  
>




More information about the talk mailing list