I am noticing a disturbing trend. On every device I use (e.g. iPhone 6 Plus, desktop, tablet) websites seems to be getting slower and slower to interact with. This isn’t true for every website I visit. However, for all of the bigger and more heavily trafficked websites it is definitely true.
Specifically, I have noticed the following:
When I first learned to program, I made many objects that were mutable. I made lots of getters and lots of setters. I could create objects using a constructor and mutate and morph the heck out of that object in all kinds of ways. Unfortunately, this led to many problems. My code was harder to test, it was harder to reason about, and my classes became chock full of checks to ensure that it was in a consistent state anytime anything changed. Of course, my classes had to be backed by unit tests and this often resulted in a combinatorial explosion. This how I look when I try to imagine all of the possibilities and how to test them.
Let’s assume we are doing TDD (and maybe BDD too) and we don’t want to write software without a failing test.
Back in the day, whether you were writing PHP, Java, or Asp.Net, testing your server side application was easy. You wrote unit tests for your models, controllers, data objects, etc. Then, you ran them every few minutes as you wrote new code and features. Everything was simple and all of your tests existed in the same language and execution environment as the business logic (i.e. the server).
Haven’t you ever wished you had an easy to use chronograph, set of constants representing the days of the week, or perhaps months of the year? Maybe you have forgotten the exact format to use when writing datetime’s to a MySQL database (i.e. ‘Y-m-d H:i:s’). I know I have.
Normally, cache entries are invalidated using one of two methods:
1. The cache entry is explicitly removed via a call to a
remove() method of some sort.
2. The cache entry is removed due to time-based expiration.
3. The cache entry is removed due to being ejected to make room for newer entries.
PHPUnit is a great testing framework. However, over time I began to find myself wishing it had certain features. So I created KissTest. It is a Keep-It-Simple-Straightforward (KISS), very fast, and absolutely gorgeous xUnit style unit test library.
As you can see in the screenshot, the display of the results is right in the browser. Everyone loves the command line and I am no different. However, there is something to be said for seeing the results laid out beautifully like this. Also, the PHP CLI binary is technically different from the one that is used to serve web pages. Generally, I try to keep the execution environment for the development environment and the production environment as close as possible. In fact, my development environment is identical to the production environment except it is running in VirtualBox. KissTest facilitates this. Sweet!
I am a huge fan of type hinting in PHP. When using great tools like PHPStorm it gets even better because of the amazing auto-complete and refactoring capabilities the IDE provides. Unfortunately, PHP doesn’t provide type hinting for scalar values. The SPL provides a set of classes for scalars, but they are not very popular. So, the package PHP Scalars (https://github.com/joefallon/PhpScalars) was born.
UPDATE: This post is probably very out of date. Please use at your own risk.
Recently, while doing some development on my Mac, I realized I didn’t have MySQL installed. I could have loaded up an instance of Ubuntu 12.04 LTS on VirtualBox and used that. However, I thought it would be much more convenient to have it available directly instead in a virtualized environment. Here are the instructions for installing it on a Mac using Homebrew.
This guide assumes Homebrew is installed and properly functioning.
When first learning about the difference between authentication and access control, it may be easy to confuse the two. However, they are two very different concepts. Also, they should understood well by any developer that is writing applications where access to the application needs to be controlled.
UPDATE: We are no longer stuck with IE6. Yay! 🙂
Among web developers, Internet Explorer 6 is considered a horrible browser. However, amongst many corporations, it is the standard browser that is used throughout the organization. One reason for this is due to the great amount of difficulty for a large organization to change. Every page on the company intranet has to be tested and fixed. Additionally, moving away from Internet Explorer 6 typically involves a change in operating system.