DEV Community

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

Posted on

5 3

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.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

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

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.

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay