ApacheCon slides: PHP Best Practices

You can now download the slides for my talk at  ApacheCon US 2007 on PHP Best Practices.

Slides for DCPHP Conference 2007

The slides for Write Beautiful Code are now online.  (As I said before, basically the same as the Premium PHP slides, but I like this title better.)  The DC PHP conference is bigger than last year and I really like the venue.  I’m currently sitting in Eli White’s talk "Help!  My website has been hacked!  Now What?" which based on a great set of anecdotes about attacks on Digg.

DC PHP Conference

I’m headed to the DC PHP conference tomorrow to give a plenary session called "Write Beautiful Code".  This will be the same talk I gave at ZendCon which was pretty well received.  (I changed the title to something I thought more appropriate once the presentation was actually written.)

On Friday morning Luke and I will give our PHP Best Practices tutorial at the conference.

I see a good number of PHPers are already at the conference - I look forward to catching up with everybody there, although I will probably have my head in a laptop in between talking, got a lot on this week.  Fingers crossed for a decent network connection.

On Open Source: PHP Video Podcast

At OSCON this year Luke and I recorded a video podcast for Informit, talking mostly about the current state of PHP.  This is part of Informit’s podcast series On Open Source

Part 1
Part 2

I rant about frameworks, Luke talks about PHP security, and we offer advice for young programmers.  I hope you enjoy it, it was fun to record.

(As a note: I’m really really hyper in this.  It’s fear of people pointing cameras at me, and also the fact that I need to move when I talk - now you know why I have to walk around the stage when I’m talking at a conference - because if I have to sit down I am forced to wave my hands around and make faces like a crazy person in order to express myself adequately.)

I mention in the podcast not taking on any technology as a religion: I’m in the process of drafting a blog post, so watch this space for more on that topic.

PHP Best Practices at ApacheCon

Luke and I will be speaking on PHP Best Practices at ApacheCon on Tuesday November 13th in sunny downtown Atlanta.  This is a half day tutorial which we try to tailor to what people want to hear about on the day.  We’ll get into the nitty gritty of writing clean, fast, secure code.    ApacheCon is a great conference.  I’ve heard some murmurs recently that tech conferences are getting less technical.  The talks at ApacheCon tend towards the engineering heavy and the speakers are some of the best techies in the industry.  I hope some of you can join us! 

ZendCon Presentation slides

I’ve uploaded the slides for my presentation "Premium PHP" (PDF).  The conference seems well attended - good job Zend!

Headed to ZendCon

I’m headed to ZendCon tomorrow evening.  I get in pretty late Tuesday and will be at the conference all day Wednesday and Wednesday night (and in at Mozilla HQ on Thursday).   My talk, "Premium PHP", is at 4pm on Wednesday the 10th.

Looks like some people in the PHP blogosphere are already having fun out there, so I look forward to catching up.  See you there!

Reports of my death…part 2.

Despite the universe’s best efforts!  News:

1.  On Saturday, yes, I did break a rib, and yes, I did get to go to trauma via helicopter.  It’s really not that serious, I just have impressive bruises and am walking kind of slow.  (I was out of the hospital within about 2 hours, so really not that serious.)

2.  On Monday I started my new job, working for Mozilla Corporation.  It’s a great deal of fun so far and everyone has been really nice.  I’m excited to take up a whole bunch of new challenges.

3.  I’ll be speaking at the Zend Conference on Wednesday October 10th on the topic of "Premium PHP".

Luke Welling makes hotlist

This was pointed out to me.  I’m happy to note my husband, co-author, and partner in crime Luke Welling is apparently one of the top 8 "sexilicious bloggers"  on the Internet.  (I also note my friend and former colleague Chris Shiflett and another contact from the web 2.0 world, Aaron Brazell, made the list.)  Congrats fellas, enjoy your notoriety.

Do all frameworks really suck?

Ahem.  So anybody that’s known me for a while has likely heard me say something similar to what is quoted in Cal’s article about OSCON.  I should clarify because I hear jokes about "Tell us what you really think".

Choosing a framework to implement your web app is a trade off like any other design decision.  Let’s focus in on specifics and talk about what the trade off is that you make when you choose a framework.  Specifically, I’m talking about MVC frameworks in PHP.

Good things

  • Frameworks provide a common method of code organization, so developers can both a) get up to speed fast, and b) don’t have to think hard about how to architect an app.  They are effectively a standard for application architecture.  This is particularly useful when working with large dev teams or junior devs.
  • Frameworks encourage the separation of the presentation layer from the business logic, avoiding a frequent PHP worst practice where stuff is all mixed in together.
  • A framework can encourage secure coding through the use of dispatch architectures.
  • In general, frameworks avoid spaghetti coding.

Bad things

  • MVC is a design pattern.  As frequently mentioned by the good ol’ Gang of Four, every implementation of a design pattern is different, depending on the specific viewpoint of the implementor, and the specific application we are trying to produce.  This causes two problems.  One is that the implementor’s viewpoint is not necessarily the same as mine.  The second is that trying to shoehorn every app into the MVC structure isn’t always appropriate.
  • Most MVC frameworks have an intentionally flat design - models, views, controllers - and when codebases grow, you need to modularize for maintainability.  There are different ways to do this, but many frameworks don’t lend themselves well to this.
  • In the world of PHP, as with Perl, there is More Than One Way To Do It.  Specifically with frameworks, I believe Luke has been known to say there are 2.3 frameworks per PHP developer.  They are like content management systems or blogging systems.  We’ve all done it, sad to say.  The downside of this is that you lose a lot of the programmer speedup if programmers have to learn a new framework on every project.
  • Bloat is a problem in a lot of frameworks.  That’s what "makes the magic happen", but typically using a framework means lots of files getting opened (required/included) behind the scenes.  This slows down your app.  See for example Paul M. Jones’ (updated) benchmarks.  (That, by the way, is an excellent, excellent article that displays a good methodology for researching design decisions.)  I’ll also refer here to what I sometimes jokingly call Thomson’s first rule of software design: First, do the simplest thing that could possibly work.
  • It’s virtually impossible to retrofit an MVC framework on to existing code.  A lot of us spend most of our careers dealing with existing applications.

In summary:
Let’s be clear here: I am not recommending people write spaghetti code, or that they embed HTML willy- nilly in their PHP.  My recommendation in making any kind of architectural decision is to know what tradeoffs you are making and make an educated decision.  It’s important to remember that you can follow some of the basic rules of MVC and get a good number of the benefits without the bloat.  It’s equally important to remember that there is more than one way to architect a web app.

I’ll try and blog in future about a couple of other related topics: MVC in Rails compared to MVC frameworks in PHP, and templating systems.  (Unlike frameworks, all templating systems really do suck ;) )