WORKSHOP: BUILDING A WEBAPP STEP BY STEP by Ohad Kravchick Fluent 2013 May 28th, 2013 Rate me:

Slides:



Advertisements
Similar presentations
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Advertisements

MMDE5011 – INTERACTIVE MEDIA PRACTICE 1 WEEK 1: INTRODUCTION TO HTML5
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
John Culviner johnculviner.com DEMO CODE:
Developing HTML5 Application using MVVM pattern Pekka Ylenius.
The Web Warrior Guide to Web Design Technologies
Introduction to Model-View-Controller (MVC) Web Programming with TurboGears Leif Oppermann,
Chapter 16 Dynamic HTML and Animation The Web Warrior Guide to Web Design Technologies.
Does Ajax suck? CS575 Spring 2007 Chanwit Suebsureekul.
Development of mobile applications using PhoneGap and HTML 5
Overview of JSP Technology. The need of JSP With servlets, it is easy to – Read form data – Read HTTP request headers – Set HTTP status codes and response.
Windows.Net Programming Series Preview. Course Schedule CourseDate Microsoft.Net Fundamentals 01/13/2014 Microsoft Windows/Web Fundamentals 01/20/2014.
Chapter 4 Dreamweaver: Part II The Web Warrior Guide to Web Design Technologies.
NextGen Technology upgrade – Synerizip - Sandeep Kamble.
Advanced CSS - Page Layout. Advanced CSS  Compound Selectors:  Is a Dreamweaver term, not a CSS term.  Describes more advanced types of selectors such.
Pittsburgh Java User Group– Dec Java PureFaces: A JSF Framework Extension.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Advanced Web Design Scripting Tutorial Chapters. Scripting Intro The scripting part of the forthcoming Advanced Web Design textbook introduces you to.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Chapter 2 Developing a Web Page. A web page is composed of two distinct sections: –The head content –The body Creating Head Content and Setting Page Properties.
Unit 1 – Web Concepts Instructor: Brent Presley. ASSIGNMENT Read Chapter 1 Complete lab 1 – Installing Portable Apps.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
SERVER web page repository WEB PAGE instructions stores information and instructions BROWSER retrieves web page and follows instructions Server Web Server.
JSP Java Server Pages Softsmith Infotech.
Javascript: More features B. Ramamurthy 7/4/2014B. Ramamurthy, CSE651C1.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
DSpace UI Alexey Maslov. DSpace in general A digital library tool useful for storage, maintenance, and retrieval of digital documents Two types of interaction:
Lecture 19 Web Application Frameworks Boriana Koleva Room: C54
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Presented by Graduate Design Group 2 Meredith, Jennifer, Cammay and Diane.
Strategies for Building Mobile Apps Using ArcGIS API for JavaScript Andy Gup, Lloyd Heberlie.
Embedded Software SKKU 14 1 Sungkyunkwan University Tizen v2.3 Application Profiling & Debugging.
Session: 1. © Aptech Ltd. 2Introduction to the Web / Session 1  Explain the evolution of HTML  Explain the page structure used by HTML  List the drawbacks.
Overview of Form and Javascript fundamentals. Brief matching exercise 1. This is the software that allows a user to access and view HTML documents 2.
® IBM Software Group © 2006 IBM Corporation Web JSF Overview – RBD Tooling – for Web Development This unit introduces you to the aspects of the RBD tooling.
Plug-in Architectures Presented by Truc Nguyen. What’s a plug-in? “a type of program that tightly integrates with a larger application to add a special.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Testing Your Alfresco Add-ons Michael Suzuki Software Engineer.
Wes Preston DEV 202. Audience: Info Workers, Dev A deeper dive into use-cases where client-side rendering (CSR) and SharePoint’s JS Link property can.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
//liveVirtualacademy2011/ What’s New for ASP.NET 4.5 and Web Development in Visual Studio 11 Developer Preview Γιώργος Καπνιάς MVP, MCT, MCDP, MCDBA, MCTS,
 A Javascript library designed to simplify client-side scripting of HTML.
