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

S.O.L.I.D: The First 5 Principles of Object Oriented Design
Mar 19, 2015 @ 10:30:47

On Scotch.io today they've posted a tutorial about SOLID, the "first five principles of object oriented design". SOLID is an acronym made from the first letter of several principles that can help make your OOP code well-architected and easier to test.

S.O.L.I.D is an acronym for the first five object-oriented design(OOD) principles by Robert C. Martin, popularly known as Uncle Bob. These principles, when combined together, make it easy for a programmer to develop software that are easy to maintain and extend. They also make it easy for developers to avoid code smells, easily refactor code, and are also a part of the agile or adaptive software development. Note: this is just a simple “welcome to S.O.L.I.D” article, it simply sheds light on what S.O.L.I.D is.

They start with a basic overview of what the letters in SOLID stand for and then work through each, providing basic code examples to help make the point clearer.

tagged: solid oop design principles introduction objectoriented

Link: https://scotch.io/bar-talk/s-o-l-i-d-the-first-five-principles-of-object-oriented-design

Three Devs & A Maybe Podcast:
Episode #56: The SOLID Podcast
Jan 29, 2015 @ 12:20:03

In the latest show from the Three Devs & A Maybe podcast hosts Michael Budd, Fraser Hart, Lewis Cains and Edd Mann talk about a wide range of topics with a focus on the SOLID development principles.

This week we have a three developer podcast with discussion on a host of topics. We kick off with how Fraser has enjoyed building his first bonus slot game, written entirely in JavaScript and HTML5. Preprocessors are a huge part of the JavaScript ecosystem at this time, with so many to choose from we discuss a couple of the more popular ones. This leads on to Photoshop discussion, ReactJS, the cool features present in ES6 and how you can use them today with transpilers. Following this we move on to the SOLID principles, the overuse of inheritance, technical debt and the concept of Over-DRY vs. Software Value. This then takes us on to a strange 'rubber duck' example Edd conjured up to help try and explain the Liskov substitution and Interface segregation principles. Finally, we discuss Edd's media server setup and how he has got it to a staged that he is finally happy with it.

Other topics include things like:

You can listen to the latest show either through the in-page audio player or by downloading the mp3 of the episode. Also, be sure to subscribe to their feed of you enjoy the show!

tagged: threedevsandamaybe podcast ep56 solid development principles

Link: http://threedevsandamaybe.com/the-solid-podcast/

Clean Architecture
Dec 23, 2014 @ 10:37:28

In an article on Thedo.fr Tristan Roussel introduces you to some of the concepts behind Clean Architecture based on a talk he recently attended at a local Symfony user group.

One particular talk retained my attention and I want to tell you about it. Let me warn you first, this is just an introduction, and I’m not going into much detail, don’t hesitate to post comments if you feel something is not clear, or deserves a better exposure! [...] So. What is Clean Architecture? It’s so fresh that it doesn’t even have a Wikipedia article.

He starts off with what the idea of Clean Architecture is trying to accomplish and where some of the ideas have evolved from. He includes some of the objectives and guiding principles as well as a diagram of how this architecture might be laid out. He gets into an actual use case for this type of structure and where abstract entities, controllers and presenters fit into the picture. He links to some of the code as provided as part of the presentation and some of the things to consider when trying it out for your application.

tagged: clean architecture introduction presentation principles objectives usecase

Link: http://www.theodo.fr/blog/2014/12/sfpot-paris-2014-12-12-pepiniere-27/

Matthias Noback:
Packages: the case for clones
Nov 17, 2014 @ 11:55:21

In a new post to his site Mattias Noback makes a case for clones (in response to this post from Phil Sturgeon). In it he defends the creation of "clones" of tools, either slightly different version of pre-existing PHP packages or the functionality from a package in another language.

