For December’s PHP Las Vegas Meetup, I gave a talk on Dependency Injection, mostly focused on using it focus on better testing. Few things that I should work on in the future. I dropped in the idea of both coupling and DI containers without a ton of explanation thought out before hand of how exactly to present each of those concepts. The talks suffered from trying to figure out how best to explain those mostly on the fly. Otherwise, I think this talk went over very well.

Tagged with: ,
Posted in Presentations, Programming
Short Link:

For this month’s Las Vegas PHP Meetup, I spoke on PHP Namespaces and PSR-0/4. This was a great beginner talk to give, lots of little things to work the way through and explore and explain. I actually learned a few things in writing this presentation, mostly around autoloaders and how they work.

Tagged with: , , ,
Posted in Computer Science, Presentations, Programming
Short Link:

I spoke on Building APIs, focusing mostly on the upfront design of APIs, at the most recent Las Vegas PHP Meetup. Overall this was defiantly one of my better talks with lots of good feedback. One key things helped I believe in the preparation and eventual presentation of the talk. I presented a rough version of this to my fellow Loadsys employees with some valuable feedback provided from them.

Tagged with: , , , ,
Posted in Communication, Presentations, Programming, Web Development
Short Link:

At this year’s CakeFest I gave a lighting talk titled “Projects Are Better When Maintained”. Essentially, it was a complaint to be a better maintainer of the open source stuff that you put out. It went over really well and I got some good feedback from it.

Tagged with: , , ,
Posted in Communication, Computer Science, Presentations, Programming, Web Development
Short Link:

Just Say No to More End-to-End Tests

The bulk of your tests are unit tests at the bottom of the pyramid. As you move up the pyramid, your tests gets larger, but at the same time the number of tests (the width of your pyramid) gets smaller.

As a good first guess, Google often suggests a 70/20/10 split: 70% unit tests, 20% integration tests, and 10% end-to-end tests. The exact mix will be different for each team, but in general, it should retain that pyramid shape.

Title is provocative, but the sentiment of loading up on unit tests over end-to-end and integration tests sits well with myself. One of the key problems with integration and end-to-end tests is that they wind up being harder to debug when something goes wrong the exact place that things broke is hidden behind these multiple layers of code. Unit tests give you a key unit of code where, this changed and now it isn’t responding in the same way, look right there.

Tagged with: , , ,
Posted in Programming, Software Code
Short Link:

The Last Line Effect

So what we get is the following pattern:

The probability of making a mistake in the last pasted block of code is 4 times higher than in any other block.

Neat bit of research from Intel here and it makes a fair bit of sense to me that it’s easy to miss a duplicated line or other minor error when scanning multiple lines that all differ in very minute ways.

Tagged with: , , ,
Posted in Computer Science, Programming, Software Code
Short Link:

One of the key goals of CakePHP 3.0 as discussed recently was making CakePHP 3.0 more decoupled. CakePHP 3.0 has achieved that goal very nicely. Take a look at the CakePHP organization’s repos on GitHub and you will find a long list of decoupled collections of classes that are all part of the overall CakePHP framework that can be used completely independently of CakePHP itself.

Perhaps you are interested in some of CakePHP’s utility classes, like the Security utility, which are a great resource for hashing and encrypting basic data (not passwords) that you want some amount of reasonable security applied to it. Or perhaps you are interested in CakePHP’s Validation system which provides for validating arbitrary arrays of data. The most complex and most interesting part of CakePHP 3 by far is even available for use independent of the rest of the CakePHP core, the ORM layer.

How about an example to help clarify how to use these different pieces in smaller projects. Let’s build a simple webpage that allows us to submit a contact form request and validate it using the CakePHP Validation Library.

I’m doing this in a new `index.php` file in a new directory. First we need to get the Validation Library in our directory.

$ composer require cakephp/validation

That creates a new `composer.json` and loads the CakePHP Validation package. Next in our `index.php` file we need to load the Composer autoloader and the CakePHP Validation Class.

namespace LoadsysTestValidation;
require dirname(__FILE__) . "/vendor/autoload.php";
use CakeValidationValidator;

Now at this point we can create a new instance of the Validator class and validate arbitrary arrays of data, like what we would get from `$_POST`.

$validator = new Validator();
  ->notEmpty('name', 'Name is required to be submitted.');
$errors = $validator->errors($_POST);

I worked out a complete example of this and posted it on GitHub as a sample if you need more details or insight into using the CakePHP packages.

The overall CakePHP framework may not be the right choice for everyone in every case. With the recent decoupling of the framework in the 3.0 branch, CakePHP can be more easily used for those times when you want to pick either the very best packages for your problem or you only need a limited subset of features from CakePHP for your web application.

This was previously posted on the Loadsys blog.

Tagged with: , , , ,
Posted in Programming, Web Development
Short Link:

CakePHP 3.0 Retrospective

With CakePHP 3.0 out the door, I thought it would be good to reflect on the project. CakePHP 3.0 is the longest and largest open source project milestone I’ve ever participated in. At FreshBooks we do retrospectives on large projects as a way to see what went well, and what could have gone better. The goal is to discover things we should keep doing, and what to improve the next time around.

Thanks Mark for putting in the hard work of getting CakePHP 3.0 out the door. I wrote a piece for Loadsys talking about some of the new features that echoes a lot of the good things that Mark points out in his retrospective.

Tagged with: , , , ,
Posted in Programming, Software Code
Short Link:

In the pocket

I just don’t have a need for what the Apple Watch currently provides.

I’m sure its functionality will grow with time, though, and as it does I’ll revisit my decision not to buy one.

This doesn’t mean I don’t appreciate its appeal, even apart from the natural desire of gadget fans to have the latest thing. If being constantly connected were more important to my job or my sense of self, and if I had to process many more messages away from my desk than I usually do, I’d see the Apple Watch as a godsend—assuming, that is, that its user interface fulfills its promise to act as a timesaving message filter.

This is a near-perfect summation of my thoughts on the Apple Watch as it stands today. I would be a little more critical in some areas, but overall Dr. Drang echoes what I’ve said both on and off-line.

Tagged with: , , , ,
Posted in Technology
Short Link:

Economy of Tests

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.

Something I’ve been exploring over the past few months is while I’m quite good at ensuring there are unit and integration testing done on my projects, one area of testing lacking is system or functional testing. This piece does a good job explaining some of the key differences and value trade offs in each.

Tagged with: , , , ,
Posted in Computer Science, Programming
Short Link: