Presentation is loading. Please wait.

Presentation is loading. Please wait.

Principled N-Tier Design or, a Solution to the Solution Problem Steve | ardalis.com Telerik, Inc.

Similar presentations


Presentation on theme: "Principled N-Tier Design or, a Solution to the Solution Problem Steve | ardalis.com Telerik, Inc."— Presentation transcript:

1 Principled N-Tier Design or, a Solution to the Solution Problem Steve Smith @ardalis | ardalis.com Telerik, Inc.

2 The Problem

3 Solution Level Pain Too Many Projects Too Few Projects Incorrect Abstraction The “Goldilocks” Solution – “Just right”

4 Relevant Principles Common Closure Principle Common Reuse Principle Stable Dependencies Principle Stable Abstractions Principle Separation of Concerns Dependency Inversion Principle

5 Common Closure Principle Classes that change together are packaged together.

6 Common Reuse Principle Classes that are used together are packaged together.

7 Stable Dependencies Principle Depend in the direction of stability.

8 Stable Abstractions Principle Abstractness increases with stability. Stability Abstractness Ideal Rigid Useless

9 More Principles Separation of Concerns Establish boundaries to separate behaviors and responsibilities within a system. Dependency Inversion Depend on abstractions, not concrete implementations.

10 DEMO A Simple Guestbook Application

11 Testability Testability correlates with: – Loose coupling – Separation of Concerns – Maintainability You don’t have to have unit tests to have testable code! – Unit tests prove (or disprove) testability

12 DEMO Adding “Unit” Tests

13 SMTP4DEV http://smtp4dev.codeplex.com/

14

15 Incremental Improvement From a Single Project – Separate responsibilities using folders – Add Project(s) From Many Projects – Create a new Solution with only what you need – Spin off separate applications into own solutions

16 DEMO Separation via Folders (still 1 project)

17 Problems Tests are still not unit tests – Tight coupling – Static Cling – Dependence on Data and Email Infrastructure concerns Nothing to prevent improper referencing of classes – e.g. UI code can call DAL code directly and bypass business logic UI Content Folders mixed with Application Code Folders

18 Onion Architecture aka Ports and Adapters, aka Hexagonal Architecture Core models and interfaces at center Infrastructure and Implementation depends on Core UI depends on Core and has access to Infrastructure

19 Onion Architecture

20 DEMO Introduce Abstractions and Invert Dependencies (in folders)

21 Results Yay! Unit Tests that work! Boo! Still nothing to prevent improper referencing of classes – e.g. UI code can call DAL code directly and bypass business logic Boo! Still mixing content and code folders

22 DEMO Refactor into Projects

23 Results Testable Code Separation of Concerns Loose Coupling Minimal logic in UI layer A solid foundation for a maintainable application!

24 Automate One Click Build One Click Test

25 DEMO Solution Automation – Build Scripts

26 DEMO More Tests

27 References Separation of Concerns - http://bit.ly/zWujRehttp://bit.ly/zWujRe Hexagonal Architecture - http://bit.ly/8Uxl5http://bit.ly/8Uxl5 Onion Architecture - http://bit.ly/4tWMT3http://bit.ly/4tWMT3 More Onion Architecture - http://bit.ly/NzF2Szhttp://bit.ly/NzF2Sz New is Glue - http://bit.ly/Ijn98ehttp://bit.ly/Ijn98e Pluralsight Resources N-Tier Application Design in C# http://bit.ly/Msrwighttp://bit.ly/Msrwig Design Patterns Library http://bit.ly/vyPEgKhttp://bit.ly/vyPEgK SOLID Principles of OO Design http://bit.ly/OWF4lahttp://bit.ly/OWF4la

28 Thanks! Find me at http://ardalis.comhttp://ardalis.com We’re hiring developers and trainers at Telerik! http://telerik.com/company/careers.aspx


Download ppt "Principled N-Tier Design or, a Solution to the Solution Problem Steve | ardalis.com Telerik, Inc."

Similar presentations


Ads by Google