Tom McFarlin

Software Engineering in WordPress, PHP, and Backend Development

Page 148 of 428

Singleton Design Pattern and Dependency Injection, Part 2

In the previous post, I said that I was going to talk about how to use the Singleton Design Pattern as a simplistic way to introduce a dependency injection container into a project.

The Singleton Design Pattern and Dependency Injection Containers

One of the best comments I’ve seen about dependency injection containers comes from Stack Overflow (and Joel Spolsky, even):

IoC containers take a simple, elegant, and useful concept, and make it something you have to study for two days with a 200-page manual.

And there’s a time and a post for where I could digress, but that’s not this post. Instead, there are a few nuances about this idea that I want to clarify before I go any further:

  1. Dependency Injection Containers are more than just ways to store objects. They handle other additional logic. I’ll cover more about this later in the article.
  2. I don’t recommend sticking with an implementation of the Singleton Design Pattern for a container (or for very many things, for that matter).
  3. The purpose of showing this as a strategy is a way to show how you can take a project with a tight deadline, a desire to use software development best practices, and find some practical middle ground.

All of that to say is that what I’m going to show is not what I consider being a best practice for using dependency injection containers.

Instead, it’s a way to “meet in the middle” when it comes to working under pressure for building solutions for others all the while not wanting to sacrifice sound engineering principles.

Continue reading

Singleton Design Pattern and Dependency Injection, Part 1

The Singleton Design Pattern is something that I’ve talked about before in previous articles.

As Wikipedia so eloquently defines it:

In software engineering, the singleton pattern is a design pattern that restricts the instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system.

If you’ve done any work with object-oriented programming and familiar design patterns, then it’s likely that you’ve come across it (if you haven’t used it).

Depending on who you ask, the singleton design pattern may be treated as an anti-pattern, like some weird use of a “poor man’s namespace,” or one of the many other negative views of it.

Though these perspectives aren’t necessarily wrong, there are times where it’s okay to use it.

Continue reading

The Reality of Software Development Pressure

I recently heard a quote from someone (and if I could remember who said it, then I’d give attribution – but this is what happens when tweets just happen to scroll on by, right?) that I liked:

Setting deadlines before requirements is like setting a wedding date before you’ve met your partner.

And yes, it’s obviously tongue-in-cheek, but it’s lead me to think a lot about the breakdown that exists between all of the discussion around software best practices, things we should be doing, architectures and patterns we should be following, and then what we’re actually doing and what we’re shipping out to the world.

Development Pressure: Setting Requirements

At this point in my career, I can’t help but wonder if we enjoy talking about and discussing a lot of the things we should be doing as some escape to some of the hacked solutions we end up releasing.

Continue reading

How To Export Trello Board Members

For a couple of projects on which I work, I use Trello almost daily.

Export Trello Board Members

Some people find it the end-all, be-all of project management. I can’t say I agree with that statement, but it definitely helps streamline certain workflows (as far as I’m concerned).

But there’s one complaint that I have regarding the application: There’s no way to export the actual list of members for a given board (at least not at the time of this writing). Sure, you can export a board, but what happens when you want to contact all of the users?

There’s no way to export the actual list of members for a given board (at least not at the time of this writing). Sure, you can export a board, but what happens when you want to contact all of the users?

Sure, you can export a board, but what happens when you want to contact all of the users? I mean, I have a list of the users and their email addresses in a separate database, but Trello doesn’t allow me to export that data.

To export Trello board members, I put together a quick script that can run in the console of Chrome (maybe others, but I didn’t test). At the very least, it will return the names of the member so you can find them in your database, assuming you have one.

Continue reading

Practical Tips for Refactoring Code

If you’ve worked on a project available to any reasonably sized audience, then you’re no doubt familiar with the bug reports, problems, and issues that can come in after something has gone live.

It’s true that the majority of the work in software comes after the first reason of a release.

Think about it this way:

Once you’ve built the product, released it, and then are responsible for maintaining it, how often do you have to triage issues? Then how frustrated are you that you’re fixing something that wasn’t foreseen earlier during development?

The thing is, this is entirely normal. It’s no less frustrating. But it’s normal. However, there are small, practical things we can do to our code throughout development or during maintenance.

And that’s part of the problem that we often face, isn’t it? There are things we know we can do but the amount of time it takes to do them is often incompatible with our deadlines.

So what can we do?

Continue reading

« Older posts Newer posts »

© 2026 Tom McFarlin

Theme by Anders NorenUp ↑