net architecture for enterprises

208
.NET Architecture for Enterprises Wade Wegner Architect, Microsoft Corporation [email protected] http://www.architectingwith.net/

Upload: wade-wegner

Post on 10-May-2015

2.678 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: NET Architecture for Enterprises

.NET Architecturefor Enterprises

Wade WegnerArchitect, Microsoft [email protected]://www.architectingwith.net/

Page 2: NET Architecture for Enterprises

First, a story …

Page 3: NET Architecture for Enterprises

First, a story …personal^

Page 4: NET Architecture for Enterprises

There once was a developer …

Page 5: NET Architecture for Enterprises

… who really enjoyed coding …

Page 6: NET Architecture for Enterprises

.NET

Python

JavaScript

HTML

Web Services

BizTalk

Tibco

SQL Server

OracleAS/400

Window Server

Apache

IIS

SOA

Page 7: NET Architecture for Enterprises

… and then one day …

Page 8: NET Architecture for Enterprises

… through no fault of his own …

Page 9: NET Architecture for Enterprises

… someone called him an architect.

Page 10: NET Architecture for Enterprises
Page 11: NET Architecture for Enterprises

How did this happen?

Page 12: NET Architecture for Enterprises

Was he suddenly adifferent person?

Page 13: NET Architecture for Enterprises

Did he now need to careabout different things?

Page 14: NET Architecture for Enterprises
Page 15: NET Architecture for Enterprises

Goals

Page 16: NET Architecture for Enterprises

Leave with a better understandingof architecture

Goals

Page 17: NET Architecture for Enterprises

Leave with a better understandingof architecture

Goals

software^

Page 18: NET Architecture for Enterprises

Understand the practical aspectsof architecture in .NET

Goals

Page 19: NET Architecture for Enterprises
Page 20: NET Architecture for Enterprises

What is architecture?

Page 21: NET Architecture for Enterprises

Why should I care?

Page 22: NET Architecture for Enterprises
Page 23: NET Architecture for Enterprises

How is software architecturedifferent?

Page 24: NET Architecture for Enterprises
Page 25: NET Architecture for Enterprises

Determining how to do something

Page 26: NET Architecture for Enterprises

Making expensive andhard-to-change decisions

Page 27: NET Architecture for Enterprises

Who is the architect?

Page 28: NET Architecture for Enterprises
Page 29: NET Architecture for Enterprises

Are there different typesof architects?

Page 30: NET Architecture for Enterprises

Are architects project managers?

Page 31: NET Architecture for Enterprises

Should architects write code?

Page 32: NET Architecture for Enterprises

Do architects just focuson abstractions?

Page 33: NET Architecture for Enterprises
Page 34: NET Architecture for Enterprises

Poor software typicallyhas one of two causes …

Page 35: NET Architecture for Enterprises

… insufficient skills.

Page 36: NET Architecture for Enterprises

… contradictory and ambiguousrequirements.

Page 37: NET Architecture for Enterprises

Anyone can write codethat just works.

Page 38: NET Architecture for Enterprises
Page 39: NET Architecture for Enterprises

Our goal should be …

Page 40: NET Architecture for Enterprises

… to write good codethat works.

Page 41: NET Architecture for Enterprises

Why?

Page 42: NET Architecture for Enterprises
Page 43: NET Architecture for Enterprises

For poorly written code“that just works”…

Page 44: NET Architecture for Enterprises

… maintenance is expensive

Page 45: NET Architecture for Enterprises

… maintenance is frustrating

Page 46: NET Architecture for Enterprises

… maintenance is time consuming

Page 47: NET Architecture for Enterprises
Page 48: NET Architecture for Enterprises

How do we write good codethat works?

Page 49: NET Architecture for Enterprises
Page 50: NET Architecture for Enterprises
Page 51: NET Architecture for Enterprises
Page 52: NET Architecture for Enterprises

Tenets of Structured Design

Page 53: NET Architecture for Enterprises

Cohesion

Tenets of Structured Design

Page 54: NET Architecture for Enterprises

Coupling

Tenets of Structured Design

Page 55: NET Architecture for Enterprises

Low coupling &High cohesion

Tenets of Structured Design

