Top Banner
FROM THEORY TO PRACTICE unspoken truth of starting web project brought to you by Sergey Bolshchikov
41

Web Projects: From Theory To Practice

Aug 26, 2014

Download

Self Improvement

There's always a gap between theoretical knowledge and practice. Particularly, how to start you first web project when you are familiar with HTML, JS, and CSS. This presentation covers such aspects as project functionality, modeling, file organization, building initial layout with HTML, insights of CSS, and jQuery.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Web Projects: From Theory To Practice

FROM THEORY TO PRACTICE

unspoken truth of starting web project

brought to youby Sergey Bolshchikov

Page 2: Web Projects: From Theory To Practice

WHAT'S YOUR NAME, U SAID?

Front end Developer @ New ProImageCo-organizer @ Ember-IL MeetupGraduate Student @ Technion, IM&E

Web: http://bolshchikov.net

Blog: http://blog.bolshchikov.net

Github: https://github.com/bolshchikov

Page 3: Web Projects: From Theory To Practice

OUTLINE

1. Understand the destiny

2. Organize your life

3. Choose your comrades

4. Lay out your way

5. Add the make up

6. Bring some action

7. Coding

Page 4: Web Projects: From Theory To Practice

UNDERSTANDING THE DESTINY

Page 5: Web Projects: From Theory To Practice

DESTINY

Page 6: Web Projects: From Theory To Practice

DESTINY :: GOALThe goal should formulate the main purpose or idea of future

project. It can be describe by one sentence or two sentences,

e.g.

“Create user-friendly web store for selling fruits and vegetables”

Page 7: Web Projects: From Theory To Practice

DESTINY :: FUNCTIONALITY● Login

● Display a list of available items with prices

● Display detailed information per item

● Be able to add the item to the basket

● Calculate the overall sum

● Send the order

Page 8: Web Projects: From Theory To Practice

DESTINY :: STRUCTURE

Page 9: Web Projects: From Theory To Practice

ORGANIZE YOUR LIFE

Page 10: Web Projects: From Theory To Practice

ORGANIZATION

Division by type

Separation of concerns

Complex

Page 11: Web Projects: From Theory To Practice

HTML5BOILERPLATE

Project started by Paul Irish (Google) for keepin' best techniques for web project

http://html5boilerplate.com/

● Code structure

● File template (html, css, js)

● Comes with libraries: jQuery, Modernizr

● and other

Page 12: Web Projects: From Theory To Practice

CHOOSE YOUR COMRADES

Page 13: Web Projects: From Theory To Practice

COMRADES

How? Checklist:

○ Amount of watchers in Github (big)

○ Amount of forks on Github (medium)

○ Amount of issues on Github (small)

○ Amount of results on Stackoverflow

○ Amount of votes on Stackoverflow

Page 14: Web Projects: From Theory To Practice

COMRADES :: DOM

Why? Cross browser API is not the same

What? Relieves you from pain developments

Who? jQuery, Zepto, MooTools

Save yourself some timeDO NOT WRITE YOUR OWN

Page 15: Web Projects: From Theory To Practice

COMRADES :: UI & WIDGETS

What?● Splitter● Tree● Accordion● Context menu● Dropdown● Charts● Calendar● Grids● Dialogs

Who?● Twitter Bootstrap

● jQueryUI

● KendoUI

● Wijmo Components

● jqWidgets

● Dojo

Page 16: Web Projects: From Theory To Practice

COMRADES :: JS FRAMEWORKS

Why? JS mess, spaghetti code

What? Clean separation of concerns

Who? EmberJS, Backbone, Angular, etc.

How? Write test programs in each of them

http://todomvc.com/

Page 17: Web Projects: From Theory To Practice

LAYOUT YOUR WAY

Page 18: Web Projects: From Theory To Practice

WRITING APPROACH

Page 19: Web Projects: From Theory To Practice

LAYOUT :: LAYOUT 1 :: HTML

<header></header><div id="main"></div><footer></footer>

http://jsbin.com/anafap/9/edit

Page 20: Web Projects: From Theory To Practice

LAYOUT :: LAYOUT 2 :: HTML

<div id="left"></div><div id="center"></div><div id="right"></div>

http://jsbin.com/asehas/7/edit

Page 21: Web Projects: From Theory To Practice

LAYOUT :: LAYOUT 3 :: HTML

<header></header><div id="container"> <div id="left"></div> <div id="right"></div></div><footer></footer>

http://jsbin.com/uvafam/6/edit

Page 22: Web Projects: From Theory To Practice

ADD THE MAKE UP

Page 23: Web Projects: From Theory To Practice

CSS

CSS is a super power

Page 24: Web Projects: From Theory To Practice

CSS :: SELECTORS

Selector Description Example

*

Matches any element.

E Matches any E element (i.e., an element of type E).

a

E F Matches any F element that is a descendant of an E element.

div a

E > F Matches any F element that is a child of an element E.

div > a

