# Design An Immutable UI Model

> Model a screen with clear, immutable state, then change the state contract yourself.

- URL: https://dantech.academy/en/courses/kotlin-accelerator/engineer-builder/02-compose-ui-from-state/lesson-01-design-immutable-ui-models
- Course: [Mobile Action Pro](https://dantech.academy/en/courses/kotlin-accelerator.md)
- Module: Compose UI from State
- Duration: 10 min
- Difficulty: beginner
- Access: Enrolled students
- Tiếng Việt: https://dantech.academy/courses/kotlin-accelerator/engineer-builder/02-compose-ui-from-state/lesson-01-design-immutable-ui-models.md

## Objectives

- Design an immutable UiState with data class, val and ImmutableList
- Model screen modes with a sealed UiState instead of loose flags
- Change a Compose UI state contract directly and validate it with unit tests

## In this lesson

1. Lesson Goal
2. Part 1: A Screen Is A Set Of States
3. Part 2: A Data Contract Is Not A UI Model
4. Part 3: Immutability Is The Key To Composables
5. Part 4: Close Off The Screen Modes With Sealed State
6. Part 5: Why Loose Flags Are A Red Flag
7. Part 6: Drill 1, Change The Number Of Skeleton Rows
8. Part 7: Drill 2, Add A Sealed Variant
9. Part 8: What Belongs In Persistent UI State?
10. Code Reading Path
11. Checkpoint
12. Bad Smells

## Study with an AI agent

The full lesson is for students of this course. Students open the lesson on the web and press **Markdown** to copy all of it, then paste it into Claude, ChatGPT, Cursor or whichever agent you use. Faster: mint a token at `/profile/ai-agents` and your agent reads lessons over MCP.

- [Join the course](https://dantech.academy/en/kotlin-accelerator/checkout)

---

- Previous lesson: [The Multiplatform Data Stack](https://dantech.academy/en/courses/kotlin-accelerator/engineer-builder/01-shared-kmp-foundations/lesson-04-kmp-data-stack.md)
- Next lesson: [Manage User Intent With Sealed Actions](https://dantech.academy/en/courses/kotlin-accelerator/engineer-builder/02-compose-ui-from-state/lesson-02-model-user-intent-with-sealed-actions.md)
