Software API/CLI interface adapters

While writing software, we are faced with lots and lots of interfaces.
The public interface for some tool or module or package or whatever is usually referred to as the API, the CLI, or simply the user interface.
In this post, when considering an interface, I am specifically referring to APIs and CLIs.

Sometimes, we find a software component that does exactly what we want, but the interface is not what we want.
That’s where software interface adapters come to the rescue.
Adapters are helpful in many stages of the design and development of just about anything.

Software interface adapters are perfect for functional testing.
On this site, I use a flavor of TDD that focuses on functional testing.
I’ve usually got a couple of goals:

  1. I want to test the public interface: either API, CLI, or both.
  2. I want the tests tat make up my regression test suite to be as easy to write as possible, so that it’s simple to add new tests as needed.

Often, these goals are at odds. The API/CLI may just not be convenient for easy testing.
That’s an ideal place to develop an interface adapter.

In this post, I’ll describe how interface adapters can be easily specified and implemented in python.
As a working example, I’ll describe the interface adapter that I need for testing

Read more about defining, implementing, and using interface adapters requirements

I’ve decided to write my own Markdown script,
possibly for dubious reasons.

I’m getting antsy to code.

But before I get started on the testing and implementation, I need to:

  • write the requirements
  • write a simple stub implementation
  • write a testing strategy
  • explore test frameworks

Then, FINALLY, I can start testing and implementing.
I will talk about the term ‘testing and implementing’ in a future post.

Let’s take a look at the requirements.
[Read more...]