# (DD07) Business Logic — ConsoleUI.listMembers() [5 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `ui.ConsoleUI` |
| Layer | Utility / UI Layer |
| Module | `ui` (Package: `ui`) |

## 1. Role

### ConsoleUI.listMembers()

`ConsoleUI.listMembers()` is a presentation-layer routine that retrieves the current collection of library members from the application service and renders the result directly to the console. It acts as the screen-level handler for the “list members” menu action, providing a minimal orchestration path between the user-facing menu and the underlying member list retrieval service.

The method follows a simple routing-and-display pattern: it delegates data acquisition to `libraryService.listAllMembers()`, checks whether any members were returned, and then chooses between two display outcomes. If the collection is empty, it prints a user-facing no-data message and exits early. If the collection contains records, it streams each member object to standard output using the member class’s string representation.

From a business perspective, this method supports read-only inquiry of registered members and has no create, update, or delete responsibility. It is likely invoked from the console menu as a shared screen action for operators who need a quick inventory of members currently stored in the system. The method does not transform data, persist state, or branch by business type; its only control flow is based on result presence versus absence.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["listMembers()"])
    CALL_SERVICE["Call libraryService.listAllMembers()"]
    CHECK{"members.isEmpty()?"}
    NO_MEMBERS["Print \"No members.\""]
    RETURN_NODE["Return"]
    PRINT_ALL["members.forEach(System.out::println)"]
    END_NODE["End"]

    START --> CALL_SERVICE
    CALL_SERVICE --> CHECK
    CHECK -->|Yes| NO_MEMBERS
    NO_MEMBERS --> RETURN_NODE
    CHECK -->|No| PRINT_ALL
    PRINT_ALL --> END_NODE
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| - | (none) | - | This method accepts no parameters. It operates entirely from the enclosing `ConsoleUI` instance state and the returned member collection from `libraryService.listAllMembers()`. |

**Instance fields / external state read by the method:**
- `libraryService` — service dependency used to retrieve the full member list
- Standard output (`System.out`) — console destination for business-facing messages and member display

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `libraryService.listAllMembers()` | N/A | Member collection / in-memory domain list | Reads all registered members for display in the console UI. |
| R | `System.out.println("No members.")` | N/A | N/A | Outputs the empty-state message when no member records are available. |
| R | `members.forEach(System.out::println)` | N/A | Member domain objects | Reads each returned member and prints its formatted representation to the console. |

## 5. Dependency Trace

### Pre-computed evidence from code analysis graph:

No screen/batch entry points found within 8 hops. Direct callers found: 1 method.
Terminal operations from this method: -

Trace who calls this method and what this method ultimately calls.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:ConsoleUI | `main menu switch case 5` -> `listMembers()` | `libraryService.listAllMembers() [R] Member collection` |

## 6. Per-Branch Detail Blocks

**Block 1** — **CALL** `(entry to listMembers)` (L79)

> Screen action entry point invoked from the console menu to display the member list.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `libraryService.listAllMembers();` |

**Block 2** — **IF** `(members.isEmpty())` (L80)

> Determines whether there are any registered members to show to the user.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `members.isEmpty()` |

**Block 2.1** — **THEN** `(no members found)` (L80)

> Presents an empty-state message and ends the flow immediately.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `System.out.println("No members.");` |
| 2 | RETURN | `return;` |

**Block 2.2** — **ELSE** `(members exist)` (L81)

> Iterates through the returned member collection and prints each record.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `members.forEach(System.out::println);` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `listMembers` | Method | Console screen action that displays all registered members. |
| `libraryService` | Field | Application service responsible for member-related business operations. |
| `Member` | Domain object | Registered member entity shown in the console output. |
| `members` | Variable | Collection of member records returned for display. |
| `No members.` | Message | Empty-state console message indicating that no member records exist. |
| `System.out` | Technical term | Standard console output stream used to display information to the user. |
| `forEach` | Technical term | Iteration method used to print each member record one by one. |
| `main menu switch case 5` | UI navigation | Menu option that routes the user to the member listing function. |
