I'm building out a new REST API and as I develop my BDD skills more and more, it makes me cycle around a lot and question my use cases and scenarios more and more defined in our Jira stories. Unfortunately where I am working, the business has not yet caught onto creating formal scenarios in our stories. They create their own chaotic "acceptance criteria" for the top level epics, and then especially for the API, we're left to work with the web team to create our API stories and it's the combination of looking at the top level epics created by our PMs with their verbose business requirements written in the top level Stories coupled with looking at the Jira stories our web platform team creates for their React.js components.
So for myself, I personally create our API stories with scenarios written in Gherkin. Since the business won't write these, we're writing them the best we can again based off the acceptance criteria we gain from the two sources above.
Anyway, that's its own problem. The problem I wanna raise is how Use Cases should sound for a REST API.
I'm watching this episode on cleancoders:
In it UB states that Use Cases should be written in a way that they are delivery independent. They don't imply the deliver mechanism (web UI, etc.) in its wording. For example a use case shouldn't have words in it like "link, page, button" because that infers a web delivery mechanism. Now your use cases are coupled to the delivery mechanism. What if you changed that to be a mobile phone? Now all your use cases are so coupled to your other delivery mechanism that you pretty much have to throw them away.
But the question remains for me, what about a REST API? It'd be nice to see some vides on cleancoders on REST APIs more too.
Away, when I first started to create use cases (scenarios for them in our Jira Stories), they were more tied to the delivery mechanism than I realized (I think).
Take an example a story acceptance criteria I wrote after talking to the PM and our web platform team about the requirements for some data they needed for one of our new REST endpoints I needed to build out. This was one of the first features, just getting an endpoint up and working and returning some data (stubbed):
Story Title (feature): API Implementation: GET Account REST Endpoint
As a caller of the new Data API
I want the ability to get Data back from a REST /accounts endpoint
So that I can get some some Account Data from a Database
Scenario (degenerate case): GET Account Endpoint - no data exists
Given There is a REST API endpoint for Accounts
When a GET request is sent to REST Uri "/accounts" with no params
Then we should receive a response back with no data
And the response status code should be 204
Scenario: GET Account Endpoint - Data returned
When a GET request is sent to REST Uri "/accounts" with no params
Then we should get a response back that has Account Data
And we receive a response with status code of 200 (OK)
And the response should be in a the form of a JSON object
Looking at these acceptance criteria definitions, I still think it's too coupled to the delivery mechanism. I mention words like REST, JSON and I'm wondering if I'm coupling my use case to the delivery mechanism. Should my uses cases give a damn about REST, JSON? Many would think sure, your use case is for the consumer of your API, other developers. But then just have this itch that these aren't quite right still. They're based on inputs/outputs but still feel they're exposing the implementation details thus coupled to the delivery mechanism.
Thoughts? opinions? suggestions? Do these look good to you or do you think they violate good use cases and that they're still coupled to implementation details or the delivery mechanism?
I don't mention words like http her which is good. But I do mention GET which is an http verb. Maybe there is no better way to write acceptance criteria for a web service? Oh no, I just said web! See what I mean? I feel the use case should talk nothing about the web period.
(I also noticed I put "from a Database" in the initial description...ouch, that also doesn't sound good, I'm driving the intent and creation of our scenarios off the word "database" right off the bat!).
If so, how would you rewrite these to be totally decoupled to the delivery mechanism, being a web service?
I'm curious on the responses I'll get here. If you think these suck, tell me...and then tell me how you've made your REST API use cases worded more independently.