{"id":353,"date":"2020-01-16T16:28:08","date_gmt":"2020-01-16T16:28:08","guid":{"rendered":"https:\/\/ctoinsight.com\/?p=353"},"modified":"2020-01-16T16:39:58","modified_gmt":"2020-01-16T16:39:58","slug":"javascript-es6-elevator","status":"publish","type":"post","link":"https:\/\/ctoinsight.com\/index.php\/2020\/01\/16\/javascript-es6-elevator\/","title":{"rendered":"Javascript ES6 Demo &#8211; Elevator System"},"content":{"rendered":"\n<p>When interviewing software developers, I like to give them a design problem to work out on a white board.  My favorite has been an elevator control system.  Everyone should know how elevators are supposed to work, so candidates shouldn&#8217;t get bogged down by lack of domain knowledge.  Of course, there is no single correct answer and the purpose is really to gain insight into their thought process and how they would approach a problem. I often thought about what my design would look like, but I never followed through and implemented any of my ideas.  So, I finally decided to take the plunge and code it to create a Javascript ES6 Demo.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Javascript ES6 Demo<\/h2>\n\n\n\n<p>You can see it running <a href=\"https:\/\/steveobjectmethods.github.io\/ElevatorJS\/\">here<\/a> and you can get the source code <a href=\"https:\/\/github.com\/steveobjectmethods\/ElevatorJS\">here on Github<\/a>.<\/p>\n\n\n\n<p>I decided to implement it in Javascript so it can run in a web browser without any backend.  <a href=\"https:\/\/www.w3schools.com\/js\/js_es6.asp\">ECMAScript 6<\/a> is widely supported now, so I was able to take advantage of some more advanced Javascript language features.  IntelliJ was my development environment.  Also, the <a href=\"https:\/\/developers.google.com\/web\/tools\/chrome-devtools\">developer tools in Chrome<\/a> were invaluable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Architecture<\/h2>\n\n\n\n<p>I first considered a distributed architecture with independent controllers for each elevator that &#8220;bid&#8221; on elevator call requests like an auction (e.g., the elevator that can accept the request with the least cost would get it).  The <a href=\"https:\/\/en.wikipedia.org\/wiki\/Actor_model\">actor<\/a> model would be a good fit for this approach.  But I ended up deciding to implement a centralized control system as an initial solution.  I may revisit the distributed architecture in a future implementation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Metrics and Optimization<\/h2>\n\n\n\n<p>What exactly are we trying to optimize?  The metrics I used are:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Average Wait Time &#8211; the average time a person must wait before being picked up.<\/li><li>Average Travel Time &#8211; the average time a person spends inside an elevator.<\/li><li>Average Total Time &#8211; the sum of wait and travel time.<\/li><\/ol>\n\n\n\n<p>I also considered using elevator power consumption as a metric.  Modern elevators generate power when they are traveling down which makes this very interesting.  But I left this as future work.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>An interactive elevator control system  and demo implemented in Javascript (ES6) is described.  There are links to a demo and the source code.<\/p>\n","protected":false},"author":1,"featured_media":354,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[8],"tags":[25,24],"class_list":["post-353","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","tag-es6","tag-javascript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Javascript ES6 Demo - Elevator System - CTO Insights<\/title>\n<meta name=\"description\" content=\"An interactive elevator control system and demo implemented in Javascript (ES6) is described. There are links to a demo and the source code.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ctoinsight.com\/index.php\/2020\/01\/16\/javascript-es6-elevator\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Javascript ES6 Demo - Elevator System - CTO Insights\" \/>\n<meta property=\"og:description\" content=\"An interactive elevator control system and demo implemented in Javascript (ES6) is described. There are links to a demo and the source code.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ctoinsight.com\/index.php\/2020\/01\/16\/javascript-es6-elevator\/\" \/>\n<meta property=\"og:site_name\" content=\"CTO Insights\" \/>\n<meta property=\"article:published_time\" content=\"2020-01-16T16:28:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-01-16T16:39:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ctoinsight.com\/wp-content\/uploads\/2020\/01\/an-antique-elevator-indicator-si.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Steve Kowalski\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Steve Kowalski\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/ctoinsight.com\\\/index.php\\\/2020\\\/01\\\/16\\\/javascript-es6-elevator\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ctoinsight.com\\\/index.php\\\/2020\\\/01\\\/16\\\/javascript-es6-elevator\\\/\"},\"author\":{\"name\":\"Steve Kowalski\",\"@id\":\"https:\\\/\\\/ctoinsight.com\\\/#\\\/schema\\\/person\\\/ae035f84ffb32d94aa6f4aa9b3780df0\"},\"headline\":\"Javascript ES6 Demo &#8211; Elevator System\",\"datePublished\":\"2020-01-16T16:28:08+00:00\",\"dateModified\":\"2020-01-16T16:39:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ctoinsight.com\\\/index.php\\\/2020\\\/01\\\/16\\\/javascript-es6-elevator\\\/\"},\"wordCount\":347,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/ctoinsight.com\\\/#\\\/schema\\\/person\\\/ae035f84ffb32d94aa6f4aa9b3780df0\"},\"image\":{\"@id\":\"https:\\\/\\\/ctoinsight.com\\\/index.php\\\/2020\\\/01\\\/16\\\/javascript-es6-elevator\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/ctoinsight.com\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/an-antique-elevator-indicator-si.jpg\",\"keywords\":[\"ES6\",\"Javascript\"],\"articleSection\":[\"Software\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/ctoinsight.com\\\/index.php\\\/2020\\\/01\\\/16\\\/javascript-es6-elevator\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ctoinsight.com\\\/index.php\\\/2020\\\/01\\\/16\\\/javascript-es6-elevator\\\/\",\"url\":\"https:\\\/\\\/ctoinsight.com\\\/index.php\\\/2020\\\/01\\\/16\\\/javascript-es6-elevator\\\/\",\"name\":\"Javascript ES6 Demo - Elevator System - CTO Insights\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ctoinsight.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ctoinsight.com\\\/index.php\\\/2020\\\/01\\\/16\\\/javascript-es6-elevator\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/ctoinsight.com\\\/index.php\\\/2020\\\/01\\\/16\\\/javascript-es6-elevator\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/ctoinsight.com\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/an-antique-elevator-indicator-si.jpg\",\"datePublished\":\"2020-01-16T16:28:08+00:00\",\"dateModified\":\"2020-01-16T16:39:58+00:00\",\"description\":\"An interactive elevator control system and demo implemented in Javascript (ES6) is described. There are links to a demo and the source code.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ctoinsight.com\\\/index.php\\\/2020\\\/01\\\/16\\\/javascript-es6-elevator\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ctoinsight.com\\\/index.php\\\/2020\\\/01\\\/16\\\/javascript-es6-elevator\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ctoinsight.com\\\/index.php\\\/2020\\\/01\\\/16\\\/javascript-es6-elevator\\\/#primaryimage\",\"url\":\"https:\\\/\\\/ctoinsight.com\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/an-antique-elevator-indicator-si.jpg\",\"contentUrl\":\"https:\\\/\\\/ctoinsight.com\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/an-antique-elevator-indicator-si.jpg\",\"width\":1280,\"height\":720,\"caption\":\"Antique elevator\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ctoinsight.com\\\/index.php\\\/2020\\\/01\\\/16\\\/javascript-es6-elevator\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ctoinsight.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Javascript ES6 Demo &#8211; Elevator System\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ctoinsight.com\\\/#website\",\"url\":\"https:\\\/\\\/ctoinsight.com\\\/\",\"name\":\"CTO Insights\",\"description\":\"Thoughts on software and technology leadership\",\"publisher\":{\"@id\":\"https:\\\/\\\/ctoinsight.com\\\/#\\\/schema\\\/person\\\/ae035f84ffb32d94aa6f4aa9b3780df0\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/ctoinsight.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/ctoinsight.com\\\/#\\\/schema\\\/person\\\/ae035f84ffb32d94aa6f4aa9b3780df0\",\"name\":\"Steve Kowalski\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/558ae6d325255bc5d2dd8dbf91724b3d5df6dbbd5c48e45bf8981de2b32907bb?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/558ae6d325255bc5d2dd8dbf91724b3d5df6dbbd5c48e45bf8981de2b32907bb?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/558ae6d325255bc5d2dd8dbf91724b3d5df6dbbd5c48e45bf8981de2b32907bb?s=96&d=mm&r=g\",\"caption\":\"Steve Kowalski\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/558ae6d325255bc5d2dd8dbf91724b3d5df6dbbd5c48e45bf8981de2b32907bb?s=96&d=mm&r=g\"},\"description\":\"Chief Technology Officer (CTO) - SaaS, Cloud, Agile\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/drstevekowalski\\\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Javascript ES6 Demo - Elevator System - CTO Insights","description":"An interactive elevator control system and demo implemented in Javascript (ES6) is described. There are links to a demo and the source code.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ctoinsight.com\/index.php\/2020\/01\/16\/javascript-es6-elevator\/","og_locale":"en_US","og_type":"article","og_title":"Javascript ES6 Demo - Elevator System - CTO Insights","og_description":"An interactive elevator control system and demo implemented in Javascript (ES6) is described. There are links to a demo and the source code.","og_url":"https:\/\/ctoinsight.com\/index.php\/2020\/01\/16\/javascript-es6-elevator\/","og_site_name":"CTO Insights","article_published_time":"2020-01-16T16:28:08+00:00","article_modified_time":"2020-01-16T16:39:58+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/ctoinsight.com\/wp-content\/uploads\/2020\/01\/an-antique-elevator-indicator-si.jpg","type":"image\/jpeg"}],"author":"Steve Kowalski","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Steve Kowalski","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ctoinsight.com\/index.php\/2020\/01\/16\/javascript-es6-elevator\/#article","isPartOf":{"@id":"https:\/\/ctoinsight.com\/index.php\/2020\/01\/16\/javascript-es6-elevator\/"},"author":{"name":"Steve Kowalski","@id":"https:\/\/ctoinsight.com\/#\/schema\/person\/ae035f84ffb32d94aa6f4aa9b3780df0"},"headline":"Javascript ES6 Demo &#8211; Elevator System","datePublished":"2020-01-16T16:28:08+00:00","dateModified":"2020-01-16T16:39:58+00:00","mainEntityOfPage":{"@id":"https:\/\/ctoinsight.com\/index.php\/2020\/01\/16\/javascript-es6-elevator\/"},"wordCount":347,"commentCount":0,"publisher":{"@id":"https:\/\/ctoinsight.com\/#\/schema\/person\/ae035f84ffb32d94aa6f4aa9b3780df0"},"image":{"@id":"https:\/\/ctoinsight.com\/index.php\/2020\/01\/16\/javascript-es6-elevator\/#primaryimage"},"thumbnailUrl":"https:\/\/ctoinsight.com\/wp-content\/uploads\/2020\/01\/an-antique-elevator-indicator-si.jpg","keywords":["ES6","Javascript"],"articleSection":["Software"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ctoinsight.com\/index.php\/2020\/01\/16\/javascript-es6-elevator\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ctoinsight.com\/index.php\/2020\/01\/16\/javascript-es6-elevator\/","url":"https:\/\/ctoinsight.com\/index.php\/2020\/01\/16\/javascript-es6-elevator\/","name":"Javascript ES6 Demo - Elevator System - CTO Insights","isPartOf":{"@id":"https:\/\/ctoinsight.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ctoinsight.com\/index.php\/2020\/01\/16\/javascript-es6-elevator\/#primaryimage"},"image":{"@id":"https:\/\/ctoinsight.com\/index.php\/2020\/01\/16\/javascript-es6-elevator\/#primaryimage"},"thumbnailUrl":"https:\/\/ctoinsight.com\/wp-content\/uploads\/2020\/01\/an-antique-elevator-indicator-si.jpg","datePublished":"2020-01-16T16:28:08+00:00","dateModified":"2020-01-16T16:39:58+00:00","description":"An interactive elevator control system and demo implemented in Javascript (ES6) is described. There are links to a demo and the source code.","breadcrumb":{"@id":"https:\/\/ctoinsight.com\/index.php\/2020\/01\/16\/javascript-es6-elevator\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ctoinsight.com\/index.php\/2020\/01\/16\/javascript-es6-elevator\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ctoinsight.com\/index.php\/2020\/01\/16\/javascript-es6-elevator\/#primaryimage","url":"https:\/\/ctoinsight.com\/wp-content\/uploads\/2020\/01\/an-antique-elevator-indicator-si.jpg","contentUrl":"https:\/\/ctoinsight.com\/wp-content\/uploads\/2020\/01\/an-antique-elevator-indicator-si.jpg","width":1280,"height":720,"caption":"Antique elevator"},{"@type":"BreadcrumbList","@id":"https:\/\/ctoinsight.com\/index.php\/2020\/01\/16\/javascript-es6-elevator\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ctoinsight.com\/"},{"@type":"ListItem","position":2,"name":"Javascript ES6 Demo &#8211; Elevator System"}]},{"@type":"WebSite","@id":"https:\/\/ctoinsight.com\/#website","url":"https:\/\/ctoinsight.com\/","name":"CTO Insights","description":"Thoughts on software and technology leadership","publisher":{"@id":"https:\/\/ctoinsight.com\/#\/schema\/person\/ae035f84ffb32d94aa6f4aa9b3780df0"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ctoinsight.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/ctoinsight.com\/#\/schema\/person\/ae035f84ffb32d94aa6f4aa9b3780df0","name":"Steve Kowalski","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/558ae6d325255bc5d2dd8dbf91724b3d5df6dbbd5c48e45bf8981de2b32907bb?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/558ae6d325255bc5d2dd8dbf91724b3d5df6dbbd5c48e45bf8981de2b32907bb?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/558ae6d325255bc5d2dd8dbf91724b3d5df6dbbd5c48e45bf8981de2b32907bb?s=96&d=mm&r=g","caption":"Steve Kowalski"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/558ae6d325255bc5d2dd8dbf91724b3d5df6dbbd5c48e45bf8981de2b32907bb?s=96&d=mm&r=g"},"description":"Chief Technology Officer (CTO) - SaaS, Cloud, Agile","sameAs":["https:\/\/www.linkedin.com\/in\/drstevekowalski\/"]}]}},"_links":{"self":[{"href":"https:\/\/ctoinsight.com\/index.php\/wp-json\/wp\/v2\/posts\/353","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ctoinsight.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ctoinsight.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ctoinsight.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ctoinsight.com\/index.php\/wp-json\/wp\/v2\/comments?post=353"}],"version-history":[{"count":24,"href":"https:\/\/ctoinsight.com\/index.php\/wp-json\/wp\/v2\/posts\/353\/revisions"}],"predecessor-version":[{"id":378,"href":"https:\/\/ctoinsight.com\/index.php\/wp-json\/wp\/v2\/posts\/353\/revisions\/378"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ctoinsight.com\/index.php\/wp-json\/wp\/v2\/media\/354"}],"wp:attachment":[{"href":"https:\/\/ctoinsight.com\/index.php\/wp-json\/wp\/v2\/media?parent=353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ctoinsight.com\/index.php\/wp-json\/wp\/v2\/categories?post=353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ctoinsight.com\/index.php\/wp-json\/wp\/v2\/tags?post=353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}