Sobes.tech
Middle

Did you add new statuses to the status model — how exactly? What was the implementation? Hardcoded or a reference?

sobes.tech AI

Answer from AI

When adding new statuses to a status model, two approaches are usually chosen:

  1. Hardcoding (fixed statuses in the code)

    • Statuses are represented as constants or enums.
    • Quick implementation, but requires recompilation and deployment when changes are made.
    • Suitable for statuses that rarely change.
  2. Directory (configurable model)

    • Statuses are stored in a database or configuration files.
    • Allows adding/changing statuses without modifying the code.
    • Requires implementation of loading and validation logic for statuses.

In real projects, a directory is often used for flexibility, especially if business processes change. For example, a statuses table with fields id, code, description.

Example of implementation using enum in Java:

public enum OrderStatus {
    NEW, PROCESSING, COMPLETED, CANCELLED
}

Example using a directory:

id code description
1 NEW New order
2 PROCESSING In processing
3 COMPLETED Completed
4 CANCELLED Cancelled

In this case, business logic refers to status codes, and an administrator can add new statuses through the interface.

Did you add new statuses to the status model — how… - sobes.tech