Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Book Review - Modern PHP: New Features and Good Practices
Mar 24, 2015 @ 11:29:28

On Slashdot today Michael Ross as posted a book review of Josh Lockhart's recently released O'Reilly book "Modern PHP".

In recent years, JavaScript has enjoyed a dramatic renaissance as it has been transformed from a browser scripting tool primarily used for special effects and form validation on web pages, to a substantial client-side programming language. Similarly, on the server side, after years as the target of criticism, the PHP computer programming language is seeing a revival, partly due to the addition of new capabilities, such as namespaces, traits, generators, closures, and components, among other improvements. PHP enthusiasts and detractors alike can learn more about these changes from the book Modern PHP: New Features and Good Practices, authored by Josh Lockhart.

In the rest of the review Michael provides an overview of the topics covered in the book and how it's divided up. He then covers each of these three sections, commenting on the contents and making a few recommendations for those not immediately familiar with the topics. He does point out that he felt there was some critical information missing on some topics that "would allow one to begin immediately applying that technique or resource to one's own coding." Overall, though, he found the book a good resource and recommends it to those looking for a source to learn about new trends and tools in PHP.

tagged: book review modernphp joshlockhart features practices

Link: http://books.slashdot.org/story/15/03/22/1447230/modern-php-new-features-and-good-practices

Worst practices
Sep 04, 2013 @ 11:35:52

In this recent post to Reddit.com, people have been sharing some of the "worst practices" they've seen during their PHP development (or may even be guilty of).

For shits and giggles some colleagues and I are trying to write the crappiest PHP script we can think of, using as many bad practices as we can find. Alas, it's much harder then we thought, because we all have been trained to not do stupid stuff.

Things on the list so far include:

  • Multiple class definitions in a single file
  • Saving passwords unhashed and unencrypted in a database
  • Using a global variable inside a class to get a database connection
  • One letter variables
  • Pointlessly setting the signup method to being static
  • Using GET or POST vars directly from user input
  • Mixing HTML and PHP like there's no tomorrow.
  • make liberal use of extract() after running 'SELECT *'
  • Define a custom exception class for each class and only throw it from that class.
  • Make sure your DB connection is a singleton.
  • Throw ugly constants everywhere

What are some of the worst things you've seen? Share them here.

tagged: worst practices opinion examples list

Link: http://www.reddit.com/r/PHP/comments/1lpgqk/worst_practices

Matt Frost:
Agent of Change: Part 2 Presentation
Feb 05, 2013 @ 09:20:35

Following up on his previous post about being an "agent of change" in your organization (work, open source project, etc) Matt Frost has posted his second part of the series focusing on the presentation of your ideas.

In Part 2 we're going to talk about presentation of the pitch you put together for this change. It's important that your pitch be well researched and in some regards provable, as the Agent of Change the responsibility lies with you to prove the value of your idea. As we touched on in Part 1, a well thought out plan is going to go a long way in breaking down the barriers that make change difficult to take hold.

He makes a strong point that you need to identify the problem you're trying to solve (and what solution you're wanting to propose) clearly before trying to present it to a listening audience. He recommends quantifying your solution in terms everyone can understand like "hours of work" or cost. He recommends coming up with a short "elevator pitch" version to entice and the longer version to fill in the gaps.

You've got slides, documentation, statistics and loads of other good information that is going to benefit your development process, sales people in particular are looking for that jewel that helps set your organization apart; you've got that jewel!
tagged: agent change series practices development presentation


Matt Frost:
Agent of Change: Part 1 Preparation
Jan 08, 2013 @ 09:57:35

Matt Frost has posted the first part of a series he's writing up about being an "Agent of Change" in your development organization with recommendations on how you can make changes for the better happen. In this first article, he looks at working up "the pitch" for new technology and practices.

We all to make changes that make our jobs easier, so if your change isn't meeting a need or helping to ease a pain point, it's probably not the right change. [...] Find something that makes your job harder or less enjoyable, there's a pretty good chance that you aren't the only one.

He recommends doing plenty of research before making your recommendations, especially if it's a "we should be doing, but don't know how to" kind of improvement. He uses test-driven development in his examples, with part of his pitch being that it reduces the number of bugs that make it into production.

When plans are well thought-out and researched, the element of risk that others perceive tends to dwindle. [...] It's not about pointing out the faults of others in the organization or assigning blame, it's about learning and making positive changes from the lessons you've learned.
tagged: agent change preparation series practices development


Jonas Hovgaard's Blog:
How I stopped writing awesome code
Jun 14, 2012 @ 11:55:21

In this recent post to his blog Jonas Hovgaard talks about how he "stopped writing awesome code" by dropping a few things from his usual development practices - like unit tests and interfaces.

If writing awesome code is using all the best practices I can find, writing interfaces, unit tests and using top notch IoC containers to control my repositories and services all over my application's different layers - Then I'm not writing awesome code at all! I've been that guy, the one writing the awesome code, but I stopped. I'm not awesome any more. Instead, I'm productive, I'm so damn productive!

