62
Stefan Pante @stefanpante

Meetup 24/3/2016 - Node.js User Group Belgium

Embed Size (px)

Citation preview

Page 1: Meetup 24/3/2016 - Node.js User Group Belgium

Stefan Pante@stefanpante

Page 2: Meetup 24/3/2016 - Node.js User Group Belgium

Node.js at Digipolis: Experiences and lessons learned24/03/2016

Page 3: Meetup 24/3/2016 - Node.js User Group Belgium

The Node.js Team

Page 4: Meetup 24/3/2016 - Node.js User Group Belgium

A-stad

Page 5: Meetup 24/3/2016 - Node.js User Group Belgium

Stack

Page 6: Meetup 24/3/2016 - Node.js User Group Belgium

A-profiel (user app)

meldingene-loket notificati

on redactie ... helpcenter

cart(betalen) search stadspla

n

Civilian/Employee

Page 7: Meetup 24/3/2016 - Node.js User Group Belgium

Centrale Reference Systems

A-profiel (user app)

meldingene-loket notificati

on redactie ... helpcenter

cart(betalen) search stadspla

n

Civilian/Employee

Page 8: Meetup 24/3/2016 - Node.js User Group Belgium

Good Ideas1. Reusable modules

Page 9: Meetup 24/3/2016 - Node.js User Group Belgium

Good Ideas1. Reusable modules

2. Basic application structure

Page 10: Meetup 24/3/2016 - Node.js User Group Belgium

Good Ideas1. Reusable modules

2. Basic application structure

3. Code Quality

Page 11: Meetup 24/3/2016 - Node.js User Group Belgium

1. Reusable modules

Page 12: Meetup 24/3/2016 - Node.js User Group Belgium

New Application

User Service

Apache Solr

Notification Service

Page 13: Meetup 24/3/2016 - Node.js User Group Belgium

Modules● Communication and Authorization

Page 14: Meetup 24/3/2016 - Node.js User Group Belgium

Modules● Communication and Authorization

● Common tasks: mailing, response handling…

Page 15: Meetup 24/3/2016 - Node.js User Group Belgium

Modules● Communication and Authorization

● Common tasks: mailing, response handling…

● Wrapper around existing modules, with specific

configuration

Page 16: Meetup 24/3/2016 - Node.js User Group Belgium

Astad module was born

Page 17: Meetup 24/3/2016 - Node.js User Group Belgium

All dependencies you’d ever need

Page 18: Meetup 24/3/2016 - Node.js User Group Belgium

Everything initialised and exposed on Express app

Page 19: Meetup 24/3/2016 - Node.js User Group Belgium

Disadvantages● Hard to maintain (versioning difficult)

Page 20: Meetup 24/3/2016 - Node.js User Group Belgium

Disadvantages● Hard to maintain (versioning difficult)

● Many unused dependencies

Page 21: Meetup 24/3/2016 - Node.js User Group Belgium

Disadvantages● Hard to maintain (versioning difficult)

● Many unused dependencies

● Scripts, cron jobs…

Page 22: Meetup 24/3/2016 - Node.js User Group Belgium

Disadvantages● Hard to maintain (versioning difficult)

● Many unused dependencies

● Scripts, cron jobs…

● Required intrinsic knowledge

Page 23: Meetup 24/3/2016 - Node.js User Group Belgium
Page 24: Meetup 24/3/2016 - Node.js User Group Belgium
Page 25: Meetup 24/3/2016 - Node.js User Group Belgium

Astad Module

Page 26: Meetup 24/3/2016 - Node.js User Group Belgium

Astad Module

Astad-Solr Astad-User Astad-Request ...

Page 27: Meetup 24/3/2016 - Node.js User Group Belgium

Many modules were created

Page 28: Meetup 24/3/2016 - Node.js User Group Belgium

Only use what you need,Dependencies are explicit!

Page 29: Meetup 24/3/2016 - Node.js User Group Belgium

Easier to test!Each module = one concern

Page 30: Meetup 24/3/2016 - Node.js User Group Belgium

Disadvantages● Still cumbersome to update dependencies

with git tags

Page 31: Meetup 24/3/2016 - Node.js User Group Belgium

