It's my pleasure to announce the Member of the Month for April, 2013.
This month, the award goes to TomB, who has been a member of these forums for quite some time already. Tom's enthusiasm for and knowledge about the more "advanced" sides of PHP programming (OOP, design patterns, MVC) make his posts an interesting read.
We are really grateful for Tom’s contributions to the forums, and recently asked him a few questions so we could get to know him a little better.
Tom, congratulations on being awarded the MoTM badge for April. Were you surprised?
Thank you! Yes, I'm very surprised! Especially given how little I've posted in the last 6 months or so.
We always ask where the username comes from, although I have feeling that this time it might be your real name?
Unfortunately yes, there's no amusing or interesting story behind my username, it is just my real name. However, despite the obvious privacy implications, I was at university when I registered here and I figured it wouldn't hurt if future employers found me or I could even link them to my profile here so they can see my level of interest/knowledge first hand. I don't think it's really worked like that but I'm happy to post here under my real name! I'd happily point potential future employers to my profile here, I don't think I would if I had a cheesy alias!
You've been around these forums for a very long time, but maybe you still remember: what brought you to Sitepoint, what made you stay?
Looking back at my first post here, I remember exactly why I registered on the forums. I'd been a lurker for some time and used sitepoint.com as a learning resource quite extensively over the years. My first post was about registering .eu domains which were just about to launch at the time. During my time at university I made a little bit of cash on the side doing development work as well as buying/selling domain names. I was trying to purchase some premium .eu domains at launch and asked here about people's knowledge on the subject. I never did make much money on a .eu domain but shortly afterwards I sold di.gg which basically paid off my student loan!
I stuck around asking questions as my programming ability improved. I mostly lurked around the now long gone PHP Application Design forum as it was a nice archive of discussions on advanced topics. For the most part I was a lurker but I discovered the best way to improve my own knowledge was posting there and then having the intellectual heavyweights that posted there shoot me down and tell me what I was doing wrong as well as slowly developing my own ability to answer questions there constructively. You'll still most likely see me pop up in threads discussing best practices or OOP theory.
Looking at your blog, your signature and your activity in these forums, PHP in general, and MVC in particular seems to be a very big part of your life/passion, can you tell us what got you interested, where it all began?
I've been programming in PHP since late 1999 and have been working as a professional PHP developer since I left university 6 years ago. I work with it every day so I've hit every possible gotcha from PHP bugs, to poorly designed code from others and my own where I've gone back and thought "Why did I do it like that?" I've learnt the hard way but I enjoy the self-improvement aspect of learning and genuinely being able see my code improve over time.
On MVC in particular, funnily enough, it was discussions on sitepoint which got me interested that, design patterns and the more advanced topics. I had looked at CakePHP and the other popular frameworks of the time and I always found myself thinking "There must be a better way to do this." After a lot of research into software architectures I learned that what I and everyone else in the PHP community was calling MVC wasn't MVC at all and realised that there was a much better way. After several long discussions on here where I found myself making the same points repeatedly, I condensed everything into a few posts on my blog to save repeating myself every time the topic arose.
There seems to be a lot of confusion around PAC versus MVC, would you say either are worthwhile to a developer regardless of the differences between them? Is it worthwhile for a developer to truly understand which they are using if the abstraction occurs making their development more flexible?
My biggest issue with this scenario is that we have two different architectures sharing the same name. Irrespective of any benefits of one over the other, this causes confusion for anyone attempting to look up the definition and hurts the community as a whole. Separating the components in any non-trivial application is vital. It makes your code flexible and easier to maintain. Choosing how to split up the various components and how they relate plays a very large part in how flexible and maintainable the end-product is. Code is split up solely to make it easier for the developer to manage, neither the computer or the end user care if you're using MVC, PAC or a single 10,000 line file that just gets processed line by line. As such, it's in the developer's own interest to make their code as flexible and easy to work with as possible. We've all worked with horrible code, it's not an enjoyable task.
In terms of PAC vs MVC specifically, most PHP developers default setting is PAC (Which has been wrongly labelled as MVC throughout the community) because it's just a way of joining an entry point, a template system and a database layer. Components which have been around years before the term "MVC" was being thrown around the PHP community. I can see why this is a logical progression but with progressive learning like this, it's difficult for people to take a step back to the beginning and think about exactly what it is they're trying to achieve. It's hard for anyone to realise there's a better way because they have a complete understanding of current methods and very little of any others making any comparison very difficult in people's minds. Nobody has really chosen to use what they call "MVC", it's just something which we ended up with as PHP developers. My question to anyone who's using what the frameworks call "MVC" is: How do you know you made the correct choice if you never made a choice?
What are some of your biggest irks with PHP and do you know how you would correct them?
Although there are many things PHP does well, there are some things it does badly. I have to look up the parameter order for strpos() every time I use it because it's the opposite order to most of the other functions. As well as inconsistent function names, htmlentities() and html_entity_decode(), nl2br() and strtolower(), etc. And whoever decided the parameter order for mktime() deserves to be shot, there's no sense of logic to it at all.
But these are all fairly trivial in the grand scheme of things. Most of my irks aren't with PHP itself, it's with the way the PHP community use it. There have always been fad-of-the month trends/buzzwords among the high end/professional level PHP Developers over the years. Database abstraction, template systems, using mysqli instead of mysql, the singleton pattern, MVC, using pdo instead of mysqli, Dependency Injection, Unit Testing. Some of them come and go, some of them stuck around, some, like the singleton pattern, we're regretting to this day. Currently, there's a growing trend for using Annotations for configuration. This is easily the worst trend to hit PHP applications since the singleton pattern and something we as a community are going to regret for years to come. I won't go into detail here but I've covered it extensively on my blog. Let's put a stop to it before it hurts the entire community.
With the ever growing number of new PHP developers what advice would you give them so they get off the ground in the right direction?
There are hundreds of ways to solve any problem. Some solutions are better than others. When starting out you just want something that works. However, once you begin realising "this can be done better" you quickly realise that programming is more of an art than a science. As such, my biggest tip for anyone is that when you look up how to do something is always to look for reasoning behind the decisions made. If the tutorial writer has only provided "how" but not "why", firstly you won't learn very much but more importantly, their reasoning may not be sound. Look for tutorials and articles which provide a level of discussion "This method is chosen because..." rather than just "Here's how it's done". The "Here's how it's done" article might give you some working code but it may also be teaching you bad habits or outdated practices. Secondly, as a rule of thumb, newer is better. Things change, the language evolves and best practices change over time. If you see two articles covering the same topic, one from 2011 and one from 2001, pick the one from 2011, it's almost certainly going to be more relevant today. We still get posts in the PHP forum where people are using the now very out of date mysql_* functions because of this.
If you could change one thing about SitePoint Forums ... what would you change?
The admins will probably hate me for saying this but I'd bring back the PHP Application Design forum. Even though it was rarely used it was still very useful to me to have an archive of discussions on advanced topics easily accessible in one place. I learnt more from lurking in there than I did from any book or online tutorial and because it was its own forum I could very easily just go through a long list of old topics which contained excellent information. A lot of very intelligent people posted in that forum over the years and the discussions that took place there are still relevant to programmers today.
This is your chance at blatant self promotion. Is there anything that you would like to promote?
For a change, yes! I don't often release code because either it would take too much support or there are a thousand other projects doing a similar thing. However, I recently released Dice ( http://r.je/dice.html ), a Dependency Injection Container for PHP. It's different from the others that are around because it focuses on minimising the configuration needed by the application developer. I've been developing it while using it in my own projects for the last 3 years and it has really helped me take a whole new approach to the way I look at dependencies in code. It's made my life as a programmer a hell of a lot easier and it's mature enough that it's very stable and it really does fill an otherwise empty niche so I thought I'd share it with the world. So, to all the PHP developers out there, give it a try, I'm sure you won't look back!
Is there anything that hasn't been asked that you would like the Sitepoint community to know?
Only thank you to everyone for being part of the community. I've learnt so much from discussions here on the forums, both topics I've participated in and ones I've lurked around and read. I certainly wouldn't be half as good a programmer as I am if I hadn't ever joined sitepoint. Thank you all, special thanks to the old posters from the PHP Application Design forum!
Well, if you made it this far, please join me in congratulating Tom with his well deserved award