skip to content

A veterinary-practice ASP.NET Core back end is growing from four developers to three teams; would you keep clean-architecture layer projects, move to vertical slices, or combine them?

level: principalimportance: should knowfreq 28%

answer

  1. where do changes cluster
  2. compiler-enforced versus convention-enforced
  3. merge conflicts follow folders
  4. Domain project plus feature-organised Application
  5. team boundaries before module boundaries

basics

~20 s

Combine them in most cases: keep a Domain project the compiler protects, and organise Application and Web by feature so each team's change lands in one folder. Layer-only projects scatter a typical feature across four projects; slices alone lose compiler-enforced direction.

solid answer

~50 s

I would look at where changes cluster. With layer projects alone, a feature such as online booking touches `Web`, `Application`, `Domain` and `Infrastructure`, so three teams edit the same four projects and the same shared folders, and merge conflicts follow. With slices alone, each feature lives in one folder, but only review or an architecture test stops one slice from reaching into another's types. The common answer for a growing team is a hybrid: a `Domain` project whose rules the compiler protects with `ProjectReference` direction, an Application layer organised by feature folders (`Features/Appointments`, `Features/Billing`), thin endpoints mapped per feature, and Infrastructure kept small. If the three teams line up with business areas such as scheduling, billing and medical records, that is the signal to go further, to modules with their own registration and data, which is a different, bigger step.

go deeper

for a junior

Be able to describe both layouts and say that one groups code by technical role and the other by feature.

for a middle

Explain what each layout makes easy and hard: finding a feature, compiler-enforced direction, merge conflicts.

for a senior

Bring evidence from a codebase you know: where changes clustered, what the boundaries caught, and what the ceremony cost per feature.

for a principal

Tie the layout to team structure and the domain's richness, recommend a path with explicit triggers for the next step, and plan an incremental migration.

## Framing the decision This is a judgement call with no single right answer. What an interviewer wants is a decision tied to evidence about the codebase and the organisation, not a preference for one diagram. The three options for an ASP.NET Core solution: - **Layer projects**: `Vet.Web`, `Vet.Application`, `Vet.Domain`, `Vet.Infrastructure`, each organised internally by technical role (`Handlers/`, `Repositories/`, `Endpoints/`). - **Vertical slices**: often one web project with `Features/<Area>/<UseCase>/` folders, each holding request, handler, validation and endpoint. - **Hybrid**: layer projects for the parts that benefit from compiler enforcement, organised by feature inside. ## Evidence to gather first 1. **Where do pull requests land?** If a typical change (add a vaccination reminder) edits files in four projects, layering by role is costing the team. 2. **How often do teams conflict?** Shared `Program.cs`, a shared `Endpoints/` folder and one giant `DbContext` configuration are the usual hot spots. 3. **How rich is the domain?** Booking rules, vaccine schedules and controlled-drug records are real invariants worth a protected `Domain` project. A CRUD-heavy admin area is not. 4. **Do teams map to business areas?** Scheduling, billing and medical records with their own data are a hint that modules, not just folders, are coming. ## Comparing the options | Concern | Layer projects | Vertical slices | Hybrid | |---|---|---|---| | Finding a feature's code | spread over 4 projects | one folder | one folder per project | | Compiler-enforced direction | yes | no, convention only | yes for Domain | | Merge conflicts across teams | high in shared role folders | low | low | | Ceremony per feature | interfaces and mapping at each boundary | minimal | moderate | | Path to modules | awkward, cuts across layers | natural | natural | ## A defensible recommendation For three teams on one veterinary back end, the hybrid usually wins: - Keep **`Vet.Domain`** as a project with no EF Core or ASP.NET Core references, so the rules shared by every team stay protected by `ProjectReference` direction. - Organise **Application** (or the web project, if Application is folded into it) by feature: `Features/Appointments/BookAppointment`, `Features/Billing/IssueInvoice`. Each team owns its feature folders. - Keep endpoints **thin** and mapped next to their feature, so `Program.cs` stops being a shared edit point. - Let handlers use the `DbContext` directly where a slice is simple, and put a specific repository in front of an aggregate only where its loading rules are subtle. What would change the answer: - A domain with few invariants and mostly reads and writes: skip the separate Domain project, go straight to slices. - Teams that need to deploy or scale independently, or that keep breaking each other's data: move toward modules with their own registration, data and public contracts, which is a separate decision from folder layout. - A regulated area such as controlled-drug logs that must be audited in isolation: carve it out first. ## Getting there incrementally A layout change on a live back end should never be a rewrite. A sequence that keeps the build green throughout: 1. Agree the target folder shape and write it down with one finished example slice, say `Features/Appointments/BookAppointment`. 2. Build every new feature in the new shape from that day on. 3. Move existing features one at a time when a team next changes them, moving endpoint, handler and request types together and running the tests after each move. 4. Delete the old role folders (`Handlers/`, `Endpoints/`) once they are empty, so there is only one way to add code. 5. Revisit after a few months using the evidence above: are pull requests now landing in one folder? The Domain project is not touched by any of this, which is part of why the hybrid is low-risk: the protected rules stay where they are while the organisation around them changes. ## How to say it State the evidence, recommend the hybrid, name the trigger for the next step. Avoid absolutes such as "clean architecture always" or "layers are dead": both layouts are used in current ASP.NET Core codebases, and the interviewer is testing whether the choice follows from the system in front of you.

  • What would you measure six months after the change to know whether it worked?
    How many projects and folders a typical pull request touches, how often teams hit merge conflicts in shared files such as `Program.cs`, and lead time for a feature change. If PRs still sprawl across areas, the feature folders do not match how work is actually split.
  • How would you migrate an existing layer-organised solution without a big-bang rewrite?
    Move one feature at a time: create its feature folder, move the endpoint, handler and request types into it, keep Domain untouched, and run the test suite after each move. New features start in the new shape. Once the old role folders are empty, delete them.

  • Clean architecture is always right once more than one team works on the code.
  • Vertical slices cannot coexist with a separate Domain project.
  • Folder layout alone will stop three teams breaking each other's data.
  • The layout choice is purely aesthetic and does not affect merge conflicts.