# (DD16) Business Logic — Sortingss.vis() [8 LOC]

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

## 1. Role

### Sortingss.vis()

`vis(int k, String str)` is a small UI-routing method that prepares the `Sortingss` screen state before displaying the sort window. Its business role is to receive the selected sort type from the menu screen, persist that choice into the current screen object, and then make the target frame visible to the user. In effect, it behaves as a lightweight navigation and presentation initializer for the sorting demo/application.

The method does not perform any algorithmic sorting itself; instead, it acts as a dispatch point for user-selected sort categories such as Bubble Sort, Selection Sort, Quick Sort, Insertion Sort, Merge Sort, and Heap Sort. The caller passes an integer key and a display label, and the method stores both into instance state so the UI can present the selected sort mode. The implementation uses a simple assignment-and-display pattern with no branching, looping, or data persistence. This makes it a shared utility-like entry point used by multiple button handlers in the parent frame.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
START(["vis(k, str)"])
SET_KEY["key = k"]
SET_TNAME_HELLO["tname = \"Hello\""]
SET_TNAME_POP["tname = \"pop\""]
SET_TNAME_STR["tname = str"]
CALL_SET_VISIBLE["frame.setVisible(true)"]
END_NODE(["return 0"])
START --> SET_KEY
SET_KEY --> SET_TNAME_HELLO
SET_TNAME_HELLO --> SET_TNAME_POP
SET_TNAME_POP --> SET_TNAME_STR
SET_TNAME_STR --> CALL_SET_VISIBLE
CALL_SET_VISIBLE --> END_NODE
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `k` | `int` | Sort selection key passed from the menu screen. It identifies which sorting mode the user chose, such as Bubble Sort, Selection Sort, Quick Sort, Insertion Sort, Merge Sort, or Heap Sort. The method stores this value in the instance field `key` and does not branch on it within this method. |
| 2 | `str` | `String` | Sort display label passed from the menu screen. It carries the human-readable name of the selected sort mode, such as `BUBBLE SORT` or `HEAP SORT`. The method assigns it to the instance field `tname`, replacing two temporary hard-coded assignments. |

**External state read by the method:** `frame` is read when `frame.setVisible(true)` is executed. The method also writes to instance fields `key` and `tname`.

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `frame.setVisible(true)` | N/A | Swing `JFrame` UI state | Displays the sort screen by making the frame visible. This is a UI presentation action, not a database CRUD operation. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:Frame | `Frame.initialize()` -> `ActionListener.actionPerformed()` -> `Sortingss.vis` | `frame.setVisible(true) [R] Swing JFrame` |

## 6. Per-Branch Detail Blocks

**Block 1** — [SEQUENTIAL] `(entry processing)` (L190)

> Receives the selected sort key and label from the caller, then persists them into the current screen instance.

| # | Type | Code |
|---|------|------|
| 1 | SET | `key = k;` |
| 2 | SET | `tname = "Hello";` |
| 3 | SET | `tname = "pop";` |
| 4 | SET | `tname = str;` |

**Block 2** — [SEQUENTIAL] `(show screen)` (L194)

> Makes the sort window visible after the state has been prepared.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `frame.setVisible(true);` |
| 2 | RETURN | `return 0;` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `k` | Field/Parameter | Sort selection key used to identify the chosen sorting mode. |
| `str` | Field/Parameter | Human-readable name of the selected sort mode. |
| `key` | Field | Instance field that stores the selected sort key for later use by the screen. |
| `tname` | Field | Instance field that stores the selected sort title shown in the UI. |
| `frame` | Field | Swing window object that represents the sort screen. |
| `vis` | Method | Visibility/navigation method that prepares and shows the sort screen. |
| `ActionListener` | Technical term | Swing callback interface that reacts to button clicks. |
| `JFrame` | Technical term | Swing top-level window container. |
| Bubble Sort | Business term | Sorting mode selected from the menu, representing the bubble sort demonstration screen. |
| Insertion Sort | Business term | Sorting mode selected from the menu, representing the insertion sort demonstration screen. |
| Selection Sort | Business term | Sorting mode selected from the menu, representing the selection sort demonstration screen. |
| Merge Sort | Business term | Sorting mode selected from the menu, representing the merge sort demonstration screen. |
| Quick Sort | Business term | Sorting mode selected from the menu, representing the quick sort demonstration screen. |
| Heap Sort | Business term | Sorting mode selected from the menu, representing the heap sort demonstration screen. |
