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

Stefan Koopmanschap:
Your unit test methods need docblocks too
Oct 12, 2017 @ 16:48:02

In a post on his site Stefan Koopmanschap suggests something that, while not as commonly done as writing docblocks for the actual code, could help with a better understanding of the application's tests: writing docblocks on tests too.

If you've met me at any time in the previous 20 years and you discussed unit testing with me, chances are pretty big that I'd have told you that your test methods in your unit tests don't really need docblocks, because the test methods would be named in such a way that they were descriptive.

[...] Tests can be hard to real though, especially (but not exclusively) when testing legacy code. You may have lots of mocks to configure, for instance, or you may have several similar tests that are testing specific situations, edge cases or bugs you found along the way that you wanted to test before you them.

[...] Documentation is important. It lowers the bus factor, makes it easier to on-board new developers (or temporary external developers, waves) and makes you think about your own code in a different way. We're (getting?) used to documenting our software, but why not document our tests by giving it a bit more context?

He starts by talking about his process for testing (outline the desired tests then fill them in) and how adding docblocks helped him avoid a "nonsensical" test that wouldn't have provided much value. He then briefly discusses what would be useful to document in the test docblocks and provides some examples to illustrate. Finally he suggests something called "Docblock Driven Testing" where the docblock descriptions help to define what is to be tested and help to make more human-readable sense of what can be tested effectively.

tagged: unittest method docblock opinion testing definition

Link: https://leftontheweb.com/blog/2017/10/11/your_unit_test_methods_need_docblocks_too/

SitePoint PHP Blog:
Being a Full Stack Developer (Update)
Jun 19, 2017 @ 17:57:37

The SitePoint PHP blog has made an update to their "Being a Full Stack Developer" article covering what it means to be "full stack" and various technologies that can be used (or skills to learn) to get there.

A full stack developer who can get from a prototype to full MVP (minimum viable product) is often considered a jack of all trades, master of none, and with good reason. To define the modern full stack developer, we first need to focus on what the full stack developer used to be.

The article talks about what it use to mean (back around the early 2000s) to be "full stack" and some of the things they needed to know. He then goes through the things you'll need to know now to be considered basically on the same level:

  • [Basic] Server Admin / Devops
  • Cloud [Services]
  • Back End [Development]
  • Front End [Development]
  • Design
  • Logging
  • Mobile

He ends the post by answering the question "is it worth it" to be a full stack developer versus focused on one thing, basically boiling down to two things. First, that most devs aren't actually full stack (even if they say they are) and that it can help to have this experience to, at the least, be able to approach a wide range of projects easier.

tagged: fullstack developer definition recommendation technology learn

Link: https://www.sitepoint.com/full-stack-developer/

SitePoint PHP Blog:
PDS Skeleton by Example: A Standard for File and Folder Structure
May 15, 2017 @ 16:56:29

The SitePoint PHP blog has a tutorial posted by Younes Rafie introducing the php-pds/skelecton package definition and how it can be used to provide some structure and consistency across your package development.

Looking at the Packagist registry, we can see that most packages follow a pattern, with some small changes to fit their needs, while others have a weird folder structure that takes time to get your head around.

This problem has been solved in different ways by different people. Some frameworks have their own recommendations on how to structure your classes and assets, while others have a skeleton that you can use as a starting point. In this article, we’re going to explore the php-pds/skeleton and use it to build a small package as a demonstration.

He then uses a Laravel package example to show the build up of the package structure (based on the pds/skeleton definition). He goes through each portion of the skeleton structure talking about what they should contain:

  • config
  • resources
  • source files
  • tests
  • the "public" directory
  • bin/ folder
  • documentation
  • other files like README and LICENSE documents

He also suggests including a guide to contributing to the package and how to use the "validate" command to be sure this and the other items in the structure are in place.

tagged: pds skeleton package definition structure example tutorial

Link: https://www.sitepoint.com/pds-skeleton-by-example-a-standard-for-file-and-folder-structure/

Benjamin Eberlei:
Explicit Global State with Context Objects
Mar 24, 2017 @ 16:50:12

