28
Web Dev in 2019

Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

  • Upload
    others

  • View
    18

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

Web Dev in 2019

Page 2: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

Yesterday was just the beginning.

Page 3: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

Where to go next?

Page 4: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

What we’ll take a peek at now

● JavaScript● More CSS● Testing● Build tools● Backend

Page 5: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

JavaScript

Page 6: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

The web tech stack

● Content○ HTML

● Design / Layout○ CSS

● Behaviour / Interactivity○ JavaScript

Page 7: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

A teaser for the upcoming talk<button>Click me!</button>

<!-- Let's make the button do something with JavaScript! -->

<script>

document.querySelector('button').onclick = function() {

alert('Hello world!');

}

</script>

Page 8: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

More CSS

Page 9: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

Your CSS will probably grow.img { /*... */ } /* all images... */

img.hero { /* ... */ } /* the big landing page image */

img.hero2 { /* ... */ } /* another big image? */

.hero-container { /* ... */ } /* a container for big images? */

.herocontainer1 { /* ... */ } /* I give up. HELP! */

Page 10: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

Methods to keep it tidy

● OOCSS: Object-oriented CSS● BEM: Block-Element-Modifier● ACSS: Atomic CSS● SMACSS: Scalable & modular architecture

Page 11: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

A sample for BEM.product { /*...*/ } /* a product tile */

.product__img { /*...*/ } /* the product image */

.product__title { /*...*/ } /* the product title */

/* modified styles for highlighted (featured) products */

.product--featured { /*...*/ }

.product__title--featured { /*...*/ }

Page 12: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

Testing

Page 13: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

Automated testing

● Encourages better code design● Faster development time, higher confidence● Test categories

○ Unit tests○ End-to-end tests

Page 14: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

Test example: Unit testtest('adds 1 + 2 and returns 3', function() {

expect(add(1, 2)).toBe(3);

});

test('adds -1 and 1 and returns 0', function() {

expect(add(-1, 1)).toBe(0);

});

Page 15: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

Test example end-to-end testdescribe('Shop page', function() {

it('clicking "buy" goes to the checkout page', function() {

cy.visit('https://example.org/shop')

cy.contains('buy').click()

// Should be on a new URL which includes '/checkout'

cy.url().should('include', '/checkout')

})

})

Page 16: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

Testing tools

● Jest● Karma● Jasmine● Cypress● Ava

Page 17: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

Build tools

Page 18: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

Automate what takes you time

● You often have to repeat certain tasks● Examples

○ Check if your code is correct & looks right○ Resize images○ Run your tests○ Minimize your code

Page 19: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

Use build tools to do that automatically

● Webpack● Gulp● Grunt● npm scripts

Page 20: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

Backend

Page 21: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

When you need to do more...

● Not everything can be done in the browser● Not everything should be done in the browser● Backends let you store data & do processing

○ Process a transaction○ Store user data

Page 22: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

Backend programming

● JavaScript (node.js)● Ruby● Python● PHP● Java

Page 23: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

A note on tools

Page 24: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

Web Dev tooling

Page 25: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

A small selection :)

Page 26: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

Different tools solve different problems.

Page 27: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

Tools...

● It’s good to have a toolbox● Use the simplest tool that solves the problem● If a tool makes your life harder, try another● Don’t listen to the haters

Page 28: Web Dev in 2019Methods to keep it tidy OOCSS: Object-oriented CSS BEM: Block-Element-Modifier ACSS: Atomic CSS SMACSS: Scalable & modular architecture A sample for BEM.product { /*...*

Keep learning & make the web