meteor project structure how to prevent spaghetti code and chaos peter ilfrich – software engineer...

12
Meteor Project Structure How to prevent spaghetti code and chaos Peter Ilfrich – Software Engineer @ IBM Research Australia

Upload: irene-cummings

Post on 13-Dec-2015

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Meteor Project Structure How to prevent spaghetti code and chaos Peter Ilfrich – Software Engineer @ IBM Research Australia

Meteor Project Structure

How to prevent spaghetti code and chaos

Peter Ilfrich – Software Engineer @ IBM Research Australia

Page 2: Meteor Project Structure How to prevent spaghetti code and chaos Peter Ilfrich – Software Engineer @ IBM Research Australia

WARNING!!!

This presentation may contain a personal opinion

Page 3: Meteor Project Structure How to prevent spaghetti code and chaos Peter Ilfrich – Software Engineer @ IBM Research Australia

Boilerplate / Template

git clone https://github.com/ilfrich/meteor-project-template.git

- Folder Structure - Fixtures- Useful Packages - Data Migration- Global Template Helpers- CSS Helpers- Example Code- Router- Collections + Schema- Views

Page 4: Meteor Project Structure How to prevent spaghetti code and chaos Peter Ilfrich – Software Engineer @ IBM Research Australia

Core Folder Structure

client

server

public

private

tests

compatibility

Page 5: Meteor Project Structure How to prevent spaghetti code and chaos Peter Ilfrich – Software Engineer @ IBM Research Australia

Shared Folder

client

server

public

private

tests

compatibility

shared model routes

Page 6: Meteor Project Structure How to prevent spaghetti code and chaos Peter Ilfrich – Software Engineer @ IBM Research Australia

Server Folder

client

server

public

private

tests

compatibility

shared model routes

init methods publications

Page 7: Meteor Project Structure How to prevent spaghetti code and chaos Peter Ilfrich – Software Engineer @ IBM Research Australia

Client Folder

client

server

public

private

tests

compatibility

shared model routes

init methods publications

init views

Page 8: Meteor Project Structure How to prevent spaghetti code and chaos Peter Ilfrich – Software Engineer @ IBM Research Australia

Init / Compatibilityclient compatibility init views

Common functionality- Function declaration- 3rd party libraries (excl. NPM, Atmosphere)

Compatibility

Client initialization- Environment- Global Subscriptions

Init

Page 9: Meteor Project Structure How to prevent spaghetti code and chaos Peter Ilfrich – Software Engineer @ IBM Research Australia

Viewsclient compatibility init views

common.lessvariables.less

globalhelpers.jsglobalevents.js

layout.html

Files

login/login.htmllogin/login.lesslogin/login.js

header/header.htmlheader/header.lessheader/header.js

dashboard/dashboard.htmldashboard/dashboard.lessdashboard/dashboard.js

Folders

Page 10: Meteor Project Structure How to prevent spaghetti code and chaos Peter Ilfrich – Software Engineer @ IBM Research Australia

Server Folder

dbinit.jsdbmigrate.js

Init

- 1 file per business object (user, category, entry, post, …)- Too many business objects? Group them into sub-folders

Methods

server init methods publications

- 1 file per collection- Each file contains all publications for a collection

Publications

Page 11: Meteor Project Structure How to prevent spaghetti code and chaos Peter Ilfrich – Software Engineer @ IBM Research Australia

Shared Folder

- 1 file per collection- Attach schema to collection- Specify access privileges and hooks

Model

shared model routes

Routes

Small Applications- 1 file

/server/routes.js

Larger Applications- Group routes into separate files

/server/routes/mainroutes.js/server/routes/adminroutes.js/server/routes/apiroutes.js

Page 12: Meteor Project Structure How to prevent spaghetti code and chaos Peter Ilfrich – Software Engineer @ IBM Research Australia

Packages

• Core– less – jquery– mizzao:bootstrap-3– iron:router

• Database– aldeed:collections2– matb33:collection-hooks– tmeasday:publish-counts– meteorhacks:aggregate

• Utility– reactive-var– http– momentjs:moment

• Authentication / Security- accounts-password- browser-policy

• Optional- tsega:bootstrap3-datetimepicker- mrt:bootstrap3-typeahead- mrt:filesaver- johdirr:meteor-git-rev- juliancwirko:s-alert- fortawesome:fontawesome- peernohell:c3- matteodem:gridster- dburles:google-maps