---

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

This method is the desktop application entry point for the `Sortingss` screen. It does not execute a business calculation itself; instead, it hands control to the Java AWT event queue so that the user interface is created and displayed on the correct UI thread. In business terms, this is the launch action that opens the Sortingss window and starts the interactive calculation tool for the user.

The method implements a classic startup / bootstrap pattern: it delegates application initialization to `EventQueue.invokeLater(...)`, then instantiates the main window and makes it visible. Its only conditional behavior is error handling inside the UI bootstrap block, where any exception raised during window construction or display is caught and printed. Because it is an entry-point method, it functions as a shared launcher rather than a reusable service method, and it sits at the boundary between the operating environment and the application UI.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["main(args)"])
    INVOKE(["EventQueue.invokeLater(new Runnable())"])
    RUN(["Runnable.run()"])
    TRY(["try block"])
    NEW_WINDOW(["Sortingss window = new Sortingss()"])
    SHOW(["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 --> SHOW
    SHOW --> END_NODE
    TRY --> CATCH
    CATCH --> PRINT
    PRINT --> END_NODE
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `args` | `String[]` | Command-line arguments supplied at application launch. In this method, they are accepted by the standard Java entry-point signature but are not used to alter behavior, so the screen always opens with the default startup flow. |

Instance fields / external state read by the method:
- None directly. The method only relies on the Swing/AWT event dispatcher and the `Sortingss` constructor / `frame` state created during startup.

## 4. CRUD Operations / Called Services

This method does not perform CRUD against business entities, tables, or persistence services. Its only executable actions are UI bootstrap and exception printing.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|-----------------------|
| R | `EventQueue.invokeLater` | N/A | UI event queue | Schedules the UI initialization task to run on the Swing event dispatch thread. |
| C | `new Sortingss()` | N/A | UI window instance | Creates the main application window object. |
| U | `window.frame.setVisible(true)` | N/A | UI frame state | Updates the window state from hidden to visible so the user can interact with the application. |
| R | `e.printStackTrace()` | N/A | Exception diagnostic output | Reads the exception context and writes a diagnostic stack trace for troubleshooting. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen: `Frame` | `Frame.main(String[] args)` -> `Sortingss.main(String[] args)` | `new Sortingss() [C] UI window instance` |

## 6. Per-Branch Detail Blocks

**Block 1** — `TRY` / application bootstrap `(L171-L182)`

> Launches the UI on the event dispatch thread and catches any startup exception.

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

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

> Executes the screen creation logic on the Swing event queue.

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

**Block 1.1.1** — `TRY` / window construction and display `(L174-L179)`

> Builds the `Sortingss` window and makes it visible to the user.

| # | Type | Code |
|---|------|---|
| 1 | CALL | `Sortingss window = new Sortingss();` |
| 2 | EXEC | `window.frame.setVisible(true);` |

**Block 1.1.2** — `CATCH` / startup failure handling `(L179-L181)`

> Prints the stack trace if the screen cannot be created or shown.

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

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `args` | Field / parameter | Standard Java command-line argument array passed at startup. |
| `EventQueue` | Technical term | Java AWT/Swing event dispatcher that serializes UI work onto the correct thread. |
| `invokeLater` | Technical term | Schedules a task to run asynchronously on the event dispatch thread. |
| `Runnable` | Technical term | Callback interface used to define the deferred UI startup logic. |
| `frame` | UI field | The top-level window component for the Sortingss application. |
| `setVisible(true)` | UI operation | Displays the application window to the user. |
| `printStackTrace()` | Technical term | Writes exception details to the console for diagnosis. |
| Sortingss | Application name | The desktop UI class being launched by the application entry point. |
| Utility | Layer | Non-persistent helper / launcher code that starts the application rather than serving domain data. |