Page 56: NET Architecture for Enterprises
Page 57: NET Architecture for Enterprises

Separation of Concerns

Page 58: NET Architecture for Enterprises

Identifying the concerns

Separation of Concerns

Page 59: NET Architecture for Enterprises

Modularity

Separation of Concerns

Page 60: NET Architecture for Enterprises

Information hiding

Separation of Concerns

Page 61: NET Architecture for Enterprises
Page 62: NET Architecture for Enterprises

So, what are some principles that make this easier?

Page 63: NET Architecture for Enterprises

Find Pertinent Objects First

Principles

Page 64: NET Architecture for Enterprises

Find Pertinent Objects First

Principles

To view all orders placed by a customer, the user indicates the customer ID. The program displays an error message if the customer does not exist. If the customer exists, the program displays name, address, date of birth, and all outstanding orders. For each order, the program gets ID, date, and all order items.

Page 65: NET Architecture for Enterprises

Favor Low Coupling

Principles

Page 66: NET Architecture for Enterprises

Favor Low Coupling

Principles

Program to an interface, not an implementation

Page 67: NET Architecture for Enterprises

Favor Code Reuse

Principles

Page 68: NET Architecture for Enterprises

This is great, we know this …so, what else is there?

Page 69: NET Architecture for Enterprises

Open/Closed Principle

Advanced Principles

Page 70: NET Architecture for Enterprises

Liskov’s Substitution Principle

Advanced Principles

Page 71: NET Architecture for Enterprises

Dependency Inversion Principle

Advanced Principles

Page 72: NET Architecture for Enterprises

Dependency Inversion Principle

Advanced Principles

public class Foo{

IDoSomething _doSomething = null;

public Foo(IDoSomething doSomething){

_doSomething = doSomething;}

}

Page 73: NET Architecture for Enterprises
Page 74: NET Architecture for Enterprises

Patterns

Page 75: NET Architecture for Enterprises

Design Patterns

Patterns

Page 76: NET Architecture for Enterprises

Architectural Patterns

Patterns

Page 77: NET Architecture for Enterprises

Antipatterns

Patterns

Page 78: NET Architecture for Enterprises

Patterns are not …

Page 79: NET Architecture for Enterprises

… a verb

Patterns are not …

Page 80: NET Architecture for Enterprises

… superhuman

Patterns are not …

Page 81: NET Architecture for Enterprises

… inherently good nor evil

Patterns are not …

Page 82: NET Architecture for Enterprises
Page 83: NET Architecture for Enterprises

Testability & Security

Page 84: NET Architecture for Enterprises
Page 85: NET Architecture for Enterprises

Testability

Page 86: NET Architecture for Enterprises

Software Testing

Testability

Page 87: NET Architecture for Enterprises

Software Contracts

Testability

Page 88: NET Architecture for Enterprises

Unit Testing

Testability

Page 89: NET Architecture for Enterprises

Dealing with Dependencies

Testability

Page 90: NET Architecture for Enterprises

Fakes to Mocks

Testability

Page 91: NET Architecture for Enterprises
Page 92: NET Architecture for Enterprises

Security

Page 93: NET Architecture for Enterprises

Security as a requirement

Security

Page 94: NET Architecture for Enterprises

Security Development Lifecycle

Security

Page 95: NET Architecture for Enterprises

Layering

Security Development Lifecycle

Page 96: NET Architecture for Enterprises

Componentization

Security Development Lifecycle

Page 97: NET Architecture for Enterprises

Roles

Security Development Lifecycle

Page 98: NET Architecture for Enterprises

Threat models

Security

Page 99: NET Architecture for Enterprises
Page 100: NET Architecture for Enterprises

Okay, is this it?

Page 101: NET Architecture for Enterprises

Interesting, but abstract

Page 102: NET Architecture for Enterprises

How does this help me design my system?

Page 103: NET Architecture for Enterprises
Page 104: NET Architecture for Enterprises

Let’s look at the common layers of any system …

Page 105: NET Architecture for Enterprises

The Business Layer

Page 106: NET Architecture for Enterprises

The Service Layer

Page 107: NET Architecture for Enterprises

The Data Access Layer

