Programming Theory

Best practices, structuring of code, dissecting algorithms and talking about the “Why?”

The Comma Operator in C++

When we think of the comma character we often think of it as a separator. It separates values in an CSV file, it separates items in lists, it may separate index values in multidimensional arrays (in other languages) and more. But in C++ an obscure way of using them was as an operator. The reason it never made it big as an operator and into the typical programming psyche is ...

My Love / Hate Relationship with PHP Traits

Anyone who knows me knows that I am a bit of a stickler when it comes to traditional software design principles. I do believe they lead to outstanding software products when they are followed correctly. This isn't to say I am not flexible when it comes to new ideas to improve traditional rules. When I saw the introduction of PHP traits in 5.4.0 I was eager to learn all about ...

5 Quick and Easy Refactoring Tips

You wouldn't believe how many programming questions I run across, on a daily basis, asking for help with programs that contain repetition, duplication and enough spaghetti code to feed half of Italy. Often times the person asking the question has a particular problem but they don't know exactly where the problem originates. So they plop down a bunch of code and say "It is somewhere in there... I think". Usually ...

Function Pointer Basics in C++

Beginners to C++ programming find the concept of pointers foreign to them. Pointers, and code that manipulates pointers (aka pointer arithmetic), can even be daunting to some of the most seasoned programmers. Pointers in C++ account for a fair share of bugs in programs due to the lack of understanding. So why even use them? Well, besides being the most problematic, they are also some of the most powerful features ...

Greatest Advice, Start Small and Think Small!

Every programmer comes across a point in their career where they think nothing will surprise them or fundamentally change the way they think about code. Every programmer would be wrong. Many programmers often run into these "inflection points" multiple times over the years. One such point came to me while reading the book Clean Code: A Handbook of Agile Software Craftsmanship. The book discussed a few topics involving function ...

Applying Enchantments for PHP RPG Games – One Approach

So you want to build a PHP game and are just now learning how to do it. You fired up your browser and began searching for various game articles and perhaps you have found very little. What you did find might not explain a flexible way to apply magical spells to units you create. After all, what is an RPG game without enchantments you can cast on your (or enemy's) ...