<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jordan Garcia on Medium]]></title>
        <description><![CDATA[Stories by Jordan Garcia on Medium]]></description>
        <link>https://medium.com/@jordanjgarcia?source=rss-115856fdf238------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mIqGNZVHsomIfrOzi_C04Q.jpeg</url>
            <title>Stories by Jordan Garcia on Medium</title>
            <link>https://medium.com/@jordanjgarcia?source=rss-115856fdf238------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 13:03:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jordanjgarcia/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[UI Components to the Rescue]]></title>
            <link>https://medium.com/engineers-optimizely/ui-components-to-the-rescue-32b6c47fbfad?source=rss-115856fdf238------2</link>
            <guid isPermaLink="false">https://medium.com/p/32b6c47fbfad</guid>
            <dc:creator><![CDATA[Jordan Garcia]]></dc:creator>
            <pubDate>Thu, 28 May 2015 16:38:56 GMT</pubDate>
            <atom:updated>2016-01-26T19:46:41.378Z</atom:updated>
            <content:encoded><![CDATA[<p>One codebase’s transformative journey from jQuery to UI components and Flux Architecture.</p><p>Spaghetti jQuery code, DOM selectors everywhere, and a pyramid of object soup are the best ways to describe Optimizely’s front-end codebase in early 2014.</p><p>At a company that has been growing as fast as Optimizely since it’s inception in 2010, you can’t really be upset about a bit of technical debt. We have an amazing product and, for us, the compromises made along the way were clearly worth it.</p><p>But then, it reached a tipping point. Frustrated by slow feature development, insane difficulty in understanding and visualizing the system, and challenges in maintaining quality led to a decision — a decision to re-think and refactor.</p><p>This post will walk your through our codebase’s transformative journey from jQuery spaghetti code to UI components and Flux Architecture.</p><h3>A brief history of Optimizely’s front-end stack</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W9nCqFTvjYSi9uidH6FXeg.jpeg" /></figure><p>Optimizely’s codebase was born in 2010 and was made of Closure (compiler, library, and framework), Knockout, and a lot of object oriented JavaScript. There were also many server rendered pages which is not ideal because it splits your codebase into two pieces: server-side and client-side front-end code.</p><p>If you were new developer at Optimizely in 2014 first looking into the codebase, you would have found the following function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/277dec8a7a05bc0758dd7ccc30f5d52c/href">https://medium.com/media/277dec8a7a05bc0758dd7ccc30f5d52c/href</a></iframe><p><em>What does this code do?</em></p><p><em>What values is it setting or what do these CSS selectors do?</em></p><p>Without context it is impossible to understand what this code is doing or how you would go about changing it to add functionality and tests.</p><p>Previous to joining Optimizely, I worked in a codebase that was 7 years old. With a lot of hard work, we were successfully able to refactor it into a component based system. Possibly the biggest win from this refactor, was the ability to create a lot of high-level UI tests that were able to test user interaction.</p><p><strong>When we took a step back and carved out some time to refactor, we identified the following shortcomings:</strong></p><ul><li>Knockout’s one-view model per page philosophy lead to copy / pasting code everywhere.</li><li>Business logic and UI logic became conflated in the same modules, leading to no clear separation between data models, thus neither are reusable.</li><li>Object instantiation pyramids made it so that in order to figure out context, you’d have to go all the way up the pyramid. (Essentially, everything started out as the same page.)</li></ul><p>We needed to change these in order to maintain code that was reusable and, in turn, more easily testable. By being able to reuse this testable code we can now move faster.</p><h3>Choosing a framework</h3><p><strong>Our requirements for a new framework were:</strong></p><ul><li>Something we could incrementally implement</li><li>A design that encouraged the decoupling of business logic and UI views</li><li>Something that does not need to support &lt; IE 10</li></ul><p>After investigating several candidates, including AngularJS, we found a very single-purposed component UI framework: <a href="http://vuejs.org/">VueJS</a>.</p><p>VueJS lived up to our checklist of requirements in a number of ways:</p><ul><li>It allows for incremental implementation. VueJS is light (14kb gzip+minified) and its components can be attached to the DOM disparately. Our first component we ever wrote was the Navbar.</li><li>It decouples business logic and UI views. VueJS is only concerned with UI components and doesn’t really have any opinions about data fetching and syncing, allowing us to implement our business logic in “services”.</li><li>There’s no need for legacy browser support. VueJS takes full advantage of ES5 getters / setters to provide a much simpler API. Contrast that to KnockoutJS’s need to convert every observable to a function.</li></ul><h3><strong>The very first component</strong></h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9660569d606335b5239bff0a23c429b0/href">https://medium.com/media/9660569d606335b5239bff0a23c429b0/href</a></iframe><p>And the corresponding HTML template:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6eb7667fb15293d4701083d243121122/href">https://medium.com/media/6eb7667fb15293d4701083d243121122/href</a></iframe><p>By moving to VueJS, we now have the tools we need to create small, reusable UI components. We are able to reuse the same UI elements on different pages, and a new developer can easily look at a single component and have a pretty good understanding of what it does, without having context on where it was used. Each day, more developers on our team have been able to start writing Vue components, and therefore, our library of a few components has quickly become dozens.</p><p>With VueJS, we achieved many of the goals we set out to accomplish:</p><ul><li>An incremental approach to refactoring our codebase? Check.</li><li>A decoupling of view and business logic? Check!</li><li>Out of the box re-usability of an any UI component? Check, check, check!</li></ul><p>This may all sound great (we’re pretty thrilled about it), but the story doesn’t end there. With a new architecture came a new problem: <strong>one of the <em>hardest problems</em> in the current landscape of front-end architecture.</strong></p><p>So stay-tuned until next time, when we will dive deep into that problem and our unique solution [SPOILER ALERT: It involves creating our own immutable Flux implementation].</p><p>Shameless plug: <a href="http://grnh.se/hlq410">we’re hiring</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W46N5NLoZZANTQGN9BrKSA.jpeg" /></figure><h4>About the author</h4><h3><strong>Jordan Garcia</strong></h3><p>Software Engineer @ Optimizely since March 2014.</p><p>Led the migration of Closure + Knockout code to Webpack + Flux + VueJS.</p><p>Creator of <a href="https://github.com/optimizely/nuclear-js">NuclearJS</a>.</p><p>Enjoys ping pong.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32b6c47fbfad" width="1" height="1" alt=""><hr><p><a href="https://medium.com/engineers-optimizely/ui-components-to-the-rescue-32b6c47fbfad">UI Components to the Rescue</a> was originally published in <a href="https://medium.com/engineers-optimizely">Engineers @ Optimizely</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>