Loading…
Loading…
9 карточек
What is the difference between Clean Architecture and Vertical Slice Architecture?
нажми, чтобы перевернуть
Clean Architecture: dependencies point inward. Domain (entities, value objects) → Application (use cases, interfaces) → Infrastructure (EF, external APIs) → API (controllers). Lots of abstractions, IRepository for everything. Vertical Slice: one file/folder = one feature. CreateOrder.cs contains request, handler, validation, mapping. Fewer abstractions, more duplication (but scoped to the feature).
// Clean Architecture: layers
src/
Domain/ → Entities, ValueObjects, Interfaces
Application/ → UseCases, DTOs, Validators
Infrastructure/ → EfDbContext, EmailService, Redis
API/ → Controllers, Middleware
// Vertical Slice: by features
src/Features/
Users/
CreateUser.cs → Request, Handler, Validator
GetUser.cs → Request, Handler
DeleteUser.cs → Request, Handler
Orders/
CreateOrder.cs
GetOrderById.csКогда да
Clean: large teams, complex domain, long-lived project. Vertical Slice: agile, frequent features, microservices
Когда нет
Clean for a CRUD service — overengineering. Vertical Slice for complex shared domain — logic duplication
Совет на собеседовании
In an interview: 'What is Clean Architecture for?' — to protect the domain layer from external dependencies. 'Vertical Slice?' — for rapid feature development.
Свайп вправо — знаю, влево — не знаю
