Upload
digipolis
View
213
Download
0
Embed Size (px)
Citation preview
Stefan Pante@stefanpante
Node.js at Digipolis: Experiences and lessons learned24/03/2016
The Node.js Team
A-stad
Stack
A-profiel (user app)
meldingene-loket notificati
on redactie ... helpcenter
cart(betalen) search stadspla
n
Civilian/Employee
Centrale Reference Systems
A-profiel (user app)
meldingene-loket notificati
on redactie ... helpcenter
cart(betalen) search stadspla
n
Civilian/Employee
Good Ideas1. Reusable modules
Good Ideas1. Reusable modules
2. Basic application structure
Good Ideas1. Reusable modules
2. Basic application structure
3. Code Quality
1. Reusable modules
New Application
User Service
Apache Solr
Notification Service
Modules● Communication and Authorization
Modules● Communication and Authorization
● Common tasks: mailing, response handling…
Modules● Communication and Authorization
● Common tasks: mailing, response handling…
● Wrapper around existing modules, with specific
configuration
Astad module was born
All dependencies you’d ever need
Everything initialised and exposed on Express app
Disadvantages● Hard to maintain (versioning difficult)
Disadvantages● Hard to maintain (versioning difficult)
● Many unused dependencies
Disadvantages● Hard to maintain (versioning difficult)
● Many unused dependencies
● Scripts, cron jobs…
Disadvantages● Hard to maintain (versioning difficult)
● Many unused dependencies
● Scripts, cron jobs…
● Required intrinsic knowledge
Astad Module
Astad Module
Astad-Solr Astad-User Astad-Request ...
Many modules were created
Only use what you need,Dependencies are explicit!
Easier to test!Each module = one concern
Disadvantages● Still cumbersome to update dependencies
with git tags
Disadvantages● Still cumbersome to update dependencies
with git tags
● BUG = Manually updating package.json of
dependents
(Sinopia)
Our very own private NPM repository
~ Allows patch variations
2. Basic application structure
Basic application structure● Quickly start developing
Basic application structure● Quickly start developing
● Uniformity and familiarity
Skeleton app● Git repository to fork
Skeleton app● Git repository to fork
● Basic uniform file structure
Skeleton app● Git repository to fork
● Basic uniform file structure
● Most used modules included
Disadvantages● Still some basic configuration required
Disadvantages● Still some basic configuration required
● Some apps need frontend, others don’t
Disadvantages● Still some basic configuration required
● Some apps need frontend, others don’t
● Need to remove unused dependencies
Yeoman Generator(s)● Asks basic questions
Yeoman Generator(s)● Asks basic questions
● Conditionally load dependencies,
file structure
Yeoman Generator(s)● Asks basic questions
● Conditionally load dependencies,
file structure
● Basic config taken care of
yo astad Please specify your project name: “A-stad”Do you need a frontend for this project : (Y/n) “Y”
3. Code quality
Testing● Ensure functionality is correct
Testing● Ensure functionality is correct
● Test robustness of methods
Testing● Ensure functionality is correct
● Test robustness of methods
● Tests allow refactoring
Testing without Control● Easy to cheat
Testing without Control● Easy to cheat
● Tests are neglected
Automated testing● No deploys without tests
● PR’s are not approved when tests fail
Other measures● Coding guidelines:JSLint, ESLint
● Code Reviews during PR, min 2 other dev’s.
Conclusion● Reusable modules
● Basic application structure
● Code Quality
ConclusionLearning from your mistakes allows for continuous
improvement and enables you to write better code.
Questions?