Top Banner
Učinkovita arhitektura modernih aplikacij Damir Arh, Adacta d.o.o. Arhitekt programske opreme MVP – Visual C#
22

Effective Architecture of Modern Applications

Nov 28, 2014

Download

Technology

Damir Arh

Architectural guidance for development of apps for Windows Store in Windows 8.1
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Effective Architecture of Modern Applications

Učinkovita arhitektura modernih aplikacijDamir Arh, Adacta d.o.o.Arhitekt programske opremeMVP – Visual C#@DamirArh, damirscorner.com

Page 2: Effective Architecture of Modern Applications

• Model-View-ViewModel• ViewModelLocator• IoC Container• Unit testing• Mocking• Razvoj za več platform• Modularnost

Agenda

Page 3: Effective Architecture of Modern Applications

• Ločitev odgovornosti• Lažje testiranje• Neodvisnost kode od podobe

Cilji uporabe arhitekturnih vzorcev

Page 4: Effective Architecture of Modern Applications

Model-View-ViewModel

View• XAML• Data binding

ViewModel• Priprava podatkov• Podpora interakciji

Model• Dostop do podatkov

• Poslovna logika

• http://bit.ly/PrismWinRT• http://bit.ly/MvvmLight• http://bit.ly/CaliburnMicro • http://bit.ly/MvvmCross

Page 5: Effective Architecture of Modern Applications

Osnovno ogrodje aplikacije

Page 6: Effective Architecture of Modern Applications

Drugačni podatki za designer

View Mode

l

Runtime

model

Designer

model

Page 7: Effective Architecture of Modern Applications

Dependency injection in view model locator

Page 8: Effective Architecture of Modern Applications

Dependency Injection

Web Service

View Model

Repository

Page 9: Effective Architecture of Modern Applications

Dependency Injection

Web Service

View Model

Repository

IRepository

Page 10: Effective Architecture of Modern Applications

Dependency Injection

Web Service

View Model

Repository

IRepository

Page 11: Effective Architecture of Modern Applications

Dependency Injection

Web Service

View Model

Repository

IRepositoryIoC Container

Page 12: Effective Architecture of Modern Applications

IoC Container

Page 13: Effective Architecture of Modern Applications

• Premik odvisnosti v ločen razred• Abstrakcija prek vmesnika• Zunanje instanciranje odvisnih razredov• Uporaba ogrodja IoC• http://bit.ly/Autofac• http://bit.ly/NinjectPcl• http://bit.ly/UnityIoC

Ključni poudarki

Page 14: Effective Architecture of Modern Applications

• Testiranje asinhronih metod• Referenca na aplikacijo za Windows Store• Izvajanje testov v peskovniku

• Predloga za Unit Test Library, MSTest• Izvajalniki testov• Visual Studio Test Runner• ReSharper• NCrunch

Testiranje razredov

Page 15: Effective Architecture of Modern Applications

Testiranje aplikacij za Windows Store

Page 16: Effective Architecture of Modern Applications

• Slabost prikazanega testa• Vhodne podatke fiksno določa uporabljeni model

• Rešitev?• Implementacija modela z nastavljivimi rezultati funkcij

• Težava?• Dinamično generiranje zbirov ni podprto• http://bit.ly/MoqaLate• http://bit.ly/MoqRT

Mocking

Page 17: Effective Architecture of Modern Applications

Implementacija testnega modela

Page 18: Effective Architecture of Modern Applications

• Raznolikost mobilnih platform• Windows 8 / Windows Phone 8• iOS• Android

• .NET in C# prisotna na vseh• Windows Store / Windows Phone 8• Xamarin.iOS• Xamarin.Android

Razvoj za več platform

Page 19: Effective Architecture of Modern Applications

Portable Class Library

Page 20: Effective Architecture of Modern Applications

• Skupna poslovna logika vsem platformam• Ista knjižnica uporabna brez ponovnega prevajanja• Enkraten razvoj in enkratno testiranje

• Ločen uporabniški vmesnik• Vsaka platforma ima svoje posebnosti• Podobnost Windows Store in Windows Phone 8• http://bit.ly/MvvmCross

Koristi PCL

Page 21: Effective Architecture of Modern Applications

• MEF (Manage Extensibility Framework)• Microsoft.Composition

• Izvajanje v peskovniku• Dinamično nalaganje zbirov ni mogoče• Vsi zbiri morajo biti del paketa aplikacije in znani vnaprej

• Statična modularnost• Moduli znani v času prevajanja• MEF : IoC

• Kompozitni uporabniški vmesnik• Event aggregation / Service bus

Modularnost

Page 22: Effective Architecture of Modern Applications

• Šibka sklopljenost• Izolirane dodelave• Enostavna zamenjava gradnikov• Testiranje posameznih funkcionalnosti

• Podpora več platformam• Skupni storitveni nivo• Skupna poslovna logika na odjemalcih• Skupni view modeli z uporabo MvvmCross

Prednosti dobre arhitekture