In a post to his site Benjamin Eberlei looks at global state in PHP using something called "context objects" and how they can be used as an alternative to true global state.

Global State is considered bad for maintainability of software. Side effects on global state can cause a very nasty class of bugs. Context objects are one flavour of global state. For example, I remember that Symfony1 had a particularly nasty context object that was a global singleton containing references to very many services of the framework.

As with every concept in programming, there are no absolute truths though and there are many use-cases where context objects make sense. This blog posts tries to explain my reasons for using context objects.

He starts by getting everyone on the same page by defining a context - the "circumstances in which something can be fully understood". He then moves into the world of context objects, talking about how they encapsulate the information other objects need to execute. They're essentially "container" objects that allow for more control that something like the normal PHP superglobals. From there he helps you define what kind of context objects you might need in your application and provides a real-world example from his own experience at Tideways.

tagged: global state context object tutorial introduction definition

Link: https://beberlei.de/2017/03/12/explicit_global_state_with_context_objects.html

Paul Jones:
Package Development Standards: "pds/skeleton" Now Open For Review!
Dec 16, 2016 @ 16:54:14

Paul Jones has a post to his site with a proposal for a standard structure for PHP packages to help provide consistency across the PHP package ecosystem. His proposal - the Package Development Standards initiative - defines the structure of the repository instead of conventions to be used in the package itself (like naming or object structure).

The new pds/skeleton (and the related research) for public review. If you are a package author, you are invited to post your comments and criticisms of the publication as issues on the relevant Github repository.

The pds/skeleton publication describes a set of standard top-level PHP package directories and files. If you are an author of more than three packages on Packagist, chances are you already follow the standard! That’s because PDS initiative researches the PHP package ecosystem to recognize commonly adopted development practices.

He's putting it out there for public review for now until he can get some feedback from the community on the structure and recommendations made. He also recommends going a head and adding "pds/skeleton" to your "require-dev" section to indicate your compliance to the suggestions he's presented.

tagged: package structure repository standard definition opinion composer

Link: http://paul-m-jones.com/archives/6457

Christian M. Mackeprang:
What “Full Stack” really means to the job market
Aug 01, 2016 @ 18:33:20

There's an interesting article from Christian M. Mackeprang that tries to provide some definition to the term "full stack programmer" and what it really means to the job market.

Back around 2013, the term Full Stack developer started to come up in job descriptions and blog posts. Companies were realizing that hiring developers with expertise in only one language just wasn’t enough anymore. A web developer that can handle a variety of tasks and environments is considerably more useful, and was starting to become the norm.

[...] What is a full stack developer supposed to know, anyway? Job descriptions frequently mention combinations of frontend and backend technologies such as JavaScript and Node, PHP and jQuery, Angular and Spring, and many others. In reality there is a significant amount of information outside those realms that would improve someone’s ability to build a website, and gone are the days when you could stick with what you know and make a career out of a single technology.

He talks about the combinatorial explosion the number of possible technology combinations can cause and how the usefulness of specific posts/resources is dwindling because of it. He then talks about "hackers" as "antifragile programmers" being the ones that enjoy the exploration of the tools and systems and are not bothered by change. He also suggests that developers need good skills in time management and setting expectations to prevent too much "exploration time".

He finishes out the post sharing thoughts about redefining the roles we're actually looking for an the individuals we want to fill them. He offers pointers about gaining context around issues, understand tradeoffs and doing what other people don't like doing to make your way ahead.

tagged: fullstack developer definition job market opinion hacker

Link: http://chrismm.com/blog/what-full-stack-really-means-to-the-job-market/

Robert Basic:
Tags for PHP in Vim
Mar 10, 2016 @ 17:32:34

In a post to his site Robert Basic has shared some helpful plugins for PHP developers using Vim as their primary editor. These plugins not only help you jump around in your code but get more context on where you're at.

One thing I was missing for a long time in Vim is to be able to "jump to definition" in an easy and painless way. The other thing I wanted to improve is to be able to tell easily where am I actually in the code base; to see the current class and method name of wherever the cursor was.