Page 108: NET Architecture for Enterprises

The Presentation Layer

Page 109: NET Architecture for Enterprises
Page 110: NET Architecture for Enterprises

The Business Layer

Page 111: NET Architecture for Enterprises

What is it?

The Business Layer

Page 112: NET Architecture for Enterprises

Domain’s Object Model

The Business Layer

Page 113: NET Architecture for Enterprises

Domain Entities

The Business Layer

Page 114: NET Architecture for Enterprises

Business Rules

The Business Layer

Page 115: NET Architecture for Enterprises

Validation

The Business Layer

Page 116: NET Architecture for Enterprises

Business Process & Workflow

The Business Layer

Page 117: NET Architecture for Enterprises
Page 118: NET Architecture for Enterprises

Where do you deploy it?

The Business Layer

Page 119: NET Architecture for Enterprises

The Gray Areas

The Business Layer

Page 120: NET Architecture for Enterprises

Data Formatting

The Business Layer – Gray Areas

Page 121: NET Architecture for Enterprises

CRUD

The Business Layer – Gray Areas

Page 122: NET Architecture for Enterprises

Stored Procedures

The Business Layer – Gray Areas

Page 123: NET Architecture for Enterprises
Page 124: NET Architecture for Enterprises

Patterns

The Business Layer

Page 125: NET Architecture for Enterprises

The Transaction Script Pattern

The Business Layer

Page 126: NET Architecture for Enterprises

The Table Module Pattern

The Business Layer

Page 127: NET Architecture for Enterprises

The Active Record Pattern

The Business Layer

Page 128: NET Architecture for Enterprises

The Domain Model Pattern

The Business Layer

Page 129: NET Architecture for Enterprises
Page 130: NET Architecture for Enterprises

The Service Layer

Page 131: NET Architecture for Enterprises

What is it?

The Service Layer

Page 132: NET Architecture for Enterprises

What’s service orientation?

The Service Layer

Page 133: NET Architecture for Enterprises

What about SOA?

Page 134: NET Architecture for Enterprises

Service-Oriented Architecture

The Services Layer

Page 135: NET Architecture for Enterprises

Tenets of SOA

The Services Layer

Page 136: NET Architecture for Enterprises

Boundaries Are Explicit

Tenets of SOA

Page 137: NET Architecture for Enterprises

Services Are Autonomous

Tenets of SOA

Page 138: NET Architecture for Enterprises

Use Contracts, Not Classes

Tenets of SOA

Page 139: NET Architecture for Enterprises

Compatibility Is Based on Policy

Tenets of SOA

Page 140: NET Architecture for Enterprises

What SOA is not …

Page 141: NET Architecture for Enterprises

… a revolution

SOA is not …

Page 142: NET Architecture for Enterprises

… a technology

SOA is not …

Page 143: NET Architecture for Enterprises

… a web service

SOA is not …

Page 144: NET Architecture for Enterprises

… a goal

SOA is not …

Page 145: NET Architecture for Enterprises
Page 146: NET Architecture for Enterprises

The Data Access Layer

Page 147: NET Architecture for Enterprises

What is it?

The Data Access Layer

Page 148: NET Architecture for Enterprises

Requirements

The Data Access Layer

Page 149: NET Architecture for Enterprises

Database Independence

DAL: Requirements

Page 150: NET Architecture for Enterprises

Configurable as a Plug-in

DAL: Requirements

Page 151: NET Architecture for Enterprises

Persisting the Application’sObject Model

DAL: Requirements

Page 152: NET Architecture for Enterprises

Responsibilities

The Data Access Layer

Page 153: NET Architecture for Enterprises

CRUD services

DAL: Responsibilities

Page 154: NET Architecture for Enterprises

Query services

DAL: Responsibilities

Page 155: NET Architecture for Enterprises

Transactions

DAL: Responsibilities

Page 156: NET Architecture for Enterprises

Concurrency

DAL: Responsibilities

Page 157: NET Architecture for Enterprises

Separated Interface Pattern

The Data Access Layer

Page 158: NET Architecture for Enterprises

The Plugin Pattern

The Data Access Layer

Page 159: NET Architecture for Enterprises
Page 160: NET Architecture for Enterprises

