Undoable architectures

40

Transcript of Undoable architectures

Page 1: Undoable architectures
Page 2: Undoable architectures

AboutMe• TechnicalLeaderandAgileCoach• Front-endDeveloper(testfirst!)• MobileDeveloper(HybridwithCordova,iOS,Android)• TechnologyEnthusiast• [email protected]

Page 3: Undoable architectures

What'sNext?

ScotchStreamingandScaling11Feb2015www.meetup.com/mobiletea

Page 4: Undoable architectures

Agenda• Monolithicapplications• Identifymodulesand/orcomponents• Distributingmodulesinyourorganization• RESTfulandHypermediamodels• Demo

Page 5: Undoable architectures
Page 6: Undoable architectures

EnterpriseApplications

• Existingcodebaseandlegacycode• Shorttimetomarket• Prototypebased• Lackofplanningandstrategy• Adaptingtomarketingneeds

Page 7: Undoable architectures

M/SSizeApplications

• Unexpectedsuccess• Budgetconstraints• Missingexpertise• Lackofplanningandstrategy• Adaptingtocustomerneeds

Page 8: Undoable architectures

What'sinCommon?Lackofdesigniterationsandseparationofconcerns

monkeyanimatedGIF

Page 9: Undoable architectures

monkeyanimatedGIF

Page 10: Undoable architectures

monkeyanimatedGIF

MajorProblems• Maintainability• Scalability• Learningcurve• Difficultsetups• Complexreleaseprocedures• Difficulttotest• Integrationnightmares• Longbuildcycles

Page 11: Undoable architectures

PossibleSolutions• Refactoring• Documenting• Decoupling• Movethemodeontheserver• Addcomputationcapabilities(e.g.clouds)• Etc.

NoEscape

Page 12: Undoable architectures

NoEscapeeatinganimatedGIF

Page 13: Undoable architectures

eatinganimatedGIF

Page 14: Undoable architectures

ModulesAnapplicationmoduleisaclassthatrepresentsabusiness

applicationtask.(Oracle)

Page 15: Undoable architectures

ComponentsAcomponentisareusableprogrambuildingblockthatcanbe

combinedwithothercomponents.

That'sGood!

Page 16: Undoable architectures

That'sGood!robertdeniroanimatedGIF

Page 17: Undoable architectures

robertdeniroanimatedGIF

IdentifyThemStartingfromYourRequirements

Page 18: Undoable architectures

SmallandDecoupled

• Identifysmallanddecoupledpartsofyourapplication• Trytounderstandwhicharereusableacrossseveralapps• Iterateacrossyourmodulesand/orcomponentslistbeforeimplementinganewfeature• Pick-uptherighttoolsettoimplementaspecificsetoffeatures• Neverreinventthewheel!

Page 19: Undoable architectures
Page 20: Undoable architectures

DistributionRequirements

• Amodule/componentshouldbeeasytoinstall• Dependenciesshouldbeeasytomanage• Thefeaturesofeverymodule/componentshouldbeveryclear• Allthereleasesofamodule/componentshouldbealwaysavailable(eventuallydismissthesupport)

Page 21: Undoable architectures

PossibleSolutions

What'sAboutmy

Page 22: Undoable architectures

What'sAboutmyPrivacy?

wtfanimatedGIF

Page 23: Undoable architectures

wtfanimatedGIF

BowerUseaprivategitrepositoryongithub.comorcreateyourowngitserver

{"name":"my-amazing-component","version":"1.0.0","ignore":["**/.*","node_modules","bower_components","test","tests"

Page 24: Undoable architectures

NPMTrythenpmjs.comenterpriseserviceorcreateyourprivatenpm

serverusingSinopiatocreateprivatepackages

Page 25: Undoable architectures

UsingNPMYoucanthenusenpmasusualbuteverythingwillliveintoyourprivaterepo,theonlydifferenceisthatyousetadifferentregistry(actuallyyoucanswitchbetweenthem)

$npmsetregistryhttp://your_external_ip:4873$npmadduser$npmpublish

Page 26: Undoable architectures

Results• Youcaninstallanduninstallcomponentseasily• Thedependenciesmanagementprocessisautomated(kinda!)• Everycomponent/modulecanbeunpluggedfromyourapplicationandchanged• Thesourcecodeisbetterorganized(componentsshouldworkalsostandalone)• Etc.

Page 27: Undoable architectures

What'sMissing?Themodel...

techanimatedGIF

Page 28: Undoable architectures
Page 29: Undoable architectures

AbstracttheModel• Keepalwaysthemodelindependentfromyourclientsidearchitecture• JSONorXMLarevalidformatstodistributethedata• Usedataadapters(Backbone,EmberData,etc.)todealwiththemodelinyourclientsidecode

Page 30: Undoable architectures

EnrichtheModel• Don'tdeliverjustdatabutalsobusinesslogicinformationlikerelatedlinks• UsetheflexibilityofJSONorXMLtoprovideastructuretoyourmodels

{"href":"http://example.com/api/v1/users/john","type":"user","head":{"allow":["GET","PUT","PATCH","DELETE"],"related":{

Page 31: Undoable architectures

DeliverYourRules• Usethemodeltoexplicitlysettherulestofollowtopost/put/delete/informationtoyoursystem• Deliverformvalidationrules(e.gregexp)toavoidtore-buildtheclientifsomethingchange• Provideliveupdateinformation(e.g.websockets)toupdateyourapplication• Etc.

Page 32: Undoable architectures

AlwaysAvoidTodefineamodelthatfitstheneedsofaspecificclientsidelibrary,

it'sapaththatisveryhardtoundo

Page 33: Undoable architectures
Page 34: Undoable architectures

Recommendations• Trytodon'tdependonlyonasingleclientsidelibrary• Don'tbetoolazy,JavaScriptcanhandlenativelythetasksperformedbyexternallibriaries• Keepthecommunicationassimpleaspossible• Writecleanandtestablecode• Etc.

Page 35: Undoable architectures

ComponentsScope• UsewebcomponentsCSSscopingifyourconcernisthelookand

feelofcomponents/module• UseaniFrametoencloseyourcomponentinasandbox

Page 36: Undoable architectures

Demohttps://github.com/GiorgioNatili/undoable-architectures

Page 37: Undoable architectures

Resources• http://almostobsolete.net/talks/hypermedia• http://liquidmedia.org/blog/2011/01/backbone-js-part-1• http://madhatted.com/2013/3/19/suggested-rest-api-practices• http://emberjs.com/guides/models/the-rest-adapter• http://cwbuecheler.com/web/tutorials/2014/restful-web-app-node-express-mongodb• https://oncletom.io/2013/live-development-bower-component• http://tech.pro/tutorial/1308/emberjs-views-and-live-templates-with-handlebarsjs-part-1

Page 38: Undoable architectures

@giorgionatili#mobiletea#javascript#swift#wearable#agile#android#tdd

Thanks!

Page 39: Undoable architectures

Thanks!Grazie!Graçias!Danke!Merci!��!

thanksanimatedGIF

Page 40: Undoable architectures

thanksanimatedGIF