Share
Embed
Web Developer Toolbox
Talk about web development tools, workflows and best practices.
Béla Varga
June 30, 2014
Annual Pro sale · Save $30
Have presentations of your own?
Share with private links, password protection, and more control over your work.
Transcript
77 slides
-
CHIP Online | Mastertemplate deutsch BÉLA VARGA JAVASCRIPT DEVELOPER 2
twitter.com/netzzwerg github.com/netzzwerg codepen.io/netzzwerg -
CHIP Online | Mastertemplate deutsch DIE ECMANAUTEN A GROUP OF
JAVASCRIPT SPECIALISTS -
CHIP Online | Mastertemplate deutsch CODERDOJO MUNICH FREE CODING CLUB
FOR YOUNG PEOPLE CoderDojo Munich 1 -
CHIP Online | Béla Varga Why tools and workflows? 9
• Reduce Complexity • Better Maintenance • Sustainable Software Development • Process Automation • Enforces Best Practices -
CHIP Online | Béla Varga Reduce Complexity 10 • Web
has grown up after 18 years. • Huge web technology stack. • Hacks because we are working on a moving target (the web). • Web development is now a serious business. • Time to become more professional. -
CHIP Online | Béla Varga The historical change of web
development 1996 11 2014 "Best viewed with Netscape Navigator and 800x600" "The web is mobile and mobile is everywhere." JavaScript 1.0.0 ECMAScript 6 Pixel perfect design, table design Responsive web design, one-page- design, flat design, material design, parallax scrolling, interactive story telling HTML 2 HTML5 (games, sound, hardware) -
CHIP Online | Béla Varga Historical Role of an Web
Developer 12 System Developer Web Developer Web Designer Backend Developer Frontend Developer HTML5 / CSS3 Developer JavaScript Developer UI Developer UX Designer Frontend Operations Developer Operations Scrum Master Product Owner OPERATIONS DEVELOPER DESIGNER -
CHIP Online | Béla Varga Better Maintenance 13 • Big
applications are built on top of testable modules. We must bring this modular approach to the browser. • Continuous development, -integration and -deployment is only possible with the right workflow. -
"THE ONLY THING MORE EXPENSIVE THAN WRITING SOFTWARE IS WRITING
BAD SOFTWARE" ! ALAN COOPER, INTERACTION DESIGNER -
CHIP Online | Béla Varga Long-term Investment 15 • Developers
are driven by time-to- market pressure. • Fast hacking works at first, but breaks in the future. • In the long run, bad software cost more money. -
CHIP Online | Béla Varga Workflow Automation 16 • Eliminate
repetitive work. • Reduce human error. • Focus on the real problems. • Use best practices conserved in tools and frameworks. • Better performance and faster response times. -
CHIP Online | Béla Varga Workflow Topic Overview Dependency Management
Version Management A/B Testing Unit Tests Integration Tests Debugging Build System Build System Scaffolding Frameworks Task Runner Quality Management PROTOTYPING 17 DEVELOPMENT DEPLOYMENT -
CHIP Online | Béla Varga Learning Resources 19 • Mozilla
Developer Network • WebPlatform • WHATWG HTML5 Specs • ES Discuss • Google Chrome Status • Microsoft IE Status • ECMAScript 5/6 compatibility table -
CHIP Online | Béla Varga Rapid and Iterative Prototyping 22
• Communicate an idea. • Gather user feedback. • Identification of mistakes and risks. • Try and learn new technologies. • Fail fast and throw away. -
CHIP Online | Béla Varga Rapid and Iterative Prototyping 23
• Node.js (Google Chrome) • JavaScriptCore (WebKit) REPL (INTERACTIVE SHELL) • Scaffolding • Live browser reload • Cross-device synchronization LOCAL EDITING • Browser console • Live edit JS/CSS and save results (Google Chrome) IN BROWSER EDITING -
CHIP Online | Béla Varga Rapid and Iterative Prototyping 24
• Live preview and visual feedback • Libraries included • Preprocessors included • Shareable work • Collaboration ONLINE PLAYGROUND Codepen.io with Haml, SASS, CoffeeScript and LiveScript. RequireBin with npm and browserify. TDDbin with Jasmine Unit Tesing. -
CHIP Online | Béla Varga Scaffolding 26 • Kickstart your
project. • Generate the structure. • Manage dependencies. • Best practices included. • Faster development. • You should know what is inside. -
CHIP Online | Béla Varga Scaffolding with Yeoman 27 Build
System Generators Configuration Dependencies BOWER GRUNT/GULP YO -
CHIP Online | Béla Varga Scaffolding with Yeoman 28 npm
install -g grunt-cli bower npm install -g yo npm install -g generator-webapp yo webapp grunt serve bower list -
CHIP Online | Béla Varga Scaffolding with Google Web Starter
Kit 29 • Inspired by Mobile HTML5 Boilerplate and generator-gulp-webapp • Mobile-optimized HTML boilerplate. • Responsive multi-device layout. • Living component style guide. • Cross-device synchronization. • PageSpeed Insights performance reporting. -
CHIP Online | Béla Varga 30 npm install -g gulp
git clone https://github.com/google/web-starter-kit.git gulp serve npm install Scaffolding with Google Web Starter Kit -
CHIP Online | Mastertemplate deutsch MODULES & COMPONENTS TOOLS, WORKFLOWS
AND BEST PRACTICES -
KEEP IT (F)OCUSED. KEEP IT (I)NDEPENDENT. KEEP IT (R)EUSABLE. KEEP
IT (S)MALL. KEEP IT (T)ESTABLE. ! ADDY OSMANI, GOOGLE FIRST -
CHIP Online | Béla Varga Modules and Components 33 •
Decoupling Application into distinct pieces. • Loose coupling removes dependencies. • To avoid pollution of the global namespace. MODULAR APPLICATION WEB JAVASCRIPT MODULE • Object Literal Pattern • Module Pattern • AMD (Asynchronous Module Definition) • CommonJS Modules • ECMAScript 6 Modules BROWSER COMPONENT • Web Components -
CHIP Online | Béla Varga AMD (Asynchronous Module Definition) 34
• Browser-first approach. • Asynchronous behavior. • Supports objects, function, constructors, strings, ... • Incredibly flexible. • File loader library needed (RequireJS, ...) • Package manager needed (Bower, ...) Proposal for defining modules where both the module and dependencies can be asynchronously loaded. Started in the CommonJS group but moved then. -
CHIP Online | Béla Varga CommonJS Modules 35 Specification addresses
how modules should be written in order to be interoperable among a class of module systems that can be both client and server side. • Server-first approach. • Assuming synchronous behavior. • Only supports objects as modules. • Node.js module system is based on CommonJS. -
CHIP Online | Béla Varga ECMAScript 6 Modules (Draft) 36
• Declarative syntax with import, export. • Asynchronous Module Loader API. • Loads existing Libraries like jQuery and AMD Modules via hooks. • Use it now with ES6 Module Transpiler • AngularJS 2.0 will based on ES6 Modules. -
CHIP Online | Béla Varga Web Components 37 • Set
of definitions for encapsulated and reusable widgets. • Create Custom Elements with Templates. • Hides the component structure in the Shadow DOM. • Bundles widget resources together (HTML Imports). • Try it with Google Polymer.js or Mozilla X-Tag and Brick. -
CHIP Online | Béla Varga Bower Components 39 Bower is
a package manager for the web. It offers a generic, unopinionated solution to the problem of front-end package management. • Flat dependency tree. • Runs over git endpoints. • Holds any type of assets. • Use any type of module (AMD, CommonJS). • Helps to resolve dependencies. -
CHIP Online | Béla Varga Package Manager 40 BOWER packages
components NODE PACKAGE MANAGER npm install bower install package.json bower.json node_modules bower_components npmjs.org bower.io/search require (native) script loader (RequireJS) -
CHIP Online | Béla Varga Node Package Manager & Browserify
41 NODE PACKAGE MANAGER The node package manager comes preinstalled with the Node.js server. ! Tip: If the registry has problems, try the npm European Proxy BROWSERIFY Browserify is a tool that allows to write Node.js style modules that compile for use in the browser. ! With this tool it is possible now to port node modules such as url, path, stream, events and http in to the browser. -
CHIP Online | Béla Varga Development Environments 43 • python
-m SimpleHTTPServer • grunt connect (Express) • WAMP, MAMP, Fenix • Virtual Machine • Vagrant & Puppet, Chef • Docker (Linux Container LXC) -
CHIP Online | Béla Varga Version Management 45 • Try
git and learn, it is essential. • Start with master & develop branch. • Create an github account. • Commit early and often. • Make useful commit messages. • Use visual git tools (SourceTree) -
CHIP Online | Béla Varga Version Management - Gitflow Workflow
46 MASTER HOTFIX RELEASE DEVELOP FEATURE 0.1 0.2 1.0 -
CHIP Online | Béla Varga Web Application Frameworks 48 Backbone
Angular Ember VanillaJS DOM Abstraction jQuery JS Abstraction Underscore Module Loader RequireJS Plugins Mediator Polyfills & Shims MVC Router Marionette Mediator View Manager Modules React View Data Binding Dependency Injection E2E Testing ES6 Modules Web Component Conventions Unit Testing Structure More comprehensiveness More flexibility ES6 Modules Web Component -
CHIP Online | Mastertemplate deutsch JAVASCRIPT EDITOR & IDE TOOLS,
WORKFLOWS AND BEST PRACTICES -
CHIP Online | Béla Varga JavaScript Code Editor and IDE
50 IDE clean and functional workflow included CODE EDITOR fast editing for projects (.settings) single developer bigger teams extendable tools integrated (git, testing) -
CHIP Online | Béla Varga JavaScript Code Editor and IDE
51 • Invest time in learning your editor. • Avoid to change the shortcuts. • Share your editor config. • Share your settings & packages (Sublime). • Activate and configure code hinting. • Use project settings with dotfiles. -
CHIP Online | Béla Varga JavaScript Code Editor and IDE
52 • VIM (yes you should learn it) • TextMate 2 • Sublime Text 2/3 EDITOR EDITOR (WEB TEC) • Twitter Atom • Adobe Brackets IDE • NetBeans IDE • Microsoft Visual Studio 2013 • JetBrains PHP/WebStorm IDE (ONLINE) • Cloud9 IDE -
CHIP Online | Béla Varga Browser Tools 54 • Google
Chrome (Canary) DevTools • Mozilla Developer Tools • Browser Console • Plugins & Extensions • Bookmarklets -
CHIP Online | Béla Varga Browser Tools 55 • Discover
DevTools in Google Chrome • Newest features with Canary and chrome://flags • Learn the DevTool Secrets • Use Firefox Developer Tools: • WebGL Shader Editor • Web Audio Editor -
CHIP Online | Béla Varga Types of Web Application Testing
58 • Usability Testing • A/B Testing • Browser (Device) Testing • Unit Testing • End to End Testing • Integration Test • ... -
CHIP Online | Béla Varga Browser and Device Testing 59
• Synchronized Cross Device Testing • BrowserSync with Grunt/Gulp • Adobe Edge Inspect CC • Free Internet Explorer VMs • Headless Testing (PhantomJS) • Automated Cross Browser Testing (DalekJS) -
CHIP Online | Mastertemplate deutsch DEBUGGING & TRACING TOOLS, WORKFLOWS
AND BEST PRACTICES -
CHIP Online | Béla Varga Debugging and Tracing 61 •
Browser Console and console.log(); • debugger; Statement • Chrome (Canary) Dev Tools • Event Listener Breakpoints • Async Call Stack • Google Chrome chrome://tracing/ • Google Web Tracing Framework • WebStorm 8 with spy-js -
CHIP Online | Béla Varga Debugging property changes with JavaScript
62 var model = {'x': 12}; model.__defineGetter__('x', function() { debugger; }); var model = {'x': 12}; Object.defineProperty(model, 'x', {get : function(){ debugger; }}); var model = {'x': 12}; Object.observe(model, function(changes){ console.log(changes); }); Non-standard and deprecated ECMAScript 5 (IE9+ and modern Browsers) ECMAScript 6 (Google Chrome 36) -
CHIP Online | Béla Varga Task Runner - Grunt 64
• Most popular task runner. • More a task runner then build tool. • Configuration with Gruntfile.js • Extendable with Plugins (2500+) • Can be slow in bigger projects (Pint). -
CHIP Online | Béla Varga Build System - Gulp 66
• Streaming build system. • Uses node streams, vinyl • Very fast file handling and builds. • Configuration with gulpfile.js • Hard to manage errors. -
CHIP Online | Béla Varga Build System - Broccoli 67
• Inspired by the rails asset pipeline. • Faster rebuilds (incremental). • Chainable plugins. • Avoids parallel execution. • Works together with grunt as plugin. • Early beta, but under development. -
CONTINUOUS INTEGRATION (CI) IS THE PRACTICE, IN SOFTWARE ENGINEERING, OF
MERGING ALL DEVELOPER WORKING COPIES WITH A SHARED MAINLINE SEVERAL TIMES A DAY. ! WIKIPEDIA -
CHIP Online | Béla Varga Deployment 70 • rsync •
grunt-ftp-deploy • Capistrano COMMAND LINE TOOLS VERSION CONTROL • git post-commit hook informs the server, and the server pulls the changes • with git remotes git push heroku yourbranch:master CONTINUOS INTEGRATION SERVERS • Travis • Jenkins DISTRIBUTED APPLICATIONS • Puppet, Chef • Docker (Linux Container LXC) -
CHIP Online | Béla Varga Better Code Quality 72 •
Code Style Guide (pre commit hooks) • Linting and Hinting • Unit Testing • Code Coverage (Istanbul) • Source Analysis (Esprima, Plato) • Performance Metrics (grunt-devperf) • Workflows (peer review) -
CHIP Online | Béla Varga Code Standards 75 • Use
naming conventions (files, folders, classes). • It is not important which style, if it is always the same style. • Code should look like it was written by one person. • Use existing style guides (Node.js, jQuery, AirBnB). -
"BEFORE YOU CODE, THINK. BEFORE YOU WRITE, READ. BEFORE YOU
SPEAK, LISTEN. BEFORE YOU COMMENT, REFLECT. BEFORE YOU RELEASE, TEST" ! ADDY OSMANI, GOOGLE