Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
Architecting ASP.NET Applications
About me
Name: Gunnar Peipman
Origin: Tallinn, Estonia
Work: Architect, developer
Microsoft: ASP.NET/IIS MVP
Community: Blogger, speaker
Blog: http://gunnarpeipman.com
Hobbies: travelling, technology, brewing
Agenda
Introduction
Server-side architecture
Client-side architecture
Performance
Get ready for changes
Server-side architecture
Understanding the application
• What are expectations on UI?
• What functionalities will be there?
• How big load we should expect?
• Are there any external services?
• How fast is system growth?
Architectural patterns
• Transaction Script
• Table Module
• Domain Model
• Service Layer
„Patterns of Enterprise Applications Architecture“
(Martin Fowler)
Transaction Script
„Organizes business logic by procedures where each
procedure handles a single request from the
presentation“
int GetNetProfitForMonth(DateTime month)
int InsertPayment(int customerId, decimal sum)
• Usually simple code using ADO.NET
• Some classes with operations + base class
Table Module
„A single instance that handles the business logic for all
rows in a database table or view.“
class Product {
Product GetById(int id)
int SaveProduct(Product product)
}
• Class per type
• All classes handle all operations related to type
Domain Model
„An object model of the domain that incorporates both
behavior and data.“
• „Living“ classes that communicate with each other
• Classes perform operations
• We can use Entity Framework or Nhibernate as ORM
Service Layer
„Defines an application's boundary with a layer of
services that establishes a set of available operations
and coordinates the application's response in each
operation.“
• Additional layer between PL and BL
• Serves UI, provides DTO-s with no relations to DB
• Easier for UI guys than Domain Model
• Better layering and separation of concerns
Our architecture now
Web application
Service Layer
Domain Model
Data Layer
Data store
• RDBMS – some relational database + ORM
• NoSQL – MongoDB, ElasticDB, DocumentDB
• Web Services – Web API, WCF, SOAP
• Files – local files, cloud storage
Our architecture now
Web application
Service Layer
Domain Model
Data Layer
MSSQL MongoDBWeb
Services
Storage
Server disk Cloud
UI architecture
UI styles
• Classic server-side code
• Some AJAX
• Single Page Application (SPA)
• Component-based (rare)
Most often your application is mix of first three.
Dynamic UI
• More complex JavaScript
• Requests for HTML and JSON
• Data provided by Web API
Web Application
Controller Model Result
JavaScript
Data Binder Model Adapter
Our achitecture now
Service Layer
Domain Model
Data Layer
MSSQL MongoDB Web Services
Storage
Server disk Cloud
JavaScript Application
Web Application Web API
Performance
Performance
• User interface
• Web application
• Data access
User interface
• Go for very well performing JavaScript and CSS
• We have no control over users machines
• Dumb user has usually way lighter computer than the
rockets we use
• Avoid chatty data layer in UI
Work together with UI guys to make sure all these
issues get addressed
Web application
Go for smaller resource consumption
• Prefer thin controllers over fat ones
• Make sure models carry data and provide
functionalities that support UI
• View must present only what model provides
• Use bundling and minification
• Use CDN-s
• Use output cache
Data access
Main focus is on data consistency and data store
performance
• Work close with DBA to make sure database
performs well
• Usually heavy optimization on ORM level is needed
• Transactions! Transactions! Transactions!
Get ready for changes
Selecting correct architecture
• Estimate size of codebase and its growth
• Have a plan for rapid growth for codebase
• Have a plan for supporting big userbase
• Some parts of application may be services in future
• Be ready to use cloud services to scale
If you application has fast growth then also architecture
changes. Stay two steps ahead of changes!
Your feedback is important!
Scan the QR Code and let us know via the TechDays App.
Laat ons weten wat u van de sessie vindt via de TechDays App!
Scan de QR Code.
Bent u al lid van de Microsoft Virtual Academy?! Op MVA kunt u altijd iets nieuws leren over de laatste technologie van Microsoft. Meld u vandaag aan op de MVA Stand. MVA biedt 7/24 gratis online training on-demand voor IT-Professionals en Ontwikkelaars.