There is this ongoing discussion in the PHP community (and I guess in every software-related community) about reinventing wheels. A refreshing angle in this debate came from an article by Phil Sturgeon pointing to the high number of "duplicate" packages available on Packagist. I agree with Phil. [...] It doesn't make sense to do the same thing over and over again. At least I personally don't try to make this mistake. If I want to write code that "already exists", at least I don't publish it on Packagist. However, recently I got myself into the business of "recreating stuff" myself.

He talks some about one of his own projects (SumpleBus) and how, despite it possibly being a clone of other packages, it has slightly different goals than other tools, making it a different tool, not just a straight up clone. He also covers some of the package design principles he suggests in his book and how they can help to make an isolated package better. He also points out how recent PHP-FIG efforts to define common interfaces and structures can help reduce this kind of package duplication as well by reducing the possible implementations of any given process.

tagged: package reinvent wheel opinion duplication design principles phpfig clone

Link: http://php-and-symfony.matthiasnoback.nl/2014/11/packages-the-case-for-clones/

Gonzalo Ayuso:
Talk about SOLID and Symfony at the deSymfony 2014 conference.
Jun 03, 2014 @ 09:23:21

Gonzalo Ayuso has posted a wrapup and the slides from his SOLID presentation at this year's deSymfony conference recently held in Barcelona, Spain.

Last saturday I attended to the deSymfony conference in Barcelona. A great opportunity to meet again with the PHP and Symfony community in Spain. This year the conference accepted my talk about SOLID and Symfony. Here you can see the slides of the talk (slides in spanish). [...] The conference was perfect. Barcelona is an incredible city and the conference place (10 minutes walking from the Sagrada Familia), was incredible too. Great talks. But the best, as always, the coffe breaks with the conversations with the Symfony and PHP community from Valencia, Zaragoza, Madrid, Barcelona, ...

His talk (in Spanish) covers some of the basics around the SOLID design principles including definitions of each piece and brief code snippets to illustrate. If you're interested in a bit more detail around the SOLID principles in PHP, check out the first four parts of a series over on NetTuts.com for each principle: Single Responsibility, Open/Closed, Liskov Substitution & Interface Segregation and Dependency Inversion principles.

tagged: solid design principles desymfony14 conference barcelona spain

Link: http://gonzalo123.com/2014/06/01/talk-about-solid-and-symfony-at-the-desymfony-2014-conference/

SOLID: Part 3 - Liskov Substitution & Interface Segregation Principles
Jan 27, 2014 @ 11:51:30

On NetTuts.com today they've continued their series covering the SOLID development principles with the next letter in the acronym - "L". It stands for the Liskov Substitution & Interface Segregation Principles. The tutorial also talks some about the "Interface Segregation Principle" as they go hand-in-hand.

The concept of this principle was introduced by Barbara Liskov in a 1987 conference keynote and later published in a paper together with Jannette Wing in 1994. Their original definition is as follows: "Let q(x) be a property provable about objects x of type T. Then q(y) should be provable for objects y of type S where S is a subtype of T." [or more simply] "Subtypes must be substitutable for their base types."

They include some example PHP code showing a base "Vehicle" class and first an example of doing it correctly (with the Template design pattern) and an example of an incorrect method, complete with tests. They then get into the Interface Segregation Principle, an interface that can be depended on to use the module, with the same car-related examples.

tagged: solid design principles liskov substitution interface segregation

Link: http://net.tutsplus.com/tutorials/php/solid-part-3-liskov-substitution-interface-segregation-principles/

SOLID: Part 2 – The Open/Closed Principle
Jan 21, 2014 @ 12:45:29

On NetTuts.com today they continue their look at the SOLID development principles with the next letter in the sequence - O for Open/Closed Principle. The first part of the series, covering "S" (the Single Responsibility Principle) can be found here.

The Open/Closed Principle, OCP in short, is credited to Bertrand Mayer, a French programmer, who first published it in his book Object-Oriented Software Construction in 1988. The principle rose in popularity in the early 2000s when it became one of the SOLID principles defined by Robert C. Martin in his book Agile Software Development, Principles, Patterns, and Practices and later republished in the C# version of the book Agile Principles, Patterns, and Practices in C#. What we are basically talking about here is to design our modules, classes and functions in a way that when a new functionality is needed, we should not modify our existing code but rather write new code that will be used by existing code.

They start with a look at OCP in the overall SOLID context and an example of an obvious violation of the principle. Some example code is provided showing a "Progress" class that's bound to at "File" implementation, not abstracted. They offer three different options for solving the issue:

  • Take Advantage of the Dynamic Nature of PHP
  • Use the Strategy Design Pattern
  • Use the Template Method Design Pattern

Each of the above comes with example code and some with illustrations of the structure they create.

tagged: solid design principles open closed tutorial introduction

Link: http://net.tutsplus.com/tutorials/php/solid-part-2-the-openclosed-principle

SOLID: Part 1 - The Single Responsibility Principle
Dec 16, 2013 @ 13:10:55

NetTuts.com kicks off a new series of posts today with this first article covering the SOLID development practices. SOLID is a set of principles that can help make your code more robust and well structured in the long run. In this first post they jump right in with the first letter - "S" for Single Responsibility Principle.

[The Single Responsibility Principle] is one of the five SOLID agile principles. What it states is very simple, however achieving that simplicity can be very tricky. A class should have only one reason to change. But why? Why is it so important to have only one reason for change? [...] Even though you may not use a compiled language, you may need to retest the same class or module for different reasons. This means more QA work, time, and effort.

They go on to talk about how to figure out the "audience" for your class and how that effects what it should contain. A few "class examples" are shared in the post including objects that can print or save themselves. There's a bit of talk about software design ideas to consider and a less obvious example that might be breaking the principle (and how to fix it).

tagged: solid design principles single responsibility principle

Link: http://net.tutsplus.com/tutorials/php/solid-part-1-the-single-responsibility-principle/

Evolving code
Nov 01, 2013 @ 13:28:06

On Reddit.com today timoh has posted a "brief look back" at PHP's evolution to be "enterprise ready" and looks towards the future with some speculations as to what the coming years will bring to the language and its community.

I'm trying to evoke some disqussion about how we have come to the current point of life we have now going on in the PHP field, as an architectural decisions, design and best practices we use to build PHP based software today. [...] Of course PHP language itself has put some walls to design the software the way one would have liked, but still there are alot that could have been done better even "back in the days". At least "better" in a sense what it means today.

He points out that in recent years there's been a push in the community as a whole for things like SOLID/DRY principles, decoupled code and testing. He speculates about the future of things like the Symfony and Zend Frameworks (and the radical changes they both made from their version one to version two). Have your own thoughts about the evolution of PHP and where it might be headed? Share them here!

tagged: evolution code community principles symfony zendframework

Link: http://www.reddit.com/r/PHP/comments/1pofu1/evolving_code/

Ben Youngblood:
MVC Is Not Enough
Sep 04, 2013 @ 09:12:25

Ben Youngblood has a new post to his site suggesting that MVC is not enough to build good, robust applications (PHP or not) just because a good portion of the frameworks implement it.

With few exceptions, any software engineer worth his/her salt have at least heard of the model-view-controller pattern. It’s been around since it was introduced to Smalltalk in the late 1970s and has been a staple pattern in object-oriented languages for as many years. Nearly all the leading PHP frameworks include some form of MVC implementation. With so many frameworks and developers espousing its use, you would think it’s the best pattern for building your application. And you would be wrong.

He's not suggesting abandoning MVC altogether for something else. He just wants a reexamination of how it's being used and how to improve the structure of the applications using it. One option is to adhere more to the SOLID principles, avoiding things like domain logic in controllers and "fat" models with too much logic.

Chiefly, MVC is one part of your application, not your application. If you find that you are building your domain logic inside models, views, or controllers, then you are abusing MVC. No substantive application can, or should, be made to fit inside MVC.
tagged: mvc opinion solid principles improvement

Link: http://blog.bjyoungblood.com/2013/08/21/mvc-is-not-enough