---
# (DD02) 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()

`Sortingss.main()` is the desktop application entry point for the `Sortingss` window. Its business role is not to calculate or persist domain data, but to bootstrap the user interface so the sorting-related application can be launched from the operating system or development environment. The method schedules the window startup on the AWT Event Dispatch Thread using `EventQueue.invokeLater`, which is the standard Swing routing pattern for safe UI initialization. Inside the deferred runnable, it instantiates the main frame holder (`Sortingss`) and makes the frame visible, turning the application from a dormant class into an interactive screen. If any exception occurs during startup, the method logs the stack trace so the launch failure is observable during diagnosis. Because the method has no business branching, it serves as a thin entry-point dispatcher rather than a business processor.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["main(args)"])
    INVOKE["EventQueue.invokeLater(new Runnable())"]
    RUN["Runnable.run()"]
    TRY["try"]
    NEW_WINDOW["Sortingss window = new Sortingss()"]
    INIT["Sortingss() -> initialize()"]
    VISIBLE["window.frame.setVisible(true)"]
    CATCH["catch(Exception e)"]
    PRINT["e.printStackTrace()"]
    END_NODE(["Return / Next"])

    START --> INVOKE
    INVOKE --> RUN
    RUN --> TRY
    TRY --> NEW_WINDOW
    NEW_WINDOW --> INIT
    INIT --> VISIBLE
    VISIBLE --> END_NODE
    TRY --> 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 when the sorting application is started. In this implementation, the array is not inspected, so it does not change screen selection or startup behavior; it exists only to satisfy the standard Java entry-point contract. |

External state read by this method: the AWT Event Dispatch Thread, the `Sortingss` constructor, the `frame` field created during initialization, and the Java exception handling/console logging mechanism.

## 4. CRUD Operations / Called Services

This method does not perform domain CRUD against business tables or external service components. It only performs UI bootstrap calls.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `EventQueue.invokeLater` | N/A | AWT Event Dispatch Thread | Schedules the UI startup runnable for execution on the Swing event thread. |
| C | `Sortingss.<init>` | N/A | UI frame state | Constructs the application window and triggers internal initialization. |
| U | `window.frame.setVisible(true)` | N/A | Swing frame visibility | Updates the frame state so the window becomes visible to the user. |
| R | `e.printStackTrace` | N/A | Console / error log | Emits startup failure details for diagnostics. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Entry point | Operating system / Java launcher -> `Sortingss.main` | `Sortingss.<init> [C] UI frame state` |
| 2 | Screen:Frame | `src/algo_Calc/Frame.main` -> application launcher -> `Sortingss.main` | `Sortingss.<init> [C] UI frame state` |

## 6. Per-Branch Detail Blocks

**Block 1** — `TRY` (startup scheduling and window creation) (L171-L182)

> This block starts the GUI application on the Swing event thread, creates the main window instance, and makes the frame visible.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `EventQueue.invokeLater(new Runnable() { ... })` |

**Block 1.1** — `RUN` (deferred UI execution) (L172-L181)

> The runnable contains the actual startup work and isolates UI creation from the caller thread.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `new Runnable()` |
| 2 | CALL | `run()` |

**Block 1.2** — `TRY` (window instantiation) (L174-L180)

> The application constructs the main screen object and prepares it for display.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Sortingss window = new Sortingss();` |
| 2 | CALL | `Sortingss()` |

**Block 1.2.1** — `Sortingss()` constructor path (L175-L175)

> The constructor delegates to the initialization routine that builds the UI components.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `initialize();` |

**Block 1.3** — `VISIBLE` (frame activation) (L176-L176)

> After successful construction, the main frame is shown to the user.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `window.frame.setVisible(true);` |

**Block 1.4** — `CATCH` (startup failure handling) (L177-L179)

> Any exception raised during startup is printed to the console for troubleshooting.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `e.printStackTrace();` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|-------------------|
| `main` | Method | Standard Java application entry point used to launch the desktop program. |
| `args` | Field | Command-line arguments passed to the application at startup. |
| `EventQueue` | Technical term | Swing/AWT event dispatcher that serializes UI work onto the correct thread. |
| `Runnable` | Technical term | Deferred execution contract used to run startup logic asynchronously on the UI thread. |
| `frame` | Field | Main application window container that is made visible to the user. |
| `setVisible(true)` | UI operation | Displays the application window on screen. |
| `initialize` | Method | Internal setup routine that constructs and configures the window contents. |
| `printStackTrace` | Technical term | Exception logging method that writes diagnostic details to the console. |
| `Sortingss` | Class | Main Swing application class for the sorting screen. |
| `AWT` | Acronym | Abstract Window Toolkit - Java desktop UI foundation. |
| `GUI` | Acronym | Graphical User Interface - the interactive desktop screen shown to the user. |
| `EDT` | Acronym | Event Dispatch Thread - the dedicated thread for Swing UI updates. |
| `Entry point` | Technical term | The first executable method invoked when the application starts. |
