Posts

Showing posts from 2017

TDD of a Simple App in PHP

TEST DRIVEN DEVELOPMENT in PHP In this tutorial, I will present an end-to-end example of a simple application - made strictly with TDD in PHP. I will walk you through each step, one at a time, while explaining the decisions I made in order to get the task done. The example closely follows the rules of TDD: write tests, write code, refactor. Step 1 - Introduction to TDD & PHPUnit Test Driven Development (TDD) TDD is a "test-first" technique to develop and design software. It is almost always used in agile teams, being one of the core tools of agile software development. TDD was first defined and introduced to the professional community by Kent Beck in 2002. Since then, it has become an accepted - and recommended - technique in everyday programming. TDD has three core rules: You are not allowed to write any production code, if there is not a failing test to warrant it.You are not allowed to write more of a unit test than is strictly necessary to make it fail. Not compiling …

Singleton Design Pattern in PHP

Image
Singleton Design Pattern in PHP The Singleton ensures that there can be only one instance of a Class and provides a global access point to that instance. Singleton is a “Gang of Four” Creational Pattern. The Singleton pattern is often implemented in Database Classes, Loggers, Front Controllers or Request and Response objects. Singleton: problem & solutionProblem Solution You want a class to have exactly one instanceYou want the instance to be easily accessibleYou don’t want to use global variables