Blog

The Single Responsibility Principle

The Single Responsibility Principle A class should have one, and only one, reason to change. – Robert C. Martin When we talk about reasons to change we are talking about business responsibilities. Pieces of business logic. Each class should deal with one singular piece of business logic. It should do one thing well and have…
Read more

SOLID principals of programming

What is SOLID SOLID is an acronym describing five basic design principles for writing good Object Oriented code. It is intended to make software designs more understandable and maintainable while also being less coupled and easier to extend. They are a condensed subset of principals promoted by Robert C. Martin, also known as Uncle Bob,…
Read more

Slim-OO Part 6 – Debugging Made Easy

Part 6 – Debugging Made Easy Whoops! Whoops! We had an error and now we have to look at that ugly, fairly uninformative error page. How many times has that happened to you? Too many? Yeah, same here. I really hate those uninformative “Hey, something broke but we’re not going to tell you what” errors.…
Read more

Slim-OO Part 5 – Install and Configure Twig

Part 5. Install and Configure Twig. Why a template engine. Slim comes with php-view, a basic renderer for PHP view scripts, by default. This means that all our templates would need to be in straight PHP syntax. There are many arguments for and against template engines. Personally, I like to use them because they give…
Read more

Slim-OO Part 4 – Converting Route Closures to Controller Classes

Part 4. Converting Route Closures to Controller Classes Route Control Right now we have all of our routing and controller logic in one procedural file that we are treating like a service definition. This is not good practice for anything more than a single-page site and will become unruly fairly quickly. Having the route definitions…
Read more

Slim-OO Part 3 – Decoupling The Configuration

Part 3. Decoupling the Configuration. Before going any further we should address something that we will be using more as we move forward. Configuration. Machine-specific configurations and credentials should never be stored in your version control repository. They should be kept on the machine and accessed by your application on deployment or runtime. Keeping them…
Read more

Slim-OO Part 2 – Refactoring The Service Loader

Part 2. Refactoring the Service Loader. One of the most important things you can do as a developer is refactoring. When you get to a point where a piece of code is working stop and look for ways to make it better. This may encompass things like removing duplicated code, breaking up large methods or…
Read more

Slim-OO Part 1 – Getting Started With Slim 2

Part 1. Getting started. Introduction So recently, when I needed to create a simple application skeleton out of the Slim v2 framework, I had a senior moment. As sometimes happens I couldn’t remember how I had set up a few things. I had to go back and look at notes and sources from previous applications…
Read more

Unit Testing Private Methods

Unit Testing Private Methods Yes I Know “A private method is an implementation detail”. “A private method should be hidden to the users of the class”. “Testing private methods breaks encapsulation”. Yes, I’ve heard all of these statements, and for the most part, I would agree. But not always! Yes, the private method is an…
Read more

To MVC, Or Not To MVC?

To MVC, Or Not To MVC? The Big Question Okay, so here I am using closure functions in a routes.php file to serve up a couple of endpoints. Nothing too out of the ordinary for a small application. And this works just fine for a small application with only a few pages or endpoints, but…
Read more