# (DD09) Business Logic — Sortingss.main() [12 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `algo_Calc.Sortingss` |
| Layer | Utility |
| Module | `algo_Calc` (Package: `algo_Calc`) |

## 1. Role

### Sortingss.main()

This method is the application entry point for the `Sortingss` desktop program. Its business role is not to perform a domain calculation itself, but to bootstrap the user interface safely on the Swing Event Dispatch Thread so that the window opens in a thread-correct manner. The method delegates the actual screen construction to the `Sortingss` constructor and then makes the main frame visible, which means it controls the first user-facing transition into the application.

From a system perspective, this is a launch-orchestration method: it routes startup execution into a deferred UI task, handles instantiation of the main window, and then exposes that window to the end user. The only failure-handling branch is a broad exception catch that prints the stack trace, indicating that startup faults are treated as runtime diagnostics rather than business recoverable errors. Because the method has no branching by business type, it acts as a minimal entry-point wrapper around the UI initialization flow.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["main(args)"])
    CREATE["Create Sortingss startup context"]
    INVOKE["EventQueue.invokeLater(Runnable)"]
    RUN["Runnable.run()"]
    TRY_START["try"]
    NEW_WINDOW["Sortingss window = new Sortingss()"]
    SHOW["window.frame.setVisible(true)"]
    TRY_END["end try"]
    CATCH["catch Exception e"]
    PRINT["e.printStackTrace()"]
    END_NODE(["Application launched / exit"])

    START --> CREATE
    CREATE --> INVOKE
    INVOKE --> RUN
    RUN --> TRY_START
    TRY_START --> NEW_WINDOW
    NEW_WINDOW --> SHOW
    SHOW --> TRY_END
    TRY_END --> END_NODE
    RUN --> CATCH
    CATCH --> PRINT
    PRINT --> END_NODE
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `args` | `String[]` | Command-line launch arguments supplied by the runtime. In this method they are not inspected, so they do not influence business behavior; the application always opens the same UI entry flow regardless of passed parameters. |

External state read by the method at the end of execution:
- `EventQueue` from the Swing runtime to schedule UI startup on the event dispatch thread.
- The `Sortingss` constructor and its `frame` field, which are used to instantiate and display the main window.

## 4. CRUD Operations / Called Services

The method contains no CRUD operations against business entities or database tables. Its only executable actions are UI bootstrap calls.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|-----------------------|
| R | `EventQueue.invokeLater` | N/A | N/A | Schedules the startup runnable to execute on the Swing event thread so the UI is created in the correct runtime context. |
| C | `new Sortingss()` | N/A | N/A | Creates the main application window object and initializes the desktop screen state. |
| U | `window.frame.setVisible(true)` | N/A | N/A | Updates the window state from hidden to visible so the user can interact with the application. |
| R | `e.printStackTrace()` | N/A | N/A | Reads exception details for diagnostic output when startup fails. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Direct runtime entry | JVM launcher -> `algo_Calc.Sortingss.main` | `Sortingss() [C] N/A` |
| 2 | Direct runtime entry | JVM launcher -> `algo_Calc.Sortingss.main` -> `EventQueue.invokeLater` -> `Runnable.run` -> `new Sortingss()` -> `frame.setVisible(true)` | `frame.setVisible(true) [U] N/A` |
| 3 | Direct runtime entry | JVM launcher -> `algo_Calc.Sortingss.main` -> `catch Exception e` -> `e.printStackTrace()` | `e.printStackTrace() [R] N/A` |
| 4 | Direct runtime entry | JVM launcher -> `algo_Calc.Frame.main` | `Frame.main` is a separate entry point and not a caller of `Sortingss.main` |

## 6. Per-Branch Detail Blocks

**Block 1** — [STATEMENT] `(method entry)` (L171)

> Application startup entry point receives control from the Java runtime.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `EventQueue.invokeLater(new Runnable() { ... });` // defer UI creation to the Swing event dispatch thread |

**Block 2** — [CALL] `(EventQueue.invokeLater callback)` (L171)

> Registers the startup job so the window is created safely on the UI thread.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `EventQueue.invokeLater(new Runnable() { ... });` // schedule deferred execution |

**Block 3** — [STATEMENT] `(Runnable.run entry)` (L172)

> Executes the startup sequence inside the deferred UI callback.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `public void run() { ... }` // callback body begins |

**Block 4** — [TRY] `(window initialization and display)` (L173-L178)

> Builds the main application window and makes it visible to the user.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Sortingss window = new Sortingss();` // create the main screen instance |
| 2 | EXEC | `window.frame.setVisible(true);` // expose the window to the user |

**Block 5** — [CATCH] `(Exception e)` (L178-L180)

> Handles any startup failure by emitting diagnostic information.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `e.printStackTrace();` // output exception details for troubleshooting |

**Block 6** — [RETURN] `(method completion)` (L181-L182)

> Terminates the launch method after scheduling and running the startup callback.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `}` // method exits with no return value |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `args` | Field/Parameter | Command-line arguments supplied at application startup; not used by this method. |
| `main` | Method | Standard Java entry point used to start the desktop application. |
| `EventQueue` | Technical term | Swing event-dispatch queue used to run UI work on the correct thread. |
| `Runnable` | Technical term | Deferred execution contract that contains the UI startup logic. |
| `frame` | Field | The main application window displayed to the user. |
| `setVisible(true)` | UI action | Makes the window visible and interactive. |
| `printStackTrace` | Technical term | Diagnostic method that prints exception details to standard error. |
| `Sortingss` | Class | Main desktop application class whose instance represents the primary screen. |
| `Swing` | Framework term | Java desktop UI toolkit used for the application window lifecycle. |