JavaScript Applications for the Enterprise: From Empty Folders to Managed Deployments George Bochenek Randy Jones
Enterprise Development What is it? Source Control Project Organization Unit Testing Continuous Integration Moving to Production
Source Control Don t ever lose a thing!
Source Control What is it? - Tracks History of Project Other Benefits - Serves as backup - Easily share project with others Software Options - Git - Git Hub (cloud), BitBucket (cloud), Stash, Many Others - Subversion Apache Subversion, CloudForge (cloud), SubversionEdge, Many Others - Mercurial - Team Foundation Server - Many many others
Release Candidate Version Control Time tags 1.0 Trunk aka Stable Minor Feature 1 5 7 Process Trunk aka Stable Always a good build of the project Release Candidate (RC) Line that s ready for holistic testing to become a release 8 1.1 10 11 Inspired from https://gist.github.com/digitaljhelms/4287848
Branches Time tags Trunk aka Stable Minor Feature Release Candidate 1 5 Some Feature 3 6 Future Feature 2 4 Adding Features Feature Branches Major functionality, when finished merged into RC for holistic testing. Allows for frequent commits w/o effecting testing 1.0 7 8 Update 9 1.1 10 11 Inspired from https://gist.github.com/digitaljhelms/4287848
Time tags 1.0 1.1 Trunk aka Stable 8 Hotfix Release Candidate 7 Update 10 Future Feature 9 Version Control Handling Bugs Critical Bugs Need a new release. Create a branch from the tag. Merge fix to both the RC and trunk. 1.2 1.3 11 13 12 Critical Bug 14 16 Minor Bug 15 Minor Bugs handle in the Feature branch or RC depending on the feature size Its good to regularly update a feature branch from the RC 17 Inspired from https://gist.github.com/digitaljhelms/4287848
Project Organization Set-up your project for success http://www.ethnoshirts.com/images/1312%20-%20i%20love%20spaghetti.png#i%20love%20spaghetti
Look Inside A Project Folder web Folder for the web contents js Folder for all code packages and resources myapp Project specific modules and widgets share Modules and widgets shared between projects index Main app page uses hosted ArcGIS API for JavaScript and dojo loader AMD API to load our modules src Project Specific folders e.g. src for a Java Web Projects
Project Build Resources web Folder for the web contents src Project Specific folders e.g. src for a Java Web Projects build Build Resources lib Libraries to support build Profile.js Dojo Build Profile build.xml Ant Build File that perform quality checks and dojo
Moving to Production Using the dojo build process to optimize and streamline user experiences
Why Build? Building your application will increase performance A Lot. 350 300 250 200 150 100 50 0 Before Build After Build # of Requests Time to Load (10s of Milliseconds)
Build Automation Parts API Cache - Download and point to cached versions of dojo libraries and ESRI JavaScript API - https://github.com/esri/enterprise-build-sample-js Site Manager - Ensure all dependencies are stored in the define statement - Build will work through each dependency recursively Build Profile - Locates all custom and library based source code - Best practice to copy libraries before build - Layers Object - Stores localization and path to custom layer file - custombase: tells Dojo not to include all default classes - Boot: tells the build to include an AMD loader in your layer file (no need for other files)
Build ANT File Set Properties - Cache Location - Folder and Application Names - Files to save after building Run Build - Exec task points to the build profile Delete Extra Bloat - Finally, the ANT script deletes everything not specifically mentioned - This keeps the build lean for deployment
Unit Testing I swear that worked on my machine
Test Driven Development 1. Understand the Requirement 2. Write the Test 3. Build the Thing 4. Run the Test
Tools of the Trade SitePen Intern https://theintern.github.io/ Selenium Web Drive http://docs.seleniumhq.org/ Junit http://junit.org/
Estimating Tasks More People = Better Estimates Think about the Developer Remember Testing
Continuous Integration
Continuous Integration What is it? - Verify that everything works together frequently (as often as every commit) Other Benefits - Very that things work in production type builds - Verify code quality - Deploy to test servers automatically Software Options - Jenkins/Hudson - Bamboo - Team Foundation Server - Many Others
What can we do with CI Software? Run scripts/builds ant, maven, shell Verify code quality with JSLint, FindBugs, etc Run unit tests Deploy builds to application servers Run checks on every commit Run daily production test builds
Rate This Session www.esri.com/ratemydevsummitsession Get The Code www.github.com/esri/enterprise-build-sample-js