alfresco day stockholm 2015 - rapid ui development

45
Rapid UI Development with Aikau Dave Draper Senior Software Engineer, Alfresco

Upload: nicole-szigeti

Post on 17-Feb-2017

306 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Alfresco Day Stockholm 2015 - Rapid UI Development

Rapid UI Development with Aikau

Dave DraperSenior Software Engineer, Alfresco

Page 2: Alfresco Day Stockholm 2015 - Rapid UI Development

Introduction

Page 3: Alfresco Day Stockholm 2015 - Rapid UI Development

Aikau Basics• Internally developed UI framework• Designed for re-usability, customizability and

accessibility• Initially part of Share, now an external GitHub project• Used for:

+ Share header+ Faceted search and faceted search management+ Sites management+ Custom Model Management (5.1 and 5.0 module)+ Parts of Record Management

• Best unit test code-coverage of any Alfresco project

Page 4: Alfresco Day Stockholm 2015 - Rapid UI Development

Hundreds of Modules• 25 different form controls• 20 different layout containers• 20 different menu controls• 44 different property renderers• 8 variations of lists

+ 7 list views+ 10 list view layout containers

• Document previewing• Keyboard accessible drag-and-drop framework• 30 different services

Page 5: Alfresco Day Stockholm 2015 - Rapid UI Development

Processes

Page 6: Alfresco Day Stockholm 2015 - Rapid UI Development

• Small Agile team+ Supporting internal product feature development

• Public GitHub repository• Use “GitFlow” process

+ Every Pull Request is code reviewed• One week sprints• Weekly backwards compatible releases• Zero technical debt

+ Bugs prioritized over features• Automated unit testing for regressions

+ Unit tests added for all new features+ Unit tests add for all new bugs

Page 7: Alfresco Day Stockholm 2015 - Rapid UI Development

Fast Turnaround

• Features and bugs not added mid-sprint• Maximum wait of 2 weeks to turnaround a

bug or feature request

Sprint N+1

Bug Raised Added to Sprint Fix Delivered

Sprint N

One Week

Page 8: Alfresco Day Stockholm 2015 - Rapid UI Development

Creation

Page 9: Alfresco Day Stockholm 2015 - Rapid UI Development

Page Creation Basics• An Aikau page is defined by a single WebScript

+ “Legacy” Share pages are defined by Surf Pages, Templates, Regions, Components and WebScripts

• Pages are mapped using “URI Templates”• Four templates are available out-of-the-box

+ “dp” (dynamic-page)+ “hdp” (hybrid-dynamic-page)+ “rp” (remote-page)+ “hrp” (hybrid-remote-page)

• Recommended to use “dp”• Custom templates can be defined

Page 10: Alfresco Day Stockholm 2015 - Rapid UI Development

Example URL

Page 11: Alfresco Day Stockholm 2015 - Rapid UI Development

Declarative UI

Page 12: Alfresco Day Stockholm 2015 - Rapid UI Development

Decoupled Model• Widgets decoupled from each other by

pub/sub• Widgets decoupled from data via Services

Page 13: Alfresco Day Stockholm 2015 - Rapid UI Development

Standalone Clients

Page 14: Alfresco Day Stockholm 2015 - Rapid UI Development

Easy Client Creation• Maven Archetype• Pre-configured for local Alfresco

Repository• Login and home page• Demo…

Page 15: Alfresco Day Stockholm 2015 - Rapid UI Development

“My Alfresco Files”

Page 16: Alfresco Day Stockholm 2015 - Rapid UI Development

Customization

Page 17: Alfresco Day Stockholm 2015 - Rapid UI Development

Customize…• Existing pages via extension modules

+ Use the “Developer View”• Create new or extend existing widgets• Style through LESS variables in Theme• Demo…

Page 18: Alfresco Day Stockholm 2015 - Rapid UI Development

Multi-Select Actions

Page 19: Alfresco Day Stockholm 2015 - Rapid UI Development

A New Way of Thinking

Page 20: Alfresco Day Stockholm 2015 - Rapid UI Development

Remember…• Today’s page will have tomorrow’s widgets• Use what’s available now and request

something better for tomorrow

Page 21: Alfresco Day Stockholm 2015 - Rapid UI Development

Records Management Example

Page 22: Alfresco Day Stockholm 2015 - Rapid UI Development
Page 23: Alfresco Day Stockholm 2015 - Rapid UI Development
Page 24: Alfresco Day Stockholm 2015 - Rapid UI Development

Benefits• Fast prototyping• Can work on server side code• Simple to swap out when new widgets are

available

Page 25: Alfresco Day Stockholm 2015 - Rapid UI Development
Page 26: Alfresco Day Stockholm 2015 - Rapid UI Development

Best Practices

Page 27: Alfresco Day Stockholm 2015 - Rapid UI Development

In General…• Always feedback

+ Bugs, feature requests, requests for examples and documentation, provide use cases, request extension points, etc.

• Never copy and paste+ Always extend or re-use

• Create composite widgets and libraries• Use Services to access data

+ Normalize JSON response schemas+ Avoid coupling widgets to data

• Use Pub/Sub or Events for communication+ Avoid fixed references

Page 28: Alfresco Day Stockholm 2015 - Rapid UI Development

NEVER USE A CSS OVERLAY !!!

Page 29: Alfresco Day Stockholm 2015 - Rapid UI Development

“A widget doesn’t do what I want”

• Widgets are intentionally written to be easily extendable

• Functions are small to encapsulate code that might want to be changed

• Closures are generally avoided to make functions available to be overridden or extended

• Functions can be extended or overridden+ Use this.inherited(arguments); to extend

Page 30: Alfresco Day Stockholm 2015 - Rapid UI Development

Extending a Widget

30

Page 31: Alfresco Day Stockholm 2015 - Rapid UI Development

Extending a Function

Page 32: Alfresco Day Stockholm 2015 - Rapid UI Development

Mix-In Modules• Widgets support “multiple inheritance”

+ Widgets extend a primary module and then “mix-in” additional modules

• “alfresco/core/Core” should be mixed-in to all widgets+ Provides core pub/sub and logging capabilities

• Abstract cross-cutting function to mix-in modules

• Request abstraction of existing widget code into a mix-in module

Page 33: Alfresco Day Stockholm 2015 - Rapid UI Development

Education

Page 34: Alfresco Day Stockholm 2015 - Rapid UI Development

Resources• Tutorial on GitHub

+ https://github.com/Alfresco/Aikau/blob/master/tutorial/chapters/Contents.md

• JSDoc+ http://dev.alfresco.com/resource/docs/aikau-

jsdoc/• Blogs

+ https://www.alfresco.com/blogs/developer/author/ddraper/

+ Follow me on twitter for announcements (@_DaveDraper)

Page 35: Alfresco Day Stockholm 2015 - Rapid UI Development

Questions?

Page 36: Alfresco Day Stockholm 2015 - Rapid UI Development

Debugging

Page 37: Alfresco Day Stockholm 2015 - Rapid UI Development

Debugging Methods• Console log• Publication/subscription log• Demo…

Page 38: Alfresco Day Stockholm 2015 - Rapid UI Development

JavaScript Debugging

Page 39: Alfresco Day Stockholm 2015 - Rapid UI Development

Finding Source (Chrome)• Use CTRL-P with text “surf” to find

aggregated resource• Use CTRL-F with function name to find

target

39

Page 40: Alfresco Day Stockholm 2015 - Rapid UI Development

Source Matching (Chrome)

40

Page 41: Alfresco Day Stockholm 2015 - Rapid UI Development

Finding Source (FireBug)• Use CTRL-F to find (with “Multiple Files”

option checked)

41

Page 42: Alfresco Day Stockholm 2015 - Rapid UI Development

Breakpoints• Logged error may not provide link to line

number• Break on exceptions to zero in on error

conditions• Need to include caught exceptions (Aikau

exceptions are caught)• Need to typically skip past 3rd party

exceptions on page load

42

Page 43: Alfresco Day Stockholm 2015 - Rapid UI Development

Break on Exception

43

Page 44: Alfresco Day Stockholm 2015 - Rapid UI Development

WebScript JS Debugger

44

Page 45: Alfresco Day Stockholm 2015 - Rapid UI Development

45