In my apps, I usually create a "Core" project separate from the web project.
Core project contains:
- Business objects, such as entities and such
- Data access
- Anything that is not specifically designed for web
Web project contains:
- Controllers, which route requests from the UI to the core logic
- Views, which focus on presenting data in HTML
- View Models, which flatten/transform core business objects into simpler structures designed to support specific views
The key point here is that the web-based Models folder/namespace is ONLY used for presentation-specific models that document the specific variables needed for a given view. As much "business logic" as possible goes into the core project.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…