The Balance between Visual and Technical Debt in PHP
Laracasts recently published a very interesting non-Laravel video about something called visual debt. It’s only 3 minutes long, so please, take the time to watch it before reading further.
Done? Okay, spoilers below.
In the video, Jeff starts out with with a bit of verbose event-based code with some listeners, fire methods, an interface on which to base the various classes, and quite a few type and return hints all over the place.
As he scrolls through the code, he claims it’s full of visual debt. Jeff then goes on to explain that while PHP does offer type and return hints, they aren’t necessary, and promptly removes them from all method signatures to reduce the amount of code. “We were doing fine for a really long time without them”, he argues.
He then reaches for interfaces and removes those, too. He argues that people reach for them too often, too soon, and add unnecessary weight to their code.
In what seems like a final cut, he removes the “final” keyword from a class arguing that it’s silly to protect a developer from themselves, but then unexpectedly, he also cuts out even the
public keyword in front of the remaining methods, leaving them at the language default (which, incidentally, is an implied
The end result? About 25% less code in this simple example. But is the debt gone?
Continue reading %The Balance between Visual and Technical Debt in PHP%