
UI shouldn't think about validation
I recently worked on abstracting the presentation layer from the UI layer. Ideally, the UI layer should be as dumb as possible when it comes to any non-UI logic. However, the presentation layer often suffers from a fundamental architectural flaw: it tries to decide what the UI should do. This happens either directly (passing a specific error String to display) or indirectly (passing a string resource Int identifier). The latter creates a false sense of decoupling — the presentation layer is still dictating the exact screen output. This approach breaks the Separation of Concerns (SoC). The solution is to provide enough contextual information for the UI to decide for itself how to display the error, without leaking presentation or domain logic. My specific problem area was form input validation. I needed to show UI formatting errors (e.g., length limits) while keeping input validation strictly separated from domain invariants — a distinction many developers miss. The initial solution in
Continue reading on Dev.to
Opens in a new tab