With a bit of googling and poking around, I finally came up with a perfect combo of 5 plugins (yep, five!) that enables me to do both, and a little bit of extra.

He shows examples of using three different things he wanted to be able to do when working in his code and the plugins that satisfy each:

One line examples are included showing how to configure them with your current Vim use.

tagged: tags vim plugin jump definition context class method

Link: http://robertbasic.com/blog/tags-for-php-in-vim

Taha Shashtari:
A Gentle Introduction to Testing in PHP
Feb 02, 2016 @ 16:11:20

If you're not already doing testing (like unit testing) in your PHP-based applications but want to start, this new post on Taha Shashtari's site might just be for you. It provides a "gentle introduction" to unit testing, what it is and some of the tools you can use to get started.

Learning testing can be very overwhelming especially if you're just starting out. [...] You might have read a bunch of PHPUnit tutorials and maybe you tried to apply some of what you've learned in your projects, but it doesn't always feel right. And sometimes you get into situations where you have no clue how to test some feature in your application.

If anything of this happened to you, don't feel bad, we all have had this experience. And it's almost because of the way we learn it.

He starts by talking about some of the main goals of testing in your application and the difference between manual and automatic testing. He then gets into each of the three main testing types and follows it with links (and summaries) to tools you can use to get started testing. He ends the post with a brief look at test-driven development and, setting the stage for the next tutorial in the series, looks at the path ahead.

tagged: tdd definition basic introduction gentle testing unittest phpunit tools summary

Link: http://taha-sh.com/blog/a-gentle-introduction-to-testing-in-php

Mathias Verraes:
Economy of Tests
Jan 05, 2015 @ 17:48:02

Expanding on the previous post about how much testing may be too much, they're back with another post in the series, this time focusing on the "economy of tests". This time Mathias is joined by Konstantin Kudryashov as a co-author.

A common complaint with teams that first try their hand at automated testing, is that it is hard, costly, and not worth the effort. On the other hand, supporters say that it saves them time. In this post, we'll try to add some nuance to the discussion. We'll take a look at how different levels of automated testing affect the cost of development, both in the short and the long term, for both greenfield and brownfield projects. Finally, we'll look at a simple strategy for introducing tests and migrating them across test levels, in order to reduce maintenance costs.

They start with some baseline definitions so everyone's on the same page - unit test, integration testing and system testing. The article also covers some of the basic kinds of testing metrics including execution speed, fragility and understandability. It then moves on and looks at the other major final factor in the overall cost of testing, the age of the project (new vs existing). He mentions the Testing Pyramid, how it's recommended to migrate tests and some of the common opposing forces to the test migration/creation.

tagged: unittest testing economy existing new project definition pyramid

Link: http://verraes.net/2015/01/economy-of-tests/

Paul Jones:
What's The Difference Between Tightly-, Loosely-, and De-Coupled ?
Oct 06, 2014 @ 15:20:30

In his latest post Paul Jones recounts a Twitter-based discussion that happened between Taylor Otwell (@taylorotwell) and others on Twitter about the different types of coupling in libraries or applications. The discussion focused around three different types and their definitions: loosely-coupled, tightly-coupled and de-coupled.

The quotes from the conversation come from Taylor, but Paul includes some of his own thoughts in response (things better expressed in more than 140 characters. He talks about some of the assumptions that were made during the discussion, the general knowledge level of "basic programming terminology" and how Paul views the definition of "decoupled".

If your code has a dependency on classes in a particular thrid-party package, your code is tightly coupled to the code in that package. [...] The fact that your code could be tightly coupled to another package does not mean that the other package is coupled to anything else. That is to say, the other package might have no couplings of any sort to any other code outside itself. The other package in that case is de-coupled.

He talks about how one of the main goals of the packages that make up the Aura project is to be decoupled from the start and how that can help with changing requirements/dependencies down the road. He also defines what he sees as "loose" and "tight" coupling, largely defined by the packages required in the "composer.json".

tagged: decouple loose tight coupling package library definition terminology

Link: http://paul-m-jones.com/archives/6051


Trending Topics: