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

ThePHP.cc:
Why Developers Should Not Code
Jul 19, 2017 @ 11:16:01

On thePHP.cc blog Stefan Priebsch offers up an interesting opinion about code, developers and understanding - developers shouldn't code.

The ultimate problem with program code seems to be that no human really understands it. Sure, we can look at a short piece of code and be relatively clear on what it does, but can we still do the same thing with programs that span tens or even hundreds of thousands of lines?

[...] Well, sometimes I get a strong feeling that there is a shortage of good programmers, because I often find myself looking at legacy code, being unable to tell what it does, at least with reasonable certainty. [...] Personally, I already consider code to be problematic when there is a reasonable amount of doubt as to what it does (and why it exists). To me, uncertainty and discussions are a sure sign of bad code. Call me picky, but years of experience have taught me that this level of strictness makes sense.

He suggests that the fact a developer cannot recognize what current code is doing doesn't make you a poor developer, but the opposite. He talks some about the meaning of the word "code" and how it is written for a machine to understand, not a human. He ends the post talking about testing your code to provide an "executable specification" and, despite having this, a human-readable spec is still a requirement (like it or not).

tagged: developer code opinion specification testing

Link: https://thephp.cc/news/2017/07/why-developers-should-not-code

Hackermoon.com:
Why you should learn Symfony in 2017
Jul 18, 2017 @ 12:39:09

On the Hackermoon site there's a new post from developer advocate Mickaël Andrieu sharing a few reasons why he thinks you should learn Symfony in 2017 if you haven't already.

In 2011, when I started my studies in computer sciences I learned the PHP using symfony 1.3, and I realized my very first student project on the beta of Symfony 2. At the time, we were moving from a fully integrated full stack framework with a back office provided to a framework that followed what was found in the Java community: besides, many components of Symfony2 were strongly inspired by JEE.

PHP 5.3 had just come out and with it the ability to start designing object-oriented correctly. [...] Large Open Source projects have started to migrate on Symfony components: if it was not first, SensioLabs has talked a lot about Drupal8 because it is one of the biggest CMS on the market. EzPublish, PHPBB, PrestaShop and many others followed, some with a full stack framework approach and others by incorporating only a few software bricks.

He then talks about the "vibrant and mature ecosystem", listing some of the packages that use Symfony components. He also looks forward to the next major iteration of the framework: Symfony Flex. He ends with his reasoning why you should learn Symfony if you haven't worked with it (or at least how it handles common things like requests and services).

tagged: learn symfony framework ecosystem future symfonyflex opinion

Link: https://hackernoon.com/why-you-should-learn-symfony-in-2017-e0cf564f0b21

Jason McCreary:
You changed the code, you didn't refactor the code.
Jul 13, 2017 @ 11:16:27

Jason McCreary has a post with an interesting perspective about code refactoring and what it means to refactor. He suggests that just changing code isn't refactoring and that it's more about changes in the observable behavior.

There was a good discussion on Twitter yesterday regarding a code contribution to the Laravel framework. It ended with some good questions about the distinctions between “refactoring” vs “changing” code.

While I want to focus on these distinctions, let’s first focus on the code change.

He gives an example of some code from the suggested change that reduced the number of lines in a before function call that still satisfied the requirements defined by the unit tests. He suggests that, while this change allowed the method to work as expected, it was more of a "change" than a "refactor". He suggests that because the code internal to the method changed that the "observable behavior" changed because of a special case with the return value. Existing tests didn't catch the change so it was assumed the refactor was successful even when it wasn't. Adding this test and fixing the issue then resulted in a true refactor and not just a change.

Given the symbiotic relationship between refactoring and testing, some consider the tests to be the requirements. So if all tests pass, you met the requirements. I think that’s a slippery slope. For me, the definition of “refactoring” again provides the answer through its own question - did we change the observable behavior?
tagged: code change refactor opinion unittest patch laravel

Link: https://jason.pureconcepts.net/2017/07/refactor-vs-change-code/