Disadvantages● Still cumbersome to update dependencies

with git tags

● BUG = Manually updating package.json of

dependents

Page 32: Meetup 24/3/2016 - Node.js User Group Belgium

(Sinopia)

Page 33: Meetup 24/3/2016 - Node.js User Group Belgium

Our very own private NPM repository

Page 34: Meetup 24/3/2016 - Node.js User Group Belgium

~ Allows patch variations

Page 35: Meetup 24/3/2016 - Node.js User Group Belgium

2. Basic application structure

Page 36: Meetup 24/3/2016 - Node.js User Group Belgium

Basic application structure● Quickly start developing

Page 37: Meetup 24/3/2016 - Node.js User Group Belgium

Basic application structure● Quickly start developing

● Uniformity and familiarity

Page 38: Meetup 24/3/2016 - Node.js User Group Belgium

Skeleton app● Git repository to fork

Page 39: Meetup 24/3/2016 - Node.js User Group Belgium

Skeleton app● Git repository to fork

● Basic uniform file structure

Page 40: Meetup 24/3/2016 - Node.js User Group Belgium

Skeleton app● Git repository to fork

● Basic uniform file structure

● Most used modules included

Page 41: Meetup 24/3/2016 - Node.js User Group Belgium

Disadvantages● Still some basic configuration required

Page 42: Meetup 24/3/2016 - Node.js User Group Belgium

Disadvantages● Still some basic configuration required

● Some apps need frontend, others don’t

Page 43: Meetup 24/3/2016 - Node.js User Group Belgium

Disadvantages● Still some basic configuration required

● Some apps need frontend, others don’t

● Need to remove unused dependencies

Page 44: Meetup 24/3/2016 - Node.js User Group Belgium
Page 45: Meetup 24/3/2016 - Node.js User Group Belgium

Yeoman Generator(s)● Asks basic questions

Page 46: Meetup 24/3/2016 - Node.js User Group Belgium

Yeoman Generator(s)● Asks basic questions

● Conditionally load dependencies,

file structure

Page 47: Meetup 24/3/2016 - Node.js User Group Belgium

Yeoman Generator(s)● Asks basic questions

● Conditionally load dependencies,

file structure

● Basic config taken care of

Page 48: Meetup 24/3/2016 - Node.js User Group Belgium

yo astad Please specify your project name: “A-stad”Do you need a frontend for this project : (Y/n) “Y”

Page 49: Meetup 24/3/2016 - Node.js User Group Belgium
Page 50: Meetup 24/3/2016 - Node.js User Group Belgium
Page 51: Meetup 24/3/2016 - Node.js User Group Belgium

3. Code quality

Page 52: Meetup 24/3/2016 - Node.js User Group Belgium

Testing● Ensure functionality is correct

Page 53: Meetup 24/3/2016 - Node.js User Group Belgium

Testing● Ensure functionality is correct

● Test robustness of methods

Page 54: Meetup 24/3/2016 - Node.js User Group Belgium

Testing● Ensure functionality is correct

● Test robustness of methods

● Tests allow refactoring

Page 55: Meetup 24/3/2016 - Node.js User Group Belgium
Page 56: Meetup 24/3/2016 - Node.js User Group Belgium

Testing without Control● Easy to cheat

Page 57: Meetup 24/3/2016 - Node.js User Group Belgium

Testing without Control● Easy to cheat

● Tests are neglected

Page 58: Meetup 24/3/2016 - Node.js User Group Belgium

Automated testing● No deploys without tests

● PR’s are not approved when tests fail

Page 59: Meetup 24/3/2016 - Node.js User Group Belgium

Other measures● Coding guidelines:JSLint, ESLint

● Code Reviews during PR, min 2 other dev’s.

Page 60: Meetup 24/3/2016 - Node.js User Group Belgium

Conclusion● Reusable modules

● Basic application structure

● Code Quality

Page 61: Meetup 24/3/2016 - Node.js User Group Belgium

ConclusionLearning from your mistakes allows for continuous

improvement and enables you to write better code.

Page 62: Meetup 24/3/2016 - Node.js User Group Belgium

Questions?