Should you write your own DAL?

The Data Access Layer

Page 161: NET Architecture for Enterprises

O/RMs

The Data Access Layer

Page 162: NET Architecture for Enterprises

Entity Framework

EntitySpaces

NHibernate

Genome

LINQ-to-SQL

LLBLGen Pro

Page 163: NET Architecture for Enterprises

Using an O/RM Tool

The Data Access Layer

Page 164: NET Architecture for Enterprises

Stored Procedures?

The Data Access Layer

Page 165: NET Architecture for Enterprises

SPs are faster than SQL code

DAL: Stored Procedure Myth #1

Page 166: NET Architecture for Enterprises

SPs are more secure than SQL code

DAL: Stored Procedure Myth #2

Page 167: NET Architecture for Enterprises

SPs can be used to fend off SQL injection

DAL: Stored Procedure Myth #3

Page 168: NET Architecture for Enterprises

SPs can be used to reduce brittleness of SQL code

DAL: Stored Procedure Myth #4

Page 169: NET Architecture for Enterprises
Page 170: NET Architecture for Enterprises

Stop! What are you saying?

Page 171: NET Architecture for Enterprises

Do we still need DBAs?

Page 172: NET Architecture for Enterprises
Page 173: NET Architecture for Enterprises
Page 174: NET Architecture for Enterprises

The Presentation Layer

Page 175: NET Architecture for Enterprises

Responsibilities

The Presentation Layer

Page 176: NET Architecture for Enterprises

Validation?Formatting?

Styling?Usability?

PL: Responsibilities

Page 177: NET Architecture for Enterprises

Independence from graphics

PL: Responsibilities

Page 178: NET Architecture for Enterprises

Independence from UI Technology

PL: Responsibilities

Page 179: NET Architecture for Enterprises

Testability

PL: Responsibilities

Page 180: NET Architecture for Enterprises

Independence from data model

PL: Responsibilities

Page 181: NET Architecture for Enterprises

Patterns

The Presentation Layer

Page 182: NET Architecture for Enterprises

Model-View-Controller (MVC)

PL: Patterns

Page 183: NET Architecture for Enterprises

Model-View-Presenter (MVP)

PL: Patterns

Page 184: NET Architecture for Enterprises

How do I choose a pattern?

The Presentation Layer

Page 185: NET Architecture for Enterprises
Page 186: NET Architecture for Enterprises

Summary

Page 187: NET Architecture for Enterprises

Defined Architecture

Summary

Page 188: NET Architecture for Enterprises

Described Architects

Summary

Page 189: NET Architecture for Enterprises

Maintainability

Summary

Page 190: NET Architecture for Enterprises

Low coupling & high cohesion

Summary

Page 191: NET Architecture for Enterprises

Principles of software architecture

Summary

Page 192: NET Architecture for Enterprises

Design patterns

Summary

Page 193: NET Architecture for Enterprises

Architecture patterns & antipatterns

Summary

Page 194: NET Architecture for Enterprises

Testability & Security

Summary

Page 195: NET Architecture for Enterprises

The Business Layer

Summary

Page 196: NET Architecture for Enterprises

The Services Layer

Summary

Page 197: NET Architecture for Enterprises

The Data Access Layer

Summary

Page 198: NET Architecture for Enterprises

The Presentation Layer

Summary

Page 199: NET Architecture for Enterprises
Page 200: NET Architecture for Enterprises

Closing thoughts …

Page 201: NET Architecture for Enterprises

“It” depends

Closing thoughts …

Page 202: NET Architecture for Enterprises

Requirements

Closing thoughts …

Page 203: NET Architecture for Enterprises

Reuse is a nice side effect

Closing thoughts …

Page 204: NET Architecture for Enterprises

Separation of Concerns

Closing thoughts …

Page 205: NET Architecture for Enterprises

Maintainability

Closing thoughts …

Page 206: NET Architecture for Enterprises

Don’t trust your users

Closing thoughts …

Page 207: NET Architecture for Enterprises

Security and testability by design

Closing thoughts …

Page 208: NET Architecture for Enterprises

© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS,

IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

[email protected]://architectingwith.net