DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for Requirements as code v1.0.0 published
Bertil Muth
Bertil Muth

Posted on

Requirements as code v1.0.0 published

The requirements as code project simplifies the development of event-driven applications.

It provides a concise way to create handlers for many types of events at once. A single runner receives events, and dispatches them to handlers. When activated, the runner also records the events. That can be used for replay in event sourced applications.

You can also customize the event handler in a simple way, for example for measuring performance, or for logging purposes.

For more advanced scenarios that depend on the application’s state, you can create a use case model with flows. It’s a simple alternative to state machines, understandable by developers and business people alike.

The v1.0.0 provides the following features:

  • Define event handling models with event classes and event handlers
  • Define use case models with actors, use cases, use case flows, use case steps that react to events
  • Run a model, either for the default user or for a particular actor
  • Record events
  • Provide a custom event handler
  • Generate documentation from a model

Further features:

  • Include use cases
  • Ask the runner if an event currently triggers a reaction
  • Query the runner for events that are currently reacted to
  • Specify event handler for events not handled by the model

Check out the requirements as code project now.
And please give me feedback. It will help me to improve the project.

Top comments (2)

Collapse
spicecoder profile image
pronab pal

Sorry , I did not understand where is the "requirement" stated - either in code or otherwise, any clarification will be appreciated Thanks. Pronab

Collapse
bertilmuth profile image
Bertil Muth Author

Hi Pronab,
the requirements are stated in the model.
Take this snippet from the Hello World example from the main page:

Model model = 
  Model.builder()
    .user(RequestHello.class).system(this::displayHello)
    .user(EnterName.class).system(this::displayName)
  .build();

You can read this as:
When the user requests hello, the system displays hello.
When the user enters a name, the system displays a name.

You can also specify a condition, as explained in Step 1 on the main page. That's the typical form of a functional requirement:
Given that a condition is fulfilled, when an event happens, then execute a certain system reaction.

You can also specify flows of user interactions in the model, similar to a state machine. You find examples here.

🌚 Life is too short to browse without dark mode