architecting, testing and developing an mvc application
Post on 05-Aug-2015
41 Views
Preview:
TRANSCRIPT
Architecting, testing and developing an
MVC application
Who I am
• Maxime Rouiller
• ASP.NET/IIS MVP
• 10 years of experience doing web development
• Freelancer
• Twitter: @MaximRouiller
• Blog: http://blog.decayingcode.com
The Plan
• My architecture and its different advantages
• Naming is subjective but must be clear
• How do I start my projects?
• What is the project structure that I use?
• What are my NuGet packages/libraries that I use?
• How do you test MVC Controllers?
3-tier architecture
• Logic or physical architecture?
• Physical:
• Logical:
• MyProject.Web
• MyProject.Infrastructure
• MyProject.Business
Why separate your projects?
• Reusable components can actually be reused.
• Components are more easily testable
• Less likely to screw up (aka: circular references, using the wrong classes, etc.)
Should I separate WebAPI and MVC?
Some rules…
• Just like an onion… you can only depend on the layer bellow
• You can’t use a layer more than one level deep.
• Exception: When binding up a Dependency Injection tool.
My Architecture: Onion/3 tier architecture
Advantages• Easy to understand
• Easy to setup
• Reference rules can easily be enforced by a source control
Disadvantages• Depends on dependency injection
• Is not suited for very complex business logic (see Domain Driven Design)
Architecture is a tool
• If what I suggested doesn’t fit your project, DO NOT USE IT.
• Architecture is a tool. If you only know one, you’ll use it on everything
My Libraries
• Data Access: Entity Framework
• Why not <INSERT TECH HERE>?
• Inversion of Control container: Ninject
• JavaScript? Depends on the project. jQuery/AngularJS
• And more… way more smaller libraries
• Unit Testing: NUnit
• And Azure…
Your Library
• Use anything you feel comfortable!
• Please avoid NHibernate if possible
• Hard to master
• Steep learning curve
• Ensure that it uses NuGet. Why?
DemoCreating some code to test!
Unit testing a controller
Project Structure with tests
Project Structure for scaling with WebAPI
Questions?
• Contact me on Twitter: @MaximRouiller
• Blog: http://blog.DecayingCode.com
• Add me to LinkedIn
• www.MaximeRouiller.com
• Or speak to me at the break!
top related