E:first-child Matches element E when E is the first child of its parent.

li:first-child

E:linkE:visited

Matches element E if E is the source anchor of a hyperlink of which the target is not yet visited (:link) or already visited (:visited).

a:linka:visited

Page 25: Web Projects: From Theory To Practice

CSS :: SELECTORS (cont.)

Selector Description Example

E:activeE:hoverE:focus

Matches E during certain user actions.

a:activea:hovera:focus

E + F Matches any F element immediately preceded by a sibling element E.

div + div

E[foo] Matches any E element with the "foo" attribute set (whatever the value).

div[data-id]

E[foo="warning"] Matches any E element whose "foo" attribute value is exactly equal to "warning".

input[type=”text”]

DIV.warning Language specific. (In HTML, the same as DIV[class~="warning"].)

div.navigation

E#myid Matches any E element with ID equal to "myid".

div#main

Page 26: Web Projects: From Theory To Practice

CSS :: BOX MODEL

Page 27: Web Projects: From Theory To Practice

CSS :: MORE● display: [none, block, inline, table, inline-

block...],

● position: [absolute, fixed, relative],

● top: [number],

● left: [number],

● float: [left, right, none]

Page 28: Web Projects: From Theory To Practice

LAYOUT :: LAYOUT 1 :: HTML + CSSHTML

<header></header><div id="main"></div><footer></footer>

CSSheader, footer { border: 1px solid red; height : 55px; background-color: grey; border-radius: 7px;}#main { border-radius: 7px; border: 1px solid red; background-color: grey; height: 90px; margin: 10px 0 10px 0;}

http://jsbin.com/anafap/7/edit

Page 29: Web Projects: From Theory To Practice

LAYOUT :: LAYOUT 2 :: HTML + CSSHTML

<div id="left"></div><div id="center"></div><div id="right"></div>

CSSdiv { background-color: grey; border-radius: 7px; border: 1px solid red; float: left; margin: 0 5px 0 5px;}#left, #right { width: 150px; height: 250px; }#center { width: 275px; height: 750px; }http://jsbin.com/asehas/6/edit

Page 30: Web Projects: From Theory To Practice

LAYOUT :: LAYOUT 3 :: HTML + CSSHTML

<header></header><div id="container"> <div id="left"></div> <div id="right"></div></div><footer></footer>

CSS#left { width: 28%; background-color: grey; border: 1px solid red; border-radius: 7px; margin-right: 2%; float: left;}#right { width: 70%; background-color: grey; border: 1px solid red; border-radius: 7px; margin-left: 30%}

http://jsbin.com/uvafam/6/edit

Page 31: Web Projects: From Theory To Practice

TIME TO CODE

Page 32: Web Projects: From Theory To Practice

JAVASCRIPT

"JavaScript is the Assembly language of WEB"- Erik Meijer, Dutch computer scientist

Page 33: Web Projects: From Theory To Practice

JQUERY :: SELECTORS

$(selector).method()

For example, $(‘#list’) will return the elements which has the attribute id=”list”.

For more, see http://api.jquery.com/category/selectors/.

Page 34: Web Projects: From Theory To Practice

JQUERY :: DOM MANIPULATIONS● $(selector).html()● $(selector).append(html)● $(selector).remove()● $(selector).attr('myAttr', 'value')● $(selector).removeAttr('myAttr')● $(selector).css('width', 40)● $(selector).addClass('my-class')● $(selector).removeClass('my-class')● $(selector).text()● $(selector).val()

Page 35: Web Projects: From Theory To Practice

JQUERY :: AJAX

$.ajax({ url: ‘/api/posts’ type: ‘POST’, data: {}, success: function () {}, error: function () {}});

Page 36: Web Projects: From Theory To Practice

JQUERY :: EVENTS● $(selector).click(function () {})● $(selector).dblclick(function () {})● $(selector).mousedown(function () {})● $(selector).mouseup(function () {})● $(selector).mouseover(function () {})● $(selector).mouseenter(function () {})● $(selector).mouseleave(function () {})● $(selector).on(eventName,

function () {})● $(selector).off(eventName,

function () {})

Page 37: Web Projects: From Theory To Practice

JAVASCRIPT :: GUIDELINES

Do not populate global space

Use namespaces: create one global variable, e.g. name of your app, and store

everything there.

window.YUI = {};YUI.version = ‘0.3’,YUI.start = function () {};

Page 38: Web Projects: From Theory To Practice

JAVASCRIPT :: GUIDELINES

Write JavaScript only in js file

Do NOT write it in HTML:

<a class=”add” onclick=”function () {}”>Add</a>

Instead use jQuery and register the click handler:

$(‘.add’).on(‘click’, function () {});

Page 39: Web Projects: From Theory To Practice

JAVASCRIPT :: GUIDELINES

Write small functions

Page 40: Web Projects: From Theory To Practice

JAVASCRIPT :: GUIDELINES

Write comments

Page 41: Web Projects: From Theory To Practice

QUESTIONS?