When To Write Bad Code

Have you ever had this situation before? You have a problem to solve and no idea how to solve it. You want to sit down and do it “the right way”, but “the right way” involves writing tests, designing objects and generally working out something that’s far more complex than you need to get a working prototype. And so nothing gets done.

I’ve been there myself. I recently needed to prototype something. As I sat down to work on it, I had absolutely no idea how I was going to write the component I was working on. And so, I started working – without a plan, without writing tests, without designing an architecture, and without really knowing how the component was going to end up.

(more…)

Tuesday, January 29th, 2013 @ 7:00 am | Comment (35) | Categories: Software Development, Object-Oriented Development, Best Practices

Using Interfaces For Exceptions

In PHP (as well as many other object oriented languages), exceptions are simply objects, which can be extended and reused. PHP makes them special in the sense that only exceptions that inherit from the base class Exception are throwable by the interpreter (you cannot throw any generic object you create).

Most developers are therefore aware of the ability to extend exceptions, thus giving them unique, typehintable values that can be identified, caught and handled.

(more…)

Tuesday, January 22nd, 2013 @ 6:00 am | Comment (2) | Categories: Object-Oriented Development, PHP 5, Best Practices

Mastering Object Oriented PHP

Object oriented PHP can leave you with quite a headache. It’s a challenge. A struggle. Something that you fight against. The principles seem abstract, and you wonder whether or not object oriented PHP can ever be something that you can grasp and be good at. Object oriented PHP is obtuse and hard to follow. You wish it was easier to understand.

I understand how this feels. Back when I started writing PHP, there wasn’t much of an object model to behold. Those were the “good old PHP 4” days, when an object was little more than an array with methods slapped on it. Objects didn’t have visibility, there were no interfaces, constructor functions were just functions inside the class with the same name as the class, and object oriented principles didn’t really apply.

(more…)

Monday, January 14th, 2013 @ 7:00 am | Comment (2) | Categories: Object-Oriented Development, Best Practices

Exception Handling: A Pilot’s Perspective

Airplane on Short FinalOne of the most amazing things about earning my pilot certificate was the ways that what I learned as a pilot interfaced with what I knew as a programmer. Things like evidence-based problem solving and data-driven decision making are core tenants of aviation and software development.

A large portion of training, for both the primary rating and the instrument rating, consists of emergency preparation. Flying an airplane is easy when things go right. Flying an airplane gets much harder when there are problems, distractions or emergencies. The skill of a pilot can be tested in these situations. In a similar way, writing an application that runs well under ideal circumstances is the easy part; handling failures is the harder task, and one that programmers must excel at.

(more…)

Tuesday, January 8th, 2013 @ 7:00 am | Comment (1) | Categories: Object-Oriented Development, Best Practices

A Last Chance To Get A Bonus With Do This, Not That

dtntcoverWhen I released Do This, Not That: Object Oriented PHP, I also included a free bonus of “Programmer in Command: What Aviation Teaches Software Developers”. This manifesto contains several suggestions that I learned over time as the best software development practices. I offered it until January 1st, 2013, and since that’s coming up on us very quickly, I wanted to offer a last chance to get it along with Do This, Not That: Object Oriented PHP.

Do This, Not That: Object Oriented PHP is aimed at developers who know the basics of object oriented development and want to learn the best practices as applied to PHP. Rather than teaching the basics of object oriented PHP, it shows you how combine the mechanics of object oriented PHP with the tried and true computer science best practices in a concrete way. And since PHP has a number of features not seen in other languages, it answers some of the most important questions about some of the PHP-specific features you’ll encounter.

(more…)

Sunday, December 30th, 2012 @ 8:37 pm | Comments (0) | Categories: PHP 5, Object-Oriented Development, Best Practices

Effective Refactoring Strategies

Including today, there are six business days remaining in 2013 (five if you are lucky enough to get New Year’s Eve off). My brother used to call this week “the lost week” – there’s hardly anything to get done because so many people are on vacation or preoccupied with setting goals for the new year. But the downtime provides a perfect opportunity for the aspiring software developer to do the one thing they are always told there’s no time to do: make the code better for better’s sake.

With few deadlines and plenty of free time, most developers can get a few hours of refactoring in to their code towards the end of the year. They can rearchitect sections that were implemented with haste in September; they can write tests for sections that were untested in April. Put another way, the “lost week” can be redeemed.

(more…)

Friday, December 21st, 2012 @ 7:00 am | Comments (0) | Categories: Object-Oriented Development, Friday Inspirations, Best Practices
Tags: , , , , , ,

« Older Entries Newer Entries »

Copyright © 2024 by Brandon Savage. All rights reserved.