Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

After the LAMP, it's time to get MEAN

447 views

Published on

The LAMP stack is a well know and ubiquitous web development stack, but have you heard of MEAN? It's an up and coming stack that's unified by a single language, JavaScript. Learn the basic components of the MEAN stack as well as practical use case and applications.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

After the LAMP, it's time to get MEAN

  1. 1. It’s time to get After the
  2. 2. About Jeff Fox (@jfox015) Assoc.Dir.,DigitalExperienceTechLead StarwoodHotelsandResorts • Nineteen year web development veteran • (Almost) entirely self-taught in programming, web and related technologies • Front end specialist with full stack skills/experience, main core capability used to be Flash  • Background in Graphic Design and art, music production & engineering and “entertainment services” • Experience working for fortune 100 companies down to creative agencies with as few as 10 people
  3. 3. Agenda •Quickie LAMP Review •Four Components of the MEAN stack (and a fifth bonus item too) •Wrap-up (with use cases) •Questions •Shatner
  4. 4. We all know LAMP is a combination of four of the most popular open source technologies that form one of the most popular and ubiquitous platform stacks used on the web. It’s estimated that 82% of web sites run on some version of PHP [1] [1] Source: http://www.w3techs.com/technologies/details/pl-php/all/all
  5. 5. LAMP is popular Some popular sites using PHP:
  6. 6. LAMP is popular Wordpress hosted blogs and sites alone account for some 4.5% of all web sites [1] [1] http://www.codeinwp.com/blog/mesmerizing-wordpress-stats/ [2] http://expandedramblings.com/index.php/wordpress-statistics/ [3] https://www.hostt.com/wordpress-stats-for-2015/ [4] https://managewp.com/14-surprising-statistics-about-wordpress-usage • 74.6 Million Sites Depend on WordPress [2] • 22% of New U.S. Registered Domains Run on WordPress [3] • WordPress.com Gets More Unique US Visitors (126M) per month Than Amazon (96M) [4]
  7. 7. What is M.E.A.N? Mean is a combination of four technologies that also form a single platform stack. The common element between them is JavaScript.
  8. 8. NODE JS About…
  9. 9. About NodeJS “Node's goal is to provide an easy way to build scalable network programs.” -- nodejs.org
  10. 10. Components of NodeJs • NodeJs runs on the V-8 Engine. • The V-8 Engine is an open source JavaScript engine created and developer by Google which also powers the Chrome browser. • V8 compiles JavaScript to native machine code (IA-32, x86-64, ARM, or MIPS ISAs) before executing it, instead of more traditional techniques such as executing byte code or interpreting it. • Node uses CommonJS specifications for common modular package management format • Uses NPM (Node Package Manager) to manage dependencies
  11. 11. How does Node work? • Node.js uses an event-driven, non-blocking I/O model, which makes it lightweight • It makes use of event-loops via JavaScript’s callback functionality to implement a non- blocking I/O • While time consuming file and disk operations block script execution in PHP, Node JS commands execute in parallel, and use callbacks to signal completion or failure)
  12. 12. Event Driven Example
  13. 13. Node in the Wild How is Node being used? API Servers Mobile backends and full-stack JavaScript hybrid apps Internet of things (IoT) Web – HTTP servers and single page apps
  14. 14. Node Pros and Cons Pros Fast – Execution speed Faster to market – development speed Less lines of code Great community Proven with high volume systems Most suited for networking, I/O intensive applications Cons Writing a large business logic centric system is cumbersome Callback hell Exception handling is not straight forward Writing event driven code is complex compared to synchronous code Source: NodeJS - Server Side JS
  15. 15. Node vs Java • 20+ years development testing making a rock solid foundation • Not as fast and Node, but absolutely a more trustworthy environment • Well know coding and debugging support in all major IDEs • True multi-threaded server support • No, XML used for Ant and Maven builds for example MATURITY SPEED TOOLS THREADING UNIFIED LANGUAGE • Younger player (launched in 2009) with less real world battle testing • Blazing fast execution, but sacrifices overall server safety for it • Modern IDE tools support via add-ons for code-completion and some debugging • Node simulated multi- threading via an event loop • Node uses JavaScript in all aspects of the development Source: Java vs. Node.js: An epic battle for developer mind share
  16. 16. EXPRESS About…
  17. 17. About Express • Popular NodeJS Server framework library • Inspired by the Sinatra framework for Ruby • Minimal and flexible application design • Handles many operations through HTTP helper utilities and the use of middleware • Easy to set up a working Express server in just few lines of code • Supports single page, multi-page and hybrid web applications
  18. 18. A basic Express app
  19. 19. Express Middleware Middleware is any number of functions that are invoked by the Express.js routing layer before the final request handler is called • Express Middleware is simply a function with three arguments • req – The HTTP Request • res – HTTP Response • next – Another Middleware to forward to after the function completes • Middleware is always invoked in the order added. • You can have multiple middleware for the same path. • Middleware has full access to the request and response objects. • Be mindful of middleware overriding fields of other middleware. • Middleware can be skipped by using the next function.
  20. 20. Express Middleware
  21. 21. Components of Express • Runs using NodeJs • App is the web application runtime • Middleware modules handle many routine operations: • Connect is a set of middleware that includes many helper modules • logger • csrf Cross-site request forgery protection • compress Gzip compression basicAuth http authentication • bodyParser extensible request body parser • json application/json parser • multipart multipart/form-data parser • timeout request timeouts • cookieParser cookie parser • session session management support with bundled MemoryStore • cookieSession cookie-based session support • methodOverride faux HTTP method support • favicon efficient favicon server (with default icon) • query automatic querystring parser, populating req.query • errorHandler flexible error handler
  22. 22. Express Routing • Handles HTTP and RESTful calls over HTTP • Can direct to Middleware, MVC controllers, use templates or return files
  23. 23. JADE TEMPLATES About… Soon to be re- released as PUG
  24. 24. About Jade • High performance template engine heavily influenced by Haml and implemented with JavaScript for Node • No need to worry about closing tags • Significant white space enforces clear coding convention between team members • Layout Inheritance • Allows for full JavaScript expressions but makes it just awkward enough to discourage full blown logic in the views • Support for inline Markdown and CoffeeScript Source: Comparing JavaScript Templating Engines: Jade, Mustache, Dust and More
  25. 25. Jade Example
  26. 26. Jade vs other Node templates Jade Mustache Dust NunJucks EJS No Closing Tags Async Layout Inheritance Streaming Custom tags High Learning Curve White Space Significance Easy Includes/ Partials Source: Comparing JavaScript Templating Engines: Jade, Mustache, Dust and More
  27. 27. MONGODB About…
  28. 28. Not that Mongo
  29. 29. About MongoDB • An open source, cross platform database • Stores data in JSON like documents with dynamic schemas (called BSON) • Fourth most popular database system worldwide as of Jan 2016 [1] • A “no sql” database without relational connections, search an API [1] http://db-engines.com/en/ranking
  30. 30. Data Design Comparison Traditional Data Design • Static, uniform, scalar data • Data “looks” like rectangles • Low level physical representation Document Data Design • Flexible and capable of rich shapes • Based on objects • High level business representation
  31. 31. Advantages of No-SQL Design • Agility • Start developing without an extremely long ER (entry- relationship) model design • Flexible for schema changes as you go without penalty • Polymorphic schema models variable structure with ease • Scalability • Shared-nothing architecture vs centrally controlled system (eliminates any single point of failure, allows self-healing capabilities and non-disruptive upgrades) • Scales horizontally, linearly • Sharding and load balancing • Auto-balance ensures a balances cluster Source: MongoDB and the Internet of Things
  32. 32. Mongo and Relational DB
  33. 33. Major Use Cases… …and Major Users • Big Data (Github) • Internet of Things (Bosch) • Complex Data Management (Cushman & Wakefield) • Mobile Apps (Twitter, Foursquare) • Customer Data Management (Intuit) • Social Networking and Collaboration (Cisco, Eventbright) • Content Management (New York Times, Adobe AEM, eBay) • Embedded (Sitecore)
  34. 34. Oracle vs MongoDB • Oranges • Created in 2009 • Document SQL-Less Model • Supports Replication, Horizontal scale and Sharding • Queries using JavaScript • MIT License • Free for commercial use • JSON (with BSON) • Supported by multiple cloud platforms • Apples • Created in 1936 • Relational Model • Supports Replication and Horizontal scale • Queries using SQL • Proprietary License • Large Price tag • Multiple data Types • Cloud Ready on Oracle Cloud Platform
  35. 35. ANGULARJS About…
  36. 36. About AngularJS • “Super heroic” framework created and developed by Google • Highly suited to single page front end web applications • Version 1.x attempted to solve many web application shortcomings in HTML 5 and JavaScript • Version 2.x tightly incorporates the latest improvements in JavaScript and modular front end design methodologies
  37. 37. Anatomy of Angular 1.x
  38. 38. Anatomy of an Angular 1.x App Index html App.js Angular BootstrapJquery Plugins CSS CSS CSS CSS HTML Partial REST API HTML Partial HTML Partial $http Controller Routing Controller Controller ServicesServicesServices/ Providers Directives Filters Angular Module $rootScopeJquery
  39. 39. About Angular 2 • Angular 2 went final on 9/15! • Version 2 sheds the non-standard 1.x conventions and embraces forward looking web standards like ECMAScript 6, Web Components as well as JS supersets like TypeScript • Component based architectural style • Highly Improved routing • Carries forward the ideology of Angular 1.x though the code will look very different • Focus on performance, transparency of Angular “internals” Change Detection and Rendering • Angular 2 has a simplified API for injecting dependencies into components via ES6 Modules
  40. 40. Anatomy of an Angular 2 App
  41. 41. Angular 1 vs 2 Components
  42. 42. Big Changes in Angular 2 • Embraces ES6 Modules/Component Design • Goodbye $scope (we hardly knew you) and DDO • Ultra-Fast Change detection • Changes in state managed through new Zones concept instead of “dirty checking” • Uses the new Object.observe property • Major Routing Improvements • Uni-Directional data flow (Similar to Facebook’s React) • Angular 1.x’s popular 2-way data binding is removed • ng-model replaced by new Form Directives • Improved Template syntax with Property and Event bindings instead of overuse of directives
  43. 43. $scope no more
  44. 44. One Framework, many langs • Angular 2 supports multiple variants of vanilla JavaScript Including: • TypeScript • Dart • ES6 • ES5 • TypeScript is a strongly typed superset of JavaScript currently in development at Microsoft. Angular 2 uses it after an agreement between Google and Microsoft • Pros • Strong typed for larger codebases/teams • Cons • Learning curve over traditional JavaScript • Must be compiled • Complicated to setup (requires definition files)
  45. 45. So can we use it in production yet? • Angular 2 went gold YESTERDAY so yes • Consider, however, that supporting technologies like ECMAScript 6, TypeScript and Web Components will require compilers and polyfills until native support is universally achieved
  46. 46. WRAP UP Tying it all together
  47. 47. Summary • The MEAN stack is comprised of four JavaScript based technologies • It can provide a flexible and powerful web development environment to quickly build fast and scalable web apps • Leverages a single language allowing for development using resources with a similar coding toolset • Node is a powerful platform for real-time, I/O web applications and APIs • Express is a flexible server platform capable of complex MVC development • Mongo is a SQL-less document driven database technology • Angular is a front end framework that allows development of dynamic single page web application front-ends
  48. 48. MEAN at work • Best case scenarios for using Node: • Backend for RESTful data APIs • Streaming or real time app servers, like chat or associate communication servers • Apps/sites with small budget and tight timelines • Internal dynamic web based tools (Call Centers, Employee Support, Knowledge bases, etc.) • Monitoring Dashboards • Avoid for: • Business logic centric systems (Java outperforms) • Heavy server side computation
  49. 49. Want a more thorough look? • Take a hands on deep dive into the design of a simple MEAN based CRUD app • Github/jfox015 – Coming soon!
  50. 50. QUESTIONS? Anyone? Bueller?!?
  51. 51. Recommended Resources • NodeJS - Server Side JS • Best practices for Express app structure • Express.js Middleware Demystified • How to test your MongoDB models under Node & Express • Unit Testing Express Middleware • Unit Testing Express Middleware / TDD with Express and Mocha • Test driven Development of Web Apps in Node.Js • Node.js frameworks • Oracle vs. MongoDB • Angular 2 vs Angular 1
  52. 52. Connect with or stalk me (Entirelyuptoyou) •Web Site: jfox015.com •Twitter: @jfox015 •Github: Github.com/jfox015 •Slideshare: Slideshare.net/jfox015 •LinkedIn: Linkedin.com/in/jfox015
  53. 53. Thank you!

×