building disaster recovery plans with azure site recovery, hyper

93

Upload: truongngoc

Post on 01-Jan-2017

221 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Building Disaster Recovery Plans with Azure Site Recovery, Hyper
Page 2: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Building Rich Apps with AngularJS on ASP.NETJohn Papa@john_papawww.johnpapa.net

Page 3: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

The Gamification of AngularJS

You get results quickly

Page 4: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

But then you hit some walls

Page 5: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Let’s get over those

Page 6: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

@john_papaANGULARJS PATTERNS10TIPSJOHN PAPA

Page 7: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Time

Prod

uctiv

ity

Data-binding rocks!

What? I’m going back to jQuery!

Wicked cool!

Why the heck is it so difficult?!

Thumbs Up for Dependency

Injection!

OMG, how can I back out of this?

Maybe nobody will notice if I switch to Silverlight

Angular Rocks!

Modularity is the bomb!

AngularJS Emotional Scale

Page 8: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

“Building large scale apps requires some planning”

Page 9: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Demos From Today

My AngularJS courses at Pluralsighthttp://jpapa.me/spangz

Demos available on githubhttps://github.com/johnpapa/ng-demos

Work in ProgressDemos available on github

http://jpapa.me/ng-z-wip Demos available on github

https://github.com/johnpapa/ng-demos

Page 10: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Agenda1. How the Components

Fit2. HotTowel3. Coding Patterns4. Structuring Your

Project5. Modularity

6. Tracing Data7. Exception

Handling8. Rich Data9. Validation10.Local Storage /

WIP

Page 11: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

How the Components Fit Together1

Page 12: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Knowing which “thing” you need

Page 13: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Module

View Controller

FactoriesDirectives

Routes

$scope

Component Hierarchy

Page 14: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

ViewThe HTMLContains built-in AngularJS directivesng-controllerng-clickng-model{{ }}ng-repeat

Page 15: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

ControllerHandles the View’s needsPresentation logicPaired with a ViewEither directly or through delegation

Page 16: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

$scopeThe glue between the Controller and ViewThe ViewModelData (and function) binding

Page 17: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

ModulesContainers of the related featuresCan have multipleModules depending on modules

Inject functionalityLike a DLLBut not really

Page 18: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

RoutesOn URL change, go to this ViewDefines the app navigationIn module.configUse $routeProvider

Page 19: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

DirectivesHow AngularJS extends HTMLEncapsulate reusable widgetsBuilt-in directives cover the core needs

Page 20: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

FactoriesA Controller’s best friendSingleton shared servicesIdeal for abstracting LoggerLocal storageData services

Page 21: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Page 22: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Module

View Controller

FactoriesDirectives

Routes

$scope

Component Hierarchy

Page 23: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Jump-Start with HotTowel2

Page 24: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

“You don’t want to go to a SPA without one”

John Papa

Hot Towel

Page 25: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Getting started should be easy

Page 26: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Let’s remove some friction

Page 27: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Project TemplateLayoutCSSFonts

AngularOther Commonly Used Vendor ScriptsStarter FilesControllers, Views, Services

Page 28: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Page 29: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Getting HotTowel-AngularGithubhttps://github.com/johnpapa/ng-demos

Nuget

Page 30: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Jump-Start with HotTowelDEMO

Page 31: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Coding Patterns3

Page 32: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Productivity and maintainability

Page 33: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Each Component Has 1 Job

Expose functionality

Page 34: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Stay Above the Fold

Immediately Identifiable

Page 35: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

AngularJS File TemplatesVisual Studio 2013http://sidewaffle.com

WebStorm 7 and 8http://jpapa.me/ngstormtmpl

Page 36: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Coding Patterns with SideWaffleDEMO

Page 37: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Structuring Your Project4

Page 38: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Guidelines for Organizing AngularJS

Locating our code is easy

Identify code at a glance

Flat structure as long as we can

Try to stay DRY

LIFT

http://jpapa.me/1iVpwkp

Page 39: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

By Type By Feature

Page 40: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

“If someone says you are doing it wrong, ignore them”

Dan Wahlin

Structuring Your Project

Page 41: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Options for Structuring Your FilesBy Type? Folders for views, controllers, factories, directives

By Feature?Folders for Speakers, Tracks, Sessions?

Somewhere in the middle?Folders for feature, then by type?

Best Advice: Be Consistent!

http://jpapa.me/ngstructure

Page 42: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Structuring Your ProjectDEMO

Page 43: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Modularity5

Page 44: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Iterative development.

Reusable components.

Page 45: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

One Monolithic App?

Page 46: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

One Monolithic App?Reusable Components to Assemble an App

Page 47: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

ModulesContainer of related services, widgets, views, controllers

Modules can depend on other modules

Promotes iterative development

Page 48: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

ControllerFactoryDirective

Routes

Module

ConfigServiceProvider

Modules are Containers

Value

Filter

Page 49: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Categories of Dependencies

Page 50: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

modularApp

avengers dashboard widgets layout

core

ngAnimate ngRoute common ui-bootstrap

Page 51: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Modularity

DEMO

Page 52: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Tracing Data6

Page 53: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Following the path through the

components with promises

Page 54: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

View Controller Data Factory

$http

$scope

Tracing the Data Calls

Web Service

Promise handles async

response

Angular digest cycle

sees the data

Page 55: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Tracing Data in the BrowserDEMO

Page 56: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Exception Handling7

Page 57: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

1 place to handle all exceptions

Page 58: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Catch and Handle all ExceptionsLocal and Remote LoggingOptional Dev vs Debug ModesConsistency

Page 59: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Decorate the $exceptionHandler Service

Page 60: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Exception HandlingDEMO

Page 61: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Rich Data: BreezeJS8

Page 62: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

When you do more than just get data

Page 63: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Why use Rich Data?$http gives you access to the dataAfter that, how do we …Track changesManage changesets CacheShare

Page 64: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Multple views of the same object?

Page 65: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Propogate Changes?

Page 66: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Do you know which entities are dirty?

Page 67: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

SessionsTracksTimeSlots RoomsSpeakers

Page 68: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

BreezeJS

DEMO

Page 69: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Validation9

Page 70: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Do you validate changes on the clientfor a better user experience?

Page 71: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Model ValidationWhere does presentation logic belong? Validating in the HTMLRepeat same validation in many placesDoesn’t handle validating model changes

So how do we validate?

Page 72: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Validate in the model

Page 73: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Page 74: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Page 75: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Validation on the server is mandatory.

Validation on the client is a user experience.

Page 76: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Model Validation

DEMO

Page 77: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Work in Progress withLocal Storage10

Page 78: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Why risk losing lose changes?

Page 79: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

OptionsYou leave, you lose your changesLost changes

You cannot leave!Annoying pop-ups

Auto-save as the user typesWhat about invalid or incomplete data?

Give up?

Page 80: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

Work in Progress with Local StorageDEMO

Page 81: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Breeze Import/Expor

tAPI’s

Angular Directives

Local Storage

Angular Services

Key Technical Features

Page 82: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Listen to breeze

Broadcast a custom message

How Do We Know When to Stash?

Page 83: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Stash all WIP

Serialize entity, changes and

state

Exporting

Page 84: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Return the newly imported entity

Grab the stashed WIP

Import the WIP into Breeze

Import

Page 85: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Update the asterisk and counter

The WIP data

Who tells the directive when WIP

changes

WIP directiveTell the User

Page 86: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

How Do We Interact With WIP?

Page 87: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Recap1. How the Components

Fit2. HotTowel3. Coding Patterns4. Structuring Your

Project5. Modularity

6. Tracing Data7. Exception

Handling8. Rich Data9. Validation10.Local Storage /

WIP

Page 88: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Demos From Today

My AngularJS courses at Pluralsighthttp://jpapa.me/spangz

Demos available on githubhttps://github.com/johnpapa/ng-demos

Work in ProgressDemos available on github

http://jpapa.me/ng-z-wip Demos available on github

https://github.com/johnpapa/ng-demos

Page 89: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

http://pluralsight.com/training/Authors/Details/john-papa

Building Apps with Angular and Breeze

Page 90: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

ResourcesLearning

Microsoft Certification & Training Resourceswww.microsoft.com/learning

msdnResources for Developershttp://microsoft.com/msdn

TechNetResources for IT Professionalshttp://microsoft.com/technet

Sessions on Demandhttp://channel9.msdn.com/Events/TechEd

Page 91: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Complete an evaluation and enter to win!

Page 92: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

ANGULARJS PATTERNS @john_papa

Evaluate this session

Scan this QR code to evaluate this session.

Page 93: Building Disaster Recovery Plans with Azure Site Recovery, Hyper

© 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.