27

Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance
Page 2: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

Architecting ASP.NET Applications

Page 3: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

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

Page 4: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

Agenda

Introduction

Server-side architecture

Client-side architecture

Performance

Get ready for changes

Page 5: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

Server-side architecture

Page 6: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

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?

Page 7: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

Architectural patterns

• Transaction Script

• Table Module

• Domain Model

• Service Layer

„Patterns of Enterprise Applications Architecture“

(Martin Fowler)

Page 8: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

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

Page 9: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

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

Page 10: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

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

Page 11: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

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

Page 12: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

Our architecture now

Web application

Service Layer

Domain Model

Data Layer

Page 13: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

Data store

• RDBMS – some relational database + ORM

• NoSQL – MongoDB, ElasticDB, DocumentDB

• Web Services – Web API, WCF, SOAP

• Files – local files, cloud storage

Page 14: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

Our architecture now

Web application

Service Layer

Domain Model

Data Layer

MSSQL MongoDBWeb

Services

Storage

Server disk Cloud

Page 15: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

UI architecture

Page 16: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

UI styles

• Classic server-side code

• Some AJAX

• Single Page Application (SPA)

• Component-based (rare)

Most often your application is mix of first three.

Page 17: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

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

Page 18: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

Our achitecture now

Service Layer

Domain Model

Data Layer

MSSQL MongoDB Web Services

Storage

Server disk Cloud

JavaScript Application

Web Application Web API

Page 19: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

Performance

Page 20: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

Performance

• User interface

• Web application

• Data access

Page 21: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

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

Page 22: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

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

Page 23: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

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!

Page 24: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

Get ready for changes

Page 25: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

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!

Page 26: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance

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.

Page 27: Architecting ASP.NET Applicationsdownload.microsoft.com/download/5/2/8/528501B8-AB...Understanding the application • What are expectations on UI? ... Table Module „Asingle instance