TutsPlus.com:
Should You Use a PHP Framework? Five Pros and Cons
Jul 12, 2017 @ 10:22:33

On the TutsPlus.com site today they've posted an opinion article that tries to help answer the question "Should You Use a PHP Framework?". They provide their own list of top five pros and cons, representing each side and hopefully getting you thinking about your own project.

From routing HTTP requests to accessing the database and rendering the user interface, most web applications have a lot in common with each other. Many of them allow their visitors to sign in, and it's hard to imagine a web application without email sending. A software framework is a way to put this observation into use.

But is using a framework always the best way to go, or does it sometimes make sense just to start from scratch using nothing but plain PHP? To answer the question, in this tutorial, we will look at five pros and cons of using a PHP framework.

Items under their "pros" list include how they allow for more rapid development, easier maintenance in the future and the support of the community around the project. Their "cons" list talks about topics like the more general approach most frameworks take, the lower level of performance vs just PHP and the limited visibility into how the core framework works where it's not supposed to be customized.

tagged: framework opinion pro con list top5 reasons

Link: https://code.tutsplus.com/tutorials/should-you-use-a-php-framework-five-pros-and-cons--cms-28905

Stefan Koopmanschap:
A list of podcasts
Jul 05, 2017 @ 09:12:57

Stefan Koopmanschap has a new post to his site sharing a list of podcasts he enjoys and thought you might too.

I had sitting in travel not being able to do anything. Listening to music can help, but can end up also being frustrating. While I was working at Schiphol last year I got pointed to podcasts. Since then I've been really getting into listening to podcasts on my daily commute and it's been making the trip a lot more fun... and useful.

Here is a random collection of podcasts that I've been listening to in the past year and a half, on many different subjects. My main problem right now is that it's so many that I'm way behind on the episodes of most of these. Ah well, it's still quite good content.

Technology-related shows in the list include /dev/hell, Sound of Symfony and Voices of the ElePHPant. Others relate to topics like "justice, true crime, wrongful convictions etc", video games and a few Dutch language technology podcasts.

tagged: podcast list opinion technology justice dutch

Link: https://leftontheweb.com/blog/2017/07/01/a-list-of-podcasts/

Stitcher.io Blog:
A programmer's cognitive load
Jul 03, 2017 @ 12:23:49

On the Stitcher.io blog there's a new article posted about a programmer's cognitive load and offers some tips to help reduce it, especially when reading code that's new to you.

Whether it's your own code or that of others, when you open a file, you have to take it all in. You need to wrap your head around what's going on, before you're able to write your code. Doing this day by day, it's important to find ways to make this process easy. To try and reduce this cognitive load as much as possible. Streamlining the way you take in code, will allow you to not only work faster and better; but also improve your mental state and mood.

[...] Today I want to share some techniques that can help you reduce this cognitive load while coding. In contrast to some recent advocates of "visual debt", I won't talk about stripping away pieces of your codebase. We'll look purely into the visual aspect: what makes code hard to read and reason about, and how to make it easier.

The tips they article make use of some of the most common features of IDE including adjusting fonts and spacing, using code folding to reduce visual noise and effective naming. Each point has either screenshots or code examples to help illustrate the point.

tagged: programmer cognitive load opinion advice

Link: https://www.stitcher.io/blog/a-programmers-cognitive-load

Josh Lockhart:
Advice For Aspiring PHP Developers
Jun 30, 2017 @ 09:18:09

On his site Josh Lockhart, author of Modern PHP and the Slim framework has shared advice for aspiring PHP developers, mainly centering around one core idea.

As a fledgling PHP developer, I aspired to be in the same league as legendary figures like Cal Evans, Chris Hartjes, Larry Garfield, Anthony Ferrara, Paul Jones, Sebastian Bergmann, Taylor Otwell, et al. I consider these folks members of PHP's inner sanctum, so to speak. They are decision makers, tool builders, and opinion shapers.

[...] My advice to aspiring PHP developers: there is no great Wizard of OZ. There are only opinionated men and women behind a veil of authority who bicker of politics and standards. It's not magical. It's messy. It's a minefield of polarizing politics, sensitivities, and opinions.

He points out that, no matter why you say or do, there'll always be someone that will take it the wrong way - it's just human nature. He uses a recent example of an interaction he had with another member of the PHP community around contributor guidelines on a project.

Aspiring PHP developers, stay above the fray. Don't seek out a Wizard of OZ. He does not exist. PHP's inner sanctum isn't worth your time. Instead, do your research, recognize and avoid propaganda, and trailblaze your own path.
tagged: advice aspiring developers community experience opinion

Link: https://joshlockhart.com/blog/2017/6/advice-for-aspiring-php-developers

Frederick Vanbrabant:
The Broken Windows Theory or "Why Some Projects are Just Destined to Suck"
Jun 20, 2017 @ 09:15:40

Frederick Vanbrabant has posted an interesting article to his site covering the "broken windows" theory, what it is and how it shows that some projects are just destined to suck.

Why is it that most legacy software projects are not really fun to work on? How can we stop that greenfield project to turn into one of those dull big projects? I would argue that it’s all in the foundation.

He starts with a brief description of the "broken windows" theory based on the 1982 definition proposed by James Q. Wilson and George L. Kellin. Basically it states that all it takes is one "broken window" to change the perceived value of something, even if it's a small thing. He then gets down to the code level and relates it back to some examples from the Slim framework project. In his examples he shows how it might look after a refactor and how removing best practices makes it harder to understand (breaking windows). To help prevent it, he recommends following the Boy Scout rule of leaving the code better than you found it and using automation to help find and fix the issues.

tagged: brokenwindows theory software development perceived value opinion

Link: http://frederickvanbrabant.com/2017/06/12/broken-windows-theory.html

Marco Pivetta:
Eliminating Visual Debt
Jun 05, 2017 @ 16:53:12

In a new post to his site Marco Pivetta talks about "visual debt" in your code. "Visual debt" is described in this video as the difficulty in understanding caused by complicated code.

Today we're talking about Visual debt in our code.

As an introduction, I suggest to watch this short tutorial about visual debt by @jeffrey_way. The concept is simple: let's take the example from Laracasts and re-visit the steps taken to remove visual debt.

The code example the post starts with, while a working piece of code, leans towards being more complex than necessary to complete the task. Marco spends the rest of the post walking you through the simplification of this code. He shows how to remove pieces that aren't as necessary, refactor it to remove the enforcement of contracts and some further things you can do to simplify the code.

He ends the post by saying that his suggestions are all sarcasm on his part and shouldn't be followed. By removing things like return type hinting and functionality that enforces good behavior you risk odd issues and poor usage down the line.

tagged: visual debt elimination sarcasm opinion

Link: https://ocramius.github.io/blog/eliminating-visual-debt/

thePHP.cc:
Testing Keeps Me From Getting Things Done
May 25, 2017 @ 09:52:29

On thePHP.cc site they have a new post that tries to refute a common claim from developers when it comes to testing: testing keeps me from getting things done. The post is a response to an email to the group about testing asking where the real value is in applications versus libraries/tools.

To successfully develop software means to work target-oriented. These targets should be derived from acceptance criteria that are reconciled with the business. Without clear targets – we mean at a task level, not project or annual targets – the developer runs the risk of getting lost in work. Most importantly, he does not know when he is done with a task.

It is prudent to document and verify acceptance criteria through automated tests. One way or another, the targets have to be defined before production code gets written. This is test-driven development, whether you want to call it that or not.

The response goes on to talk about how, with tests written after the code has already been written (legacy code), it's not always clear what the original intent was resulting in lost context. It also compares two of the main types of testing - integration and unit - and the place each has in an overall testing strategy.

tagged: testing unittest reply integration opinion application

Link: https://thephp.cc/news/2017/05/testing-keeps-me-from-getting-things-done