He talks about how not writing unit tests (which "customers don't care about") gave him extra time to work on other code and how not using things like interfaces, ORMs and how he follows DRY, but only so far.

My personal result of doing all of this is productivity and better products. I can't tell if I did it all wrong, and that's why I'm writing better code now, but I truly believe that I'm not alone. In fact I think that most of us regular web developers, tend to do the same "mistakes" as I did.

The post has turned into flame bait and has pulled in lots of comments discussing his decisions and other sympathetic souls that feel the same way he does about some of the complexity of the "best practices" promoted in development today.

tagged: opinion development practices bestpractice unittest interface orm dry


PC World:
How Etsy.com Grows in a Unique Fashion
Apr 03, 2012 @ 09:08:08

Over on the PC World site, there's a new article posted about Etsy and its development practices and how it "grows in a unique fashion" because of them.

The Etsy staffers are also completely serious about their work, and these two features they share in common with their customer base, who are tying to earn side money, if not pay the rent, by designing the hand bags, walking sticks and hand-made chocolates that have made Etsy famous in the artisan and sustainable business scene. [...] The quality model for Etsy is cutting edge, but not unique. New developers are expected to push code to production on day one. That's not commit code, but push it to production.

The article gets into some of the technology they use there at Etsy (including NodeJS, Nagios and, of course, PHP), the atmosphere they try to maintain, how they do their code deployment and how they conform to various regulations, security and privacy concerns.

tagged: etsy growth developer practices interview


Ed Finkler's Blog:
The MicroPHP Manifesto
Jan 03, 2012 @ 10:46:40

Ed Finkler has put together what he calls the MicroPHP Manifesto, a call to arms for the PHP community to get "back to the basics" and focus more on things like good well-crafted code rather than extending out into "complex, verbose solutions."

The approach I've been taking lately is to start with as lightweight a foundation as possible, in the form of a "microframework." [...] For additional functionality, I pull in lightweight libraries that help me accomplish only the tasks I need. Clarity and brevity are my top considerations. My other big consideration is the commitment I make when I use code I didn't write.

He goes on to talk about difficulties finding lightweight libraries to suit his needs and gives some cloc benchmarks for the Symfony HttpKernel and the Slim and Epiphany microframeworks. The end of the post is the most important part - the manifesto itself...one he hopes will ring true with the development community. It includes things like:

  • "I am a PHP developer. I am not a Zend Framework or Symfony or CakePHP developer."
  • "I like building small things with simple purposes."
  • "I need to justify every piece of code I add to a project."
  • "I want to write code that's easily understood."

For more read the full post over on his blog.

tagged: manifesto opinion development practices


Nikita Popov's Blog:
Dec 28, 2011 @ 09:26:14

Nikita Popov talks about the SOLID coding practices and creates his own acronym for the complete opposite - STUPID (Singleon, Tight coupling, Untestable, Premature optimization, Indescriptive naming, Duplication).

Ever heard of SOLID code? Probably: It is a term describing a collection of design principles for “good code” that was coined by Robert C. Martin (aka “uncle bob”), our beloved evangelist of clean code. [...] So, why not approach the problem from the other side for once? Looking at what makes up bad code.

He goes through each part of his STUPID acronym and talks about how it can hurt your code and a few alternatives to help make your application more flexible and easier to maintain in the long run. He also mentions GRASP (General Responsibility Assignment Software Principles), another set of good practices to follow, some similar to SOLID, that can make your app better.

tagged: stupid solid grasp development practices opinion


Writing Better PHP: Three Guides
Dec 14, 2011 @ 11:15:32

On DZone.com today John Esposito has posted about three guides that want to help you improve your PHP development skills (including a forum post and two articles).

Sometimes, then, improving your generic 'programming brain' will help you improve your facility with a particular language. At other times, it's more important to learn the nuances of a language, paying close attention to the kind of applications the language is used for. [...] For improving your PHP, then, you can do two things: become a better programmer; and understand PHP more finely, more deeply.

The three guides share a lot of the same concepts in common - naming conventions, separation of functionality, DRY (don't repeat yourself), testing code, etc.

tagged: improve development practices skill guide


Exploring the software behind Facebook, the world’s largest site
Jun 22, 2010 @ 09:17:54

On pingdom.com there's a recent article posted looking at some of the technology behind Facebook and how they manage to keep up with the huge demand put on them and their servers.

At the scale that Facebook operates, a lot of traditional approaches to serving web content break down or simply aren’t practical. The challenge for Facebook’s engineers has been to keep the site up and running smoothly in spite of handling close to half a billion active users. This article takes a look at some of the software and techniques they use to accomplish that.

They have to be able to handle over 570 billion page views a month across over 30,000 servers so there's several key technologies than they use to help make this a reality. Besides the famous HipHop for PHP tool, they also use things like memcached, Cassandra, Hadoop and Varnish. There's also other non-tech specific practices they do to keep things flowing smoothly.

tagged: facebook technology practices software