Software Engineering in WordPress, PHP, and Backend Development

Tag: Software Development (Page 12 of 20)

A Few More Spotify Playlists for Work

Towards the end of last year, I shared a list of Spotify playlists for work that seemed to garner a good response if for no other reason than offering up some additional things to check out on my own 😇).

Since a few months have past and I’ve had a chance to listen, evaluate, and come up with a few more playlists to share I thought why not share another list?

Spotify Playlists for Work, Volume 2

So just as I shared towards the end of last year, here’s a list of the ambient music or the soundtracks I’ve been listening to as of late.

Continue reading

Repository Pattern Benefits: Why We Should Consider It

Yesterday, I gave a primer on the repository pattern. In short, it’s one of those patterns that I think anyone working on middleware built on top of WordPress should understand.

When giving a primer on a pattern like this, it can be tough to do justice to the pattern when you need to:

  • introduce it,
  • explain how it works,
  • cover the benefits,
  • and give a small demo.

But the real advantage to the repository lies not only in abstracting the data layer away from the rest of the application but that it can (or should) be able to be easily swapped out with various data stores without changing the API.

For example, in one instance, you may need to retrieve data from the WordPress database, in other cases you may need to retrieve something from a third-party API, or perhaps there’s some other place from which you need to retrieve data.

Regardless, the idea behind the repository pattern is that whatever sits behind it doesn’t matter so long as the API it provides works for the layer of the application calling into it.

And since we’ve covered a primer on the repository pattern, let’s take a look at some of the repository pattern benefits and how we can implement it in the context of WordPress projects.

Continue reading

The Repository Pattern Primer

Whenever you’re working on a larger project that’s based on WordPress, the odds that you’re going to be working with more than a single data source – that is, the WordPress database – are higher than normal. For example, you may be working on a project that has to coordinate information from:

  • the WordPress database,
  • a help desk ticketing system,
  • a content importing system,
  • another third-party API,
  • and possible more.

And when this happens, it can become a bit cumbersome to write code that makes it easy to retrieve information from those different places. This what developers usually talk about when they refer to dealing with “layers” in their application. That is,

  • there are layers for presenting information to the user,
    layers for handling business logic (or domain logic),
  • layers for communicating with APIs,
  • and layers for storing data.

Honestly, you don’t have to have a variety of data stores to watch to create a layer that makes it easier to send and retrieve data from the database, that’s just when it’s more common. You can just as effectively work with a single data store, like the WordPress database, when implementing the repository pattern.

Regardless, if you’re building a larger website, web application, or plugin, implementing the repository pattern is something that can pay dividends in maintenance, clarity of code, and separation of concerns.

But how might this be implemented within WordPress? It’s not terribly challenging, but first, it’s worth reviewing a repository primer before jumping into any code.

Continue reading

Mindset For Debugging (And Why We Need It)

When it comes to writing software, maintaining software, or simply trying to understand software, a debugger is one of the most powerful tools that we can use.

But when it comes to WordPress, it seems that it’s less common. Personally, I’m not sure why:

  • I don’t know if it has to do with the nature of open-source,
  • if has to do with the convenience of echo and var_dump that are built into the language,
  • or if I’m just missing other developers who talk about it.

Regardless, if an IDE doesn’t have a built-in debugger, it’s not too difficult to set up Xdebug and get started using it. And once you do start using it, you learn much more about how a given piece of software performs regardless of if you wrote it or if someone else wrote it.

Yes, I’ve written on this topic before, but I recently stumbled across an article that I found to be a really good break down of how to shift one’s thinking into a mindset for debugging.

Continue reading

Singletons in WordPress, Revisited (A Time and a Place?)

Before I start a post talking about using singletons in WordPress (or, more appropriately, the Singleton Pattern), I want to make sure that you read the following two articles:

Both of these articles provide immensely valuable perspective on this pattern and the dangers of using it whenever using it throughout our work in WordPress; however, does that mean we should completely avoid them?

I don’t think so.

Then again, I also recognize that the articles aren’t saying to completely avoid them. They are giving strong cases for how to use them and the dangers of using them should you opt to do so.

And though I’ve definitely used them in the past, I’ve generally stopped. However, I recently came across a use case for a project in which I think it’s acceptable.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