AngularJS and SharePoint
Vineel Vutukuri. What is SPA? Why SPA? Pros & Cons When to use SPA?
Week 1: Introduction to HTML and Web Design
Introduction to.
Angular 4 + TypeScript Getting Started
Google Web Toolkit Tutorial
ASP.NET Core Tag Helpers
Haritha Dasari Josue Balandrano Coronel -
Build Better Apps with MEAN.
IS1500: Introduction to Web Development
APTECH JANAKPURI INSTITUTE PROVIDING WEB DESIGNING COURSES Address:- J-1,2nd Floor, Opp Metro Pillar No – 559, Janakpuri East, Delhi /42.
Prepared for Md. Zakir Hossain Lecturer, CSE, DUET Prepared by Miton Chandra Datta
SPA Revolution with WebAssembly and Blazor Rainer Stropek | software
SPA Revolution with WebAssembly and Blazor Rainer Stropek | software
Modern web applications
Module P3 Practical: Building a webapp in nodejs and
Modern web applications
Teaching slides Chapter 6.
WPS - your story so far Seems incredible complicated, already
Web Page Layout Imran Rashid CTO at ManiWeber Technologies.
Web Development 101 Workshop
ASP.NET Imran Rashid CTO at ManiWeber Technologies.
Web Client Side Technologies Raneem Qaddoura
Web Programming and Design
Week 5: Recap and Portfolio Site
Web Programming and Design
Presentation transcript:

WORKSHOP: BUILDING A WEBAPP STEP BY STEP by Ohad Kravchick Fluent 2013 May 28th, 2013 Rate me: Grab me:

Overview Introduction Setting up a simple skeleton app using HTML, JS, CSS, Require.js, and Backbone Building a Simple Model and View classes, and testing them Taking our classes to the next level Automating our continuous integration and deployment processes Conclusion 2

INTRODUCTION

Introduction What is a single-page webapp? How should we use our HTML and DOM, JS, CSS? Setting up a good coding strategy: good tools and dev environment, modularizing code, test-driven development, continuous integration As always, think about your users: page load time, network traffic, caching 4

Single-page webapp? What is a single-page webapp? What does one entail? Should I build one? Plugging everything yourself vs. using a monolithic framework 5

What is a single-page webapp? One main HTML file One screen at any given time Generating (or toggling) other screens dynamically, using JS Instead of navigating between different pages, one navigates between different sections of one web page Maintaining state – what’s currently in the DOM Maintaining data – what’s needed for generating DOM 6

How should we use our HTML and DOM? HTML should hold all markup Your application’s viewport Dynamic content – in templates DOM should not hold data, but UI Should probably contain only what’s visible to the user 7

How should we use our JavaScript? Modularize your JavaScript Use an MV* framework as a start Organize code into files and folders We will use Require.js to not penalize our users Use one coding style Tests require even more code modularity for simulating code interactions (stubbing) Don’t try to “privatize”; allow for overriding 8

How should we use our CSS? Break CSS into smaller files Use a CSS preprocessor to concatenate imports Since our JS code and HTML templates are modularized, we can strive the same for CSS Module-based CSS 9

Combining it all Your code is modularized into units/components You can match JS and CSS, and even template file structure During development, you want to see/debug all the files In production, you want to concat, minify, and uglify as much as possible 10

Test-driven development When you create your JS and CSS files, also create your test files Start by writing simple tests against the core of the code Write code, run tests, loop until green Write more tests – edge cases, interactions, load The process takes some time to adjust to, but is simply awesome 11

BUILDING A SKELETON

Our basic application – a news reader Main screen – showing all headlines with images (henceforth a Section page) Clicking on any article, brings up the full article (henceforth an Article page) Clicking on a Back button in the Article page, brings you back to the Section page 13

Section Page List of stories Later: Spinner while loading 14

Article Page Entire article content Back button Later: Spinner while loading 15

On a device 16

Code structure HTML file – reader.html Includes reader.js and all our JS And includes reader.css and all our CSS 17

Demo – code structure Boilerplate HTML markup Boilerplate JS markup + onload invocation Boilerplate CSS markup + reset css Fork it: 18

Demo Exercise - Layout FlexBox ( ) Build the 3-column UI using FlexBox don’t worry about content yet Will start at: “git checkout 0.9_minimal_skeleton” Images are in a"/images" folder 19

Review – Layout Follow along: “git checkout 1_minimal_app” We've used webkit's flexbox There's a draft of a standard (a bit different syntax) What’s next? Using HTML5 Boilerplate Semantic HTML, new tags ( CSS, especially CSS3 (gradients, transitions, translations, regions,...) Become a JS ninja 20

Breaking it into multiple files JS – using require.js ( Include the require.js script Wrap our reader.js with AMD Include reader.js using require.js in our HTML file Then require other files CSS – using less ( Include the LESS preprocessor script Output all css files in a src folder into the reader.css file Later, automate this transpiling for production 21

Exercise – Breaking JS into multiple files Breaking up JS code: Require.js and showing our js still works (alert) Start at: “git checkout 1_minimal_app” 22

Review – Breaking JS into multiple files Follow along: “git checkout 2_with_require_js” What’s next? Plugins (! text for templates ) r.js for packaging node-like packages Read the source 23

Demo Exercise – Breaking CSS into files Breaking up CSS code: Use LESS and convert some CSS Start at: “git checkout 2_with_require_js” 24

Review – Breaking CSS into files Follow along: “git checkout 3_with_less” What’s next? Learn ALL less features Incorporate less helpers (e.g. vendor-prefix) Use less compiler to package standard css 25

Test-driven development (TDD) When is it appropriate? We will build each of our “classes” by: Creating the boilerplate file Creating a test file for it Writing the standard test and seeing it fails (no implementation) Writing the code, rerunning the test with every save For that, we’ll install node.js (+npm) and mocha.js We’ll automate running the tests with every save 26

Test-driven development (TDD) Mocha Describe It Expectations - Reporters Dependency injection 27

Demo Exercise – Supporting TDD Adding a tests folder Building a simple test file for our simple main.js Running tests Command Line Options Start at: “git checkout 3.99_before_tests” 28

Review – Supporting TDD Follow along: “git checkout 4_with_tests” What’s next? Adjust to TDD style Write tests for ANY project Expand your tests: unit-level, integration, black box, UI, … 29

Server Side Let's inspect our api provider(/api) Uses node.js and a few frameworks: express for routing HTTP requests can easily compile less and require.js files upon change serving static files optimist for command line parsing 30

MVC Divide code into classes Separate classes for the Section page and Article page Backbone.js ( We will further divide code into different classes for: Model – defining, fetching, validating, storing and reloading our data View – defines a screen or a part of the screen (component); builds the DOM, clears the DOM, handles interaction with the DOM Controller (/Presenter/ViewManager/Router) – Switches from one page to another; renders the correct views and creates a view hierarchy; handles anything unusual 31

Models ArticlePreview – contains: title, thumbnail, byline ArticlePreviews – contains a list of ArticlePreviews Article – same as ArticlePreview, but also contains: body, images A model can easily be tested: After it’s loaded, we can inspect it’s expected fields Then, we can unit test our models by stubbing a request for the data and validating the output for normal fetch or for any edge case 32

Views All views will be provided with a DOM element to output into Will allow us to render elements off-screen and attach once all rendering finishes Will allow us to easily test a view, in memory (or node.js) ArticlePreviewView – shows just one article preview on the main page Will be provided with an ArticlePreviewModel for knowing what to show SectionView – renders many ArticlePreviewView as the main page Will be provided with a SectionModel ArticleView – renders a full article page Will be provided with an ArticleModel 33

Controller/s Main is our controller for both pages. We could have broken it to SectionController and ArticleController instead: SectionController – creates the full section page Loads the SectionModel; will wait until it’s loaded successfully Instantiates a SectionView, which will instantiate the many ArticlePreviewViews Upon clicking on article, will instantiate ArticleController ArticleController – creates a full article page Loads/receives the ArticleModel; will wait until it’s loaded successfully Instantiates an ArticleView Upon clicking on Back, will instantiate a SectionController 34

Exercise – Building our classes Building and testing the models Building and testing the views Also demoing the views in the browser Building and testing the controllers and gluing everything together Start at: “git checkout 4.99_api” 35

Review – Building our classes Follow along: “git checkout 5_with_backbone” What’s next? Implement a router Loading spinner 36

What’s next? App enhancements (sections, images, media, sharing, …) Deployment process Responsive design Offline support PhoneGap Socket.io 37

FIN. QUESTIONS? BUILDING A WEBAPP STEP BY STEP by Ohad Kravchick Fluent 2013 May 28th, 2013 Rate me: Grab me: