PHP and application evolution
Ian Bicking provokes some interesting thoughts in PHP and Application Evolution, in context with Python and Zope, inspired by this enlightened comment on that article I blogged a while back.
I think Python’s imperative approach is a real feature. Starting on an application by building objects (or doing “whole design”) is a bad idea, unless you know the domain well
and then from the comment he links to;
PHP object orientation was minimal and used only for 3rd-party packages (which is the way it should be in web apps) and it’s syntax is also very simple.
If we think about web apps as, typically having three “layers” (even if they can’t be distinguished in source code) – a data layer (data fetching e.g. from db), an application layer (typically thin in a PHP app but might include simple number crunching, sorting and so on) and a presentation layer (responding to incoming requests, rendering HTML), the approach that seems most successful / down to earth (in terms of getting a project finished / reaching working prototypes) is OO for the data layer, procedural code for the presentation layer and a mix of the two for the application layer. From my own experience and from looking at successful apps like WordPress, so long as you don’t go wild with global variables, it’s hard to fail with this approach, at least until your app really starts to grow.
Meanwhile Jeff has done an outstanding job with laying the foundations of WACT’s MVC implementation; even if PHP isn’t your cup of tea, it’s worth exploring what he’s done. The flip side of the coin though is, as you can see from the reference CRUD application, there’s suddenly alot of classes out there, even for a relatively simple app. Talking to Jeff recently, it’s possible that the current design is going to get “dumbed down” again eventually – what’s been lost is that essential simplicity. In building a really flexible MVC implementation, making unusual use cases possible seems to prevent make common use cases easy.
Anyway – just musing on the state of the Elephant.
Otherwise phpPatterns (and my email) has been down the last few days. The provider of the DNS service I was using decided to wait for the week I went on holiday to make radical changes. Hopefully will will be back up within 24 (any urgent email; please resend).
Don’t you just love it when that relaxed holiday feeling instantly evaporates on returning home?