devintersection asp.net mvc & jquery mobilesddconf.com/brands/sdd/library/lessons_from_a... ·...
TRANSCRIPT
ngLessons
K. Scott Allen
@OdeToCode
Three Things
Needs
Cautions
Plans
Need: Robust Error Handling
Catch At The Top Of The Chain
Need: Consistent Error Handling
Decorators For Instrumentation
Sanitize Decorator Output
Decorators For Debugging
Need: $http Interceptors
Use $controller With What You Need
Possibly Redefine The SUT
Use Controller As
Explicit in the view
Simplifies tests
Avoid: $rootScope Abuse
Let’s store errors
Let’s store loading messages
Let’s store user profile
Let’s store configuration constants
Think About: Your Router
Look at UI-Router
Think About: A Better $http
BreezeJS
Restangular
Caching, configuration, offline…
Resolve Pros
View appears with data ready
Easier to stay somewhere is there is an error
Easier to test controllers
Move Resolve To A Service
Think About: Authentication and
Authorization
Cookies or Tokens?
Cookies
Sent with every request
Susceptible to CSRF
Difficult to use across domains
Tokens
Offer more control, no forgeries
Work across domains
Require more code
Logins and Redirects
GET /secret redirect redirect GET /secret
Think About: Basic Abstractions
Controller
Model
Service
Directive
Filter
Think About: Code Standards
Think About: Directory Structure
I like feature based
apps
movieApp
module.js
templates
specs
js
dashboard
common
Summary
Error handling
Decorators, interceptors
Custom directives
Code style and structure