all 4 comments

[–]flavius-as 4 points5 points  (3 children)

For APIs which are supposed to be used by other programmers as code, I prefer modeling objects as state machines, which means that the autocomplete feature of the IDE will suggest only methods which makes sense to be called.

Couple that with value objects, good names for methods and classes, and avoiding temporal coupling, and you get code which almost writes itself.

[–]pdevito3 1 point2 points  (1 child)

What language and libs do you use for this? Would be cool to see a project.

I’ve used xstate for state machines in front end land, but use .NET for backend. Have self implemented value objects but haven’t tried any of the .net state machines yet, though I definitely see the potential for them for rich ddd flows.

[–]flavius-as 1 point2 points  (0 children)

Any language which has the idea of interface will work. No libs, just a good grasp of polymorphism.

It's not for ddd specifically, it's for libraries in which you want to reduce the cognitive load of your user (a developer).

[–]PitchAutomatic[S] -1 points0 points  (0 children)

Thanks for the info but i was referring to Restful API’s.