<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>css &#8211; Software, Fitness, and Gaming &#8211; Jesse Warden</title>
	<atom:link href="https://jessewarden.com/tag/css/feed" rel="self" type="application/rss+xml" />
	<link>https://jessewarden.com</link>
	<description>Software &#124; Fitness &#124; Gaming</description>
	<lastBuildDate>Sat, 12 Jan 2019 16:11:43 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://jessewarden.com/wp-content/uploads/2016/08/cropped-Lambda2-32x32.png</url>
	<title>css &#8211; Software, Fitness, and Gaming &#8211; Jesse Warden</title>
	<link>https://jessewarden.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Front End Development 5 Years Later</title>
		<link>https://jessewarden.com/2019/01/front-end-development-5-years-later.html</link>
		
		<dc:creator><![CDATA[JesterXL]]></dc:creator>
		<pubDate>Sat, 12 Jan 2019 15:57:46 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[front end]]></category>
		<category><![CDATA[frontend]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<guid isPermaLink="false">http://jessewarden.com/?p=5760</guid>

					<description><![CDATA[Chris Coyier, a famous web dev whose articles on CSS/HTML/design have helped even lowly me, has a super compelling video my colleague Steven Sacks shared with me.&#160;Chris covers the many facets of &#8220;what is a front end developer&#8221;, the identity crisis the term has, and it&#8217;s fascinating. Totally valid in what I&#8217;ve seen in the [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p><a href="https://chriscoyier.net/" rel="noreferrer noopener" target="_blank">Chris Coyier</a>, a famous web dev whose articles on CSS/HTML/design have helped even lowly me, has a super compelling video my colleague <a href="https://www.linkedin.com/in/stevensacks/" target="_blank" rel="noreferrer noopener">Steven Sacks</a> shared with me.&nbsp;Chris covers the many facets of &#8220;what is a front end developer&#8221;, the identity crisis the term has, and it&#8217;s fascinating. Totally valid in what I&#8217;ve seen in the past 8 years.</p>



<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
https://www.youtube.com/watch?v=jf6GhdttPBc
</div></figure>



<span id="more-5760"></span>



<p>Now, 5 years ago, I made a video aimed at the skills I saw employers looking for in web development after 6 months of miserable interviews.</p>



<p>Here&#8217;s one hiring a front end developer when they really needed what I call a &#8220;web designer&#8221;, someone with strong CSS chops:</p>



<p>&#8220;I need pixel perfect designs. Can you do that?<br>&#8220;No, I build web applications, not websites. You need a guy to code it, I&#8217;m you&#8217;re man. You need someone to go into Photoshop and convert all those un-flattened layers to CSS, that&#8217;s not me. I work with those people to make apps.&#8221;<br>&#8220;Interesting&#8230; so you don&#8217;t build websites?&#8221;<br>&#8220;Correct, I build web applications.&#8221;<br>&#8220;What&#8217;s the difference?&#8221;<br>&#8220;90% content? Website. 90% user interaction with dynamic data in the back-end? Web application.&#8221;<br>&#8220;Hrm, but that&#8217;s what we&#8217;re building&#8230; and it needs to be pixel perfect on all browsers.&#8221; &#8220;Ok, who&#8217;s going to code it?&#8221;<br>&#8220;Same person.&#8221;<br>&#8220;You&#8217;re telling me you&#8217;re going to hire a JQuery developer to use an MVC framework like Angular which still doesn&#8217;t support components, with their own Node Restify orchestration layer both of which are deployed with Heroku with their current CICD npm build scripts somehow linked in your Jenkins&#8230; that somehow magically got deployed via Docker on some random EC2 which is deployed by your non-existent Ops team using and managing Chef?&#8221;<br>&#8220;I&#8217;m not sure what all that means.&#8221;<br>&#8220;Sir, free consulting advice: You&#8217;re looking for a web developer who has HTML and CSS chops. Stop caring about the JavaScript chops, I promise you if they have &#8216;a portfolio&#8217; with web sites in it, then they can do what you need. Stop telling recruiters you need a JavaScript developer; you don&#8217;t. We&#8217;re twice the cost of those CSS devs, too, FYI.&#8221;</p>



<p>The opposite was those who wanted back end developers who had framework experience, yet pitched it as &#8220;an Angular developer who knows .NET&#8221; or &#8220;a React developer who is familiar with Java&#8221;.</p>



<p>&#8220;Do you know Angular?&#8221;<br>&#8220;Yes.&#8221;<br>&#8220;Explain to me MVC, then.&#8221;<br>:: 5 hours later :: &#8220;Ok&#8230; you clearly know how to program. Great, so what&#8217;s your .NET experience?&#8221;<br>&#8220;None, I hate back-end, I&#8217;ve spent the last 15 years building front-ends and hit everything on the back-end excluding Aida and RPG.&#8221;<br>&#8220;Oh&#8230; so no .NET then?&#8221;<br>&#8220;I can read .NET and C# and VB and could learn to compile it if need be if someone needs fixing, or the XML SOAP needs to be converted to JSON.&#8221;<br>&#8220;That&#8217;s too bad, sorry, you won&#8217;t fit.&#8221;<br>&#8220;So 99% of the job is building front-end web applications, configuring grunt builds with various npm dev dependencies to ensure your pipeline accounts for the fact it&#8217;s actually deployed in a custom .NET MVC code process because no one spent the time to explain what a Single Page Application is, so you treat it like an artifact in a Java .jar file. You want Bootstrap styled designs with someone who&#8217;s aware of how to handle event bubbling so they can hack it into your existing .NET MVC app but not break your modals, yet can get your debug code minified and uglified into a single deployable artifact via require.js + uglify js in that hacked grunt file extension Node script&#8230; and you&#8217;re telling me that type of person who knows the same design patterns like Observer, Proxy, and Memento like your back-end developers can&#8217;t figure out how to tweak a 4 year old .NET service in a reasonable time frame?&#8221;<br>&#8220;Yeah.&#8221;<br>&#8220;I see&#8230; when you guys get bored and re-write your back-end in Node, let the recruiter know and we can repeat this interview.&#8221;</p>



<p>It was based on the type of work I wanted to do, and knew was out there, and I knew was coming. Literally 1 year later, I&#8217;m interviewing 12 year .NET and Java developers veterans chomping at the bit for front-end Angular/React experience. WAT.</p>



<p>My video even accidentally scored a huge contract for my employer at the time, Accenture. It wasn&#8217;t because of me; it was because the skills I outlined consist of MULTIPLE TYPES OF PEOPLE, and large consulting firms can create that village of people, and our client knew that. This &#8220;full stack&#8221; nonsense had the dumb ones thinking they &#8220;could just hire a talented JavaScript developer&#8221;. Again, this was 5 years ago.</p>



<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="What Are The HTML5 Skills Employers Are Looking For?" width="500" height="281" src="https://www.youtube.com/embed/vJM9kRsXgAI?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p>After watching Chris&#8217; video, it&#8217;s fascinating in retrospect to watch mine and see how it is laser focused on &#8220;application front end developer&#8221;, meaning, I wrote code, avoided HTML and CSS at all costs, and focuses on business logic for the front end browser specifically. My assumption was those watching the video wanted to build apps. Those who already did HTML and CSS with Design would still do the same thing, the industry would just start calling them &#8220;Designers&#8221; heh&#8230; or they&#8217;d get pigeonholed into WordPress/Expression Engine/Drupal or even Agency work. To this day, my advice still stands, but so to do the weaknesses. Meaning, if your CSS framework doesn&#8217;t support a strong layout story or is even deprecated, a la <a rel="noreferrer noopener" href="https://getmdl.io/" target="_blank">Material Design Lite</a>, what do you do when all you have is &#8220;full stack devs&#8221; who don&#8217;t have design chops?</p>



<p>You can do one of the following:</p>



<ul class="wp-block-list"><li>learn CSS and some minor HTML (not happening)</li><li>or more likely find a better component framework</li><li>or even more likely convince your Designer to &#8220;design for the component framework&#8221;. If you&#8217;re building a Bootstrap site, make the design look like Bootstrap; use bootstrap components, use their grid model, etc.</li></ul>



<p>If your company has a design system (and I bet from asking it around, it may have many competing ones if you&#8217;re large enough), then you&#8217;ll end up encouraging your designer to design around that &#8220;so that your team can build things vs. building things to build things&#8221;.</p>



<p>As someone who used to interview a ton and has recently only interviewed a little, yet still seen the industry change, I&#8217;ve noticed a pattern. In the past 8 years there is a distinct class that I believe Chris Coyier and other UX types are in. Yes, the tree is varied, BUT THERE ARE 2 TREES. They are who I label as &#8220;good at CSS&#8221; which really means Designers who have extremely good CSS knowledge and write good, semantic HTML that&#8217;s easier to make accessible. They still build the web, but because &#8220;JavaScript Developers&#8221; outnumber them, they&#8217;re falsely labeled as designers.</p>



<p>They make websites.</p>



<p>The others, those who are programmers who use JavaScript, also make websites. Most of us don&#8217;t really care about CSS and HTML. I don&#8217;t think that&#8217;s going to change, though.</p>



<p>So what now? There is a huge push for Design Systems in Enterprises. Specifically, something like <a href="https://getbootstrap.com/" rel="noreferrer noopener" target="_blank">Bootstrap</a>, <a href="https://foundation.zurb.com/" rel="noreferrer noopener" target="_blank">Foundation</a>, or <a href="https://material.io/design/" rel="noreferrer noopener" target="_blank">Material Design</a>, but branded for your company or department / line of business. You can Google what a design system is specifically (it&#8217;s a huge deal and complicated and powerful), but for people like me, the end result is: Components. Meaning, it provides the Leggo&#8217;s to build applications. Any front end team building web applications will spend a lot of time &#8220;making things to make things&#8221;; they&#8217;ll take buttons and text inputs to build a form; they&#8217;ll use those forms to build input screens for other large components they compose into an application. Doesn&#8217;t matter if it&#8217;s <a href="https://elm-lang.org/" rel="noreferrer noopener" target="_blank">Elm</a>, <a href="https://vuejs.org/" rel="noreferrer noopener" target="_blank">Vue</a>, <a href="https://reactjs.org/" rel="noreferrer noopener" target="_blank">React</a>, or <a href="https://angular.io/" rel="noreferrer noopener" target="_blank">Angular</a>; same problem. You need good looking Buttons to make a good looking, and well functioning applications.</p>



<p>Note I am NOT talking about <a href="https://wordpress.com/" rel="noreferrer noopener" target="_blank">WordPress</a>, <a href="https://expressionengine.com/" rel="noreferrer noopener" target="_blank">Expression Engine</a>, <a href="https://www.drupal.org/" rel="noreferrer noopener" target="_blank">Drupal</a>, <a href="https://sailsjs.com/" rel="noreferrer noopener" target="_blank">Sails</a>, etc. The &#8220;developers&#8221; (web designers) who use those types of frameworks already know how to design and build what they need.</p>



<p>Design systems make that possible by 3 important things:</p>



<ol class="wp-block-list"><li>They handle the CSS and HTML.</li><li>They tailor it to your framework.</li><li>They figure out all the design and branding rules and provide strong guidelines</li></ol>



<p>This is huge. Chris has a great attitude, and alludes to the common theme in our industry of &#8220;constant learning&#8221; with a positive vibe. That&#8217;s great. You can see he also acknowledges that some things will never be learned by particular people because they simply don&#8217;t want to and have passions in other areas. HTML and CSS, and their design result in particular with company / line of business branding, requires a massively different skillset than <a rel="noreferrer noopener" href="https://en.wikipedia.org/wiki/Object-oriented_programming" target="_blank">Object Oriented Programming</a>. The person in your company creating design atoms, thinking about accessibility, re-reading <a rel="noreferrer noopener" href="https://www.amazon.com/Dont-Make-Me-Think-Usability/dp/0321344758" target="_blank">Steve Krug</a>, gorging on <a rel="noreferrer noopener" href="https://www.nngroup.com/articles/" target="_blank">https://www.nngroup.com/articles/</a> articles, and iterating on layouts and terms in <a rel="noreferrer noopener" href="https://www.sketchapp.com/" target="_blank">Sketch</a> is not the same person encouraging your front end and orchestration API teams to leverage <a rel="noreferrer noopener" href="https://en.wikipedia.org/wiki/Algebraic_data_type" target="_blank">Algebraic Data Types</a> as <a rel="noreferrer noopener" href="https://www.youtube.com/watch?v=6TDKHGtAxeg" target="_blank">a replacement for if/statements</a> when a compiler isn&#8217;t present.</p>



<p>Different people. Different teams. Different skillsets. Same goal, though: Build awesome websites.</p>



<p>Those creating the design system which leads to a component framework like <a href="https://material-ui.com/" rel="noreferrer noopener" target="_blank">Material Design for React</a> or <a href="https://ng-bootstrap.github.io/#/home" rel="noreferrer noopener" target="_blank">Bootstrap for Angular</a> are the ones empowering people like me to be effective to build things without worrying about our weaknesses. Specifically knowing the design and layout languages of the web: HTML and CSS.</p>



<p>That&#8217;s one thing that should continue to be encouraged. Large swaths of the enterprises I&#8217;ve worked with have completely broken interview processes and wrong interpretations of the village it takes to build small and large web applications. If you&#8217;re going to continue to hire programmers and designers, but not hire those who know how the web is built, then at least have those who <em>do</em> know and somehow exist in your company empower those who don&#8217;t. Let them build design systems that turn into component frameworks that front end web developers can use to make awesome, branded applications.</p>



<p>Lastly, we should acknowledge, despite projects that vary on the skillsets needed, that <a href="https://en.wikipedia.org/wiki/It_takes_a_village" rel="noreferrer noopener" target="_blank">it takes a village</a> to make great software. If you have even an inkling of custom design, you need at least someone who&#8217;s got HTML/CSS chops on your project, or your department to help support the other teams. Else, you&#8217;ll get teams that focus on functionality, and less on design intent&#8230; because they can&#8217;t. They don&#8217;t know how, waste time on it, give up, and it validates (falsely) that it&#8217;s a waste of their time because it&#8217;s not their passion, encouraging less of a care in the future. Ask any designer if the developers they work with take ownership of their designs, and the ones who say &#8220;yes&#8221; will have the UX types Chris refers to on their team or within support reach.</p>



<p>Those who say &#8220;no&#8221;, don&#8217;t. They may have the will, but they won&#8217;t have the skillset.</p>



<p>Below is one of the compelling examples of the myriad of skillsets that make up a &#8220;front end developer&#8221;.</p>



<figure class="wp-block-image"><img decoding="async" src="https://media.licdn.com/dms/image/C4E12AQGeeHXyuH4eQw/article-inline_image-shrink_1500_2232/0?e=1552521600&amp;v=beta&amp;t=CcUH0jvKMhYzXRryVo12ccvqtQVI9NvDptw6tT6oMm8" alt=""/></figure>



<p>If you&#8217;re hiring front end developers for your company, I highly encourage you to watch Chris&#8217; video. If you&#8217;re in a hurry and want the executive summary, watch from <a rel="noreferrer noopener" href="https://youtu.be/jf6GhdttPBc?t=1200" target="_blank">20:00</a> &#8211; 22:15. If you want your head hurt on concepts that validate just how broad front end development is in terms of skills and focus areas, watch <a rel="noreferrer noopener" href="https://youtu.be/jf6GhdttPBc?t=1635" target="_blank">27:15</a> &#8211; 29:31. These developers who used to build the web, and now continue to build &#8220;web sites&#8221; are not being carried over en-masse into the Enterprise unless they&#8217;re willing to lie about their React, Node, and JavaScript skillset or are hired as UX Designers. It&#8217;s a mistake. Like Brad Frost says, they are the &#8220;Front of the Front&#8221; and I&#8217;m the &#8220;Back of the Front&#8221;&#8230; and even then, I don&#8217;t even do <a rel="noreferrer noopener" href="https://webpack.js.org/" target="_blank">Webpack</a>, the current popular JavaScript compiler. I outsource that to Facebook in <a rel="noreferrer noopener" href="https://github.com/facebook/create-react-app" target="_blank">create-react-app</a> or <a rel="noreferrer noopener" href="https://cli.angular.io/" target="_blank">Angular CLI</a> or <a rel="noreferrer noopener" href="https://cli.vuejs.org/" target="_blank">Vue CLI</a> to be the &#8220;Back to the Back of the Front&#8221;.</p>



<p>Recognize the differences. Communicate that to your managers. Explain the risks of not having people with CSS chops (Design and Product/Business is your ally here) on your team(s). The world has changed how we build web applications, but the core design language, while vastly improved and more complicated, has not. If you know HTML and CSS, your industry has a huge branding problem. Half of them are fine in the Agency world. Those working on websites with that use SPA frameworks, we need to fight for you to be at the same table as us as you&#8217;re desperately needed to make our front end team &#8220;complete&#8221;.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Fun With Polymer 1.1</title>
		<link>https://jessewarden.com/2015/09/fun-with-polymer-1-1.html</link>
		
		<dc:creator><![CDATA[JesterXL]]></dc:creator>
		<pubDate>Sat, 19 Sep 2015 02:20:49 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[htmlimports]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[materialdesign]]></category>
		<category><![CDATA[polymer]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[shadowdom]]></category>
		<category><![CDATA[webcomponents]]></category>
		<guid isPermaLink="false">http://jessewarden.com/?p=4895</guid>

					<description><![CDATA[Introduction I&#8217;ve spent the past 2 weeks of my vacation playing with JavaScript, Polymer, Node, Express, Restify, and Mongo.Â Today, I wanted to cover the fun I had with Polymer, Google&#8217;s web UI component framework, contrast it with other frameworks, and give my general impressions. From this you&#8217;ll have a firm understanding of what Polymer is [&#8230;]]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<p>I&#8217;ve spent the past 2 weeks of my vacation playing with JavaScript, <a href="https://www.polymer-project.org/1.0/">Polymer</a>, <a href="https://nodejs.org/en/">Node</a>, <a href="http://expressjs.com/">Express</a>, <a href="http://mcavage.me/node-restify/">Restify</a>, and <a href="https://www.mongodb.org/">Mongo</a>.Â Today, I wanted to cover the fun I had with Polymer, Google&#8217;s web UI component framework, contrast it with other frameworks, and give my general impressions. From this you&#8217;ll have a firm understanding of what Polymer is for, how to use it, and what things to watch for.</p>
<p><span id="more-4895"></span></p>
<h2>What is Polymer?</h2>
<p>Polymer is Google&#8217;s open source web component UI framework. The goal is to allow developers to utilize the latest web standards for web components in a cross browser way, today. <a href="http://www.w3.org/TR/components-intro/">Web components</a> is an umbrella of standards, specifically <a href="http://www.html5rocks.com/en/tutorials/webcomponents/shadowdom/">Shadow DOM</a>, <a href="http://www.html5rocks.com/en/tutorials/webcomponents/customelements/">Custom Elements</a>, and <a href="http://www.html5rocks.com/en/tutorials/webcomponents/imports/">HTML Imports</a>.</p>
<p>These are the core technologies needed in browsers to build web components.Â Given the web community is &#8220;design by committee&#8221;, it&#8217;s actually quite a fast moving standard in that context, thus much has changed between Polymer version 0.5 and version 1.x. That said, Google&#8217;s done a great job of shielding you from a lot of these core changes as well as including new featuresÂ that iterate on top of previous work.</p>
<p>&#8230; the whole point of creating a UI framework, heh.</p>
<p>In short, Polymer allows you to create your own UI controls more easily than you could in the past, built on webÂ standards, and with performance in mind.Â That, and they already follow the <a href="https://www.google.com/design/spec/material-design/introduction.html">Material Design guidelines</a>.</p>
<h2>What does the codeÂ look like in practice?</h2>
<p>While this is native in browsers now:</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-11.14.45-AM.png"><img decoding="async" class="size-full wp-image-4899 alignnone" src="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-11.14.45-AM.png" alt="Screen Shot 2015-09-18 at 11.14.45 AM" width="374" height="45" srcset="https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-11.14.45-AM.png 374w, https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-11.14.45-AM-300x36.png 300w" sizes="(max-width: 374px) 100vw, 374px" /></a></p>
<p>Results in this:</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-2.53.19-PM.png"><img decoding="async" class="size-full wp-image-4906 alignnone" src="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-2.53.19-PM.png" alt="Screen Shot 2015-09-18 at 2.53.19 PM" width="64" height="57" /></a></p>
<p>You can now do this:</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-2.54.17-PM.png"><img loading="lazy" decoding="async" class="size-full wp-image-4910 alignnone" src="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-2.54.17-PM.png" alt="Screen Shot 2015-09-18 at 2.54.17 PM" width="532" height="47" srcset="https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-2.54.17-PM.png 532w, https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-2.54.17-PM-300x27.png 300w" sizes="auto, (max-width: 532px) 100vw, 532px" /></a></p>
<p>And you&#8217;ll see this:</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-2.52.47-PM1.png"><img loading="lazy" decoding="async" class="size-full wp-image-4908 alignnone" src="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-2.52.47-PM1.png" alt="Screen Shot 2015-09-18 at 2.52.47 PM" width="87" height="54" /></a></p>
<p>Notice in <a href="http://getbootstrap.com/">Bootstrap</a>, you have toÂ apply the CSS classes toÂ the tag:</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.13.31-PM.png"><img loading="lazy" decoding="async" class="size-full wp-image-4911 alignnone" src="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.13.31-PM.png" alt="Screen Shot 2015-09-18 at 3.13.31 PM" width="74" height="54" /></a></p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.13.49-PM.png"><img loading="lazy" decoding="async" class="size-full wp-image-4912 alignnone" src="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.13.49-PM.png" alt="Screen Shot 2015-09-18 at 3.13.49 PM" width="797" height="57" srcset="https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.13.49-PM.png 797w, https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.13.49-PM-300x21.png 300w" sizes="auto, (max-width: 797px) 100vw, 797px" /></a></p>
<p>Unlike Bootstrap, and like <a href="http://benclinkinbeard.com/posts/introducing-atomify-a-new-standard-of-modularity/">Atomify</a>,Â Polymer&#8217;s goal is encapsulate everything; not just the CSS,Â but also the JavaScript functionality, and additional HTML tags that make it up.</p>
<p>You&#8217;ll see a common theme with Polymer is mainly focused around markup, specifically HTML tags. If you come from <a href="https://angularjs.org/">Angular</a> or <a href="https://facebook.github.io/react/">React</a>, you&#8217;ll immediately get that concept of creating your own elements to use. Polymer is the same way.</p>
<p>The reason for this is attempting to mitigateÂ &#8220;div soup&#8221;, where you have a lot of nested divs that use CSS styles create the user interface, as well as helping create semantics: allowing various technologies to glean meaning from your page. The semantics help for Search Engine Optimization, Accessibility, and even during development to lessen the cognitive overhead from developers and designers.</p>
<p>Contrast how <a href="https://mail.google.com/">GMail</a> is built:</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/div-soup.png"><img loading="lazy" decoding="async" class="alignnone wp-image-4897 size-large" src="http://jessewarden.com/wp-content/uploads/2015/09/div-soup-1024x601.png" alt="div-soup" width="604" height="354" srcset="https://jessewarden.com/wp-content/uploads/2015/09/div-soup-1024x601.png 1024w, https://jessewarden.com/wp-content/uploads/2015/09/div-soup-300x176.png 300w" sizes="auto, (max-width: 604px) 100vw, 604px" /></a></p>
<p>Versus using custom components:</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-11.14.02-AM.png"><img loading="lazy" decoding="async" class="wp-image-4902 size-full alignnone" src="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-11.14.02-AM.png" alt="" width="896" height="308" srcset="https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-11.14.02-AM.png 896w, https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-11.14.02-AM-300x103.png 300w" sizes="auto, (max-width: 896px) 100vw, 896px" /></a></p>
<p>AlthoughÂ Polymer&#8217;s nomenclature is about &#8220;tags&#8221; and &#8220;custom elements&#8221;, what you&#8217;re really doing is creating &#8220;components&#8221;: visual and non-visual.</p>
<h2>Why Even Do This?</h2>
<p>Components, Composition, Encapsulation, and Design.</p>
<h3>Components: It&#8217;s How InterfacesÂ Start</h3>
<p>Once you&#8217;ve got a few applications built under your belt, you start recognizing 2 patterns that emerge every project. You have a visual style guide, whether official or unofficial, that you follow. How buttons look, work, what colorsÂ the button is vs. the text,Â and its shape are all examples of the minutiae.</p>
<p>The other pattern is re-use. This is not just a programming concept related to <a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself">DRY</a>, but a design one as well.Â The rule is you&#8217;re supposed to use the same UI controls for the same user actions so users can more easily use your application. Jakob Nielsen covers that in the &#8220;2. Inconsistency&#8221; section of his <a href="http://www.nngroup.com/articles/top-10-application-design-mistakes/">Top 10 Application Design Mistakes article</a>.</p>
<p>Whether using Angular, React, or Polymer, you&#8217;re going to create 1 button, 1 time, and use it every where in your application a button is needed.</p>
<p>This applies to all user controls. Polymer&#8217;s core concept is building theseÂ components while providing many of which you need out of the box so you don&#8217;t have to create everything from scratch. That said, if you wish to opt-out of Material Design, you can use the core web component libraries it provides to use your own look and feel.</p>
<h3>Composition: It&#8217;s How Interfaces are Made</h3>
<p>Once you have your components built, you then start composing them together into large components that house other components. This is called <a href="https://en.wikipedia.org/wiki/Object_composition">composition</a>, usingÂ something in another thing. You either build more complex components using these pieces together, or build containers. This can be a customized button inside of a calendar control:</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/calendar.png"><img loading="lazy" decoding="async" class="size-full wp-image-4903 alignnone" src="http://jessewarden.com/wp-content/uploads/2015/09/calendar.png" alt="calendar" width="620" height="476" srcset="https://jessewarden.com/wp-content/uploads/2015/09/calendar.png 620w, https://jessewarden.com/wp-content/uploads/2015/09/calendar-300x230.png 300w" sizes="auto, (max-width: 620px) 100vw, 620px" /></a></p>
<p>Which is created by oneÂ HTML tag:</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-2.50.32-PM.png"><img loading="lazy" decoding="async" class="size-full wp-image-4904 alignnone" src="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-2.50.32-PM.png" alt="Screen Shot 2015-09-18 at 2.50.32 PM" width="829" height="59" srcset="https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-2.50.32-PM.png 829w, https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-2.50.32-PM-300x21.png 300w" sizes="auto, (max-width: 829px) 100vw, 829px" /></a></p>
<p>or a button and a text field input inside of a self-contained login form:</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-2.48.15-PM.png"><img loading="lazy" decoding="async" class="size-full wp-image-4905 alignnone" src="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-2.48.15-PM.png" alt="Screen Shot 2015-09-18 at 2.48.15 PM" width="430" height="274" srcset="https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-2.48.15-PM.png 430w, https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-2.48.15-PM-300x191.png 300w" sizes="auto, (max-width: 430px) 100vw, 430px" /></a></p>
<p>Which is also created by one HTML tag:</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.20.19-PM.png"><img loading="lazy" decoding="async" class="size-full wp-image-4914 alignnone" src="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.20.19-PM.png" alt="Screen Shot 2015-09-18 at 3.20.19 PM" width="554" height="105" srcset="https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.20.19-PM.png 554w, https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.20.19-PM-300x57.png 300w" sizes="auto, (max-width: 554px) 100vw, 554px" /></a></p>
<p>Lastly, you&#8217;ll sometimes create containers that house dynamic content and use HTML&#8217;s declarative nature. Polymer&#8217;s &lt;paper-card&gt; is a perfect example. Not only can you house custom content,Â they also gave you 2 areas for it to live, theÂ &#8216;content&#8217; and &#8216;actions&#8217; area for buttons:</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.27.52-PM.png"><img loading="lazy" decoding="async" class="size-full wp-image-4915 alignnone" src="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.27.52-PM.png" alt="Screen Shot 2015-09-18 at 3.27.52 PM" width="320" height="448" srcset="https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.27.52-PM.png 320w, https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.27.52-PM-214x300.png 214w" sizes="auto, (max-width: 320px) 100vw, 320px" /></a></p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.28.12-PM.png"><img loading="lazy" decoding="async" class="size-full wp-image-4916 alignnone" src="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.28.12-PM.png" alt="Screen Shot 2015-09-18 at 3.28.12 PM" width="870" height="247" srcset="https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.28.12-PM.png 870w, https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.28.12-PM-300x85.png 300w" sizes="auto, (max-width: 870px) 100vw, 870px" /></a></p>
<p>Like <a href="https://docs.angularjs.org/api/ng/directive/ngTransclude">Angular&#8217;s ngTransclude</a>, or <a href="http://backbonejs.org/">Backbone</a> <a href="http://marionettejs.com/">Marionette&#8217;s Regions</a>, you simply use a &lt;content&gt;&lt;/content&gt; tag in your component, and that&#8217;s where stuff will go.</p>
<p>The more complex theÂ components and screens, the more composition and containers you&#8217;ll create. Polymer easily enables composition and containers.</p>
<h3>Encapsulation: D0 One Thing Well and Don&#8217;t Tell Anyone How You Do It</h3>
<p>While functional &amp; reactive programming are in, Object Oriented ProgrammingÂ is still how most projectsÂ are primarily done and how most programming is still taught.Â Good OOP is when you create components that have a well understood API and don&#8217;t leak too much detail and state.</p>
<p>Doing that in HTML, JavaScript, and CSS is really hard. HTML&#8217;s DOM API makes your document an open book. Tag ID&#8217;s and class names are effectively global variables, and cannot clash. JavaScript has no module API norÂ built-in ways of privacy without working around how JavaScript works. CSS is SUPPOSED to cascade; that is a core feature of CSS.</p>
<p>Polymer attempts to fixÂ the encapsulation problems the web has.</p>
<h4>HTML</h4>
<p>Shadow DOM enables you toÂ hide DOM from the document. Just like you can&#8217;t open a native &lt;button&gt;, your normal DOM API code won&#8217;t dig into your component.</p>
<h4>CSS</h4>
<p>This is in flux, but similar to HTML, the CSS styles you define in your Shadow DOM only apply to that component. They don&#8217;t leak out and overwrite other styles. Conversely, you effectively have an umbrella from cascading styles so your component&#8217;s styles aren&#8217;t overwritten if they have the same names of something else. You can confidently put your component in any other application and be assured it&#8217;ll look the same.</p>
<h4>JavaScript</h4>
<p>Beyond makingÂ Object.prototype easier to work with, they don&#8217;t do much here since the web component has a lot of otherÂ solutions forÂ this. However, they DO make it easier to import via HTML imports. Whether your code is code or visual code, both can be imported using the same tag.</p>
<p>The workÂ Google has done with Polymer means you only have to do 2 steps to use a component you or someone else has written: import it and use it.</p>
<p>Import:</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.48.51-PM.png"><img loading="lazy" decoding="async" class="size-full wp-image-4917 alignnone" src="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.48.51-PM.png" alt="Screen Shot 2015-09-18 at 3.48.51 PM" width="605" height="58" srcset="https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.48.51-PM.png 605w, https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.48.51-PM-300x29.png 300w" sizes="auto, (max-width: 605px) 100vw, 605px" /></a></p>
<p>And then use it as normal HTML, in the light dom or shadow dom:</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.49.39-PM.png"><img loading="lazy" decoding="async" class="size-full wp-image-4918 alignnone" src="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.49.39-PM.png" alt="Screen Shot 2015-09-18 at 3.49.39 PM" width="654" height="48" srcset="https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.49.39-PM.png 654w, https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.49.39-PM-300x22.png 300w" sizes="auto, (max-width: 654px) 100vw, 654px" /></a></p>
<p>Or via JavaScript:</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.49.53-PM.png"><img loading="lazy" decoding="async" class="size-full wp-image-4919 alignnone" src="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.49.53-PM.png" alt="Screen Shot 2015-09-18 at 3.49.53 PM" width="777" height="63" srcset="https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.49.53-PM.png 777w, https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-3.49.53-PM-300x24.png 300w" sizes="auto, (max-width: 777px) 100vw, 777px" /></a></p>
<p>That is way easier than theÂ copious DevOps, transpilers, and module libraries I and others use today. This is also whyÂ <a href="https://angulardart.org/">Angular Dart</a> years ago went to the <a href="https://github.com/angular/angular.dart/blob/master/example/web/form.dart#L4">component model</a>, and where Angular 2 is going with <a href="http://blog.wolksoftware.com/decorators-metadata-reflection-in-typescript-from-novice-to-expert-part-4?utm_content=buffer0ff0d&amp;utm_medium=social&amp;utm_source=twitter.com&amp;utm_campaign=buffer">class annotation</a>. While functional is in, the basic concepts of modules, package organization, and encapsulation are still valid, good concepts to use and build applications with.</p>
<h3>Design the UI, it Then (Mostly) Builds Itself</h3>
<p>Designing applications is different from designing websites. TheÂ web development world is vast, complex, and there are a variety of approaches. The only consistency I&#8217;ve seen regarding design is that those building applications tend to encapsulate their design into the components they use to build applications whereas the webÂ designers tend to do this from their CSS/LESS/SCSS.</p>
<p>Polymer is clearly on the developers side on this one in that embracing Shadow DOM, I can layoutÂ my component&#8217;s visual pieces, code it to work, and style it all in the same place. Once I distribute it, I don&#8217;t have to worry about style names that make sense, how the CSS is organized, what build task I use to re-compile the LESS, etc.</p>
<p>Instead, you either just code the CSS inline with your component with confidence you aren&#8217;t negatively affecting another component, or you use <a href="http://jessewarden.com/2015/08/sharing-css-between-polymer-components-in-version-1-1-vs-0-5.html">common styles</a> which are a safe, opt-in approach. That way, if you want to share a single style sheet, or support theming, you can do that without breaking encapsulation.</p>
<p>At this point, you help mitigate the biggest problem Web Designers have: Developers.</p>
<p>Most developers I&#8217;ve met say they care about design, but in practice don&#8217;t. This isn&#8217;t malicious, they&#8217;re justÂ focused on their job and that&#8217;s making things work. They&#8217;re held accountable when they don&#8217;t work. If the color or font is wrong? That&#8217;s ok. Doesn&#8217;t compile or show the data correctly from the database? That&#8217;s not ok.</p>
<p>This culture reinforces developers to stay away from design concerns unless they have too since a lot of design changes can&#8217;t easily be unit tested like their code can.</p>
<p>With Polymer, once you hand a developer a component with the padding, fonts, and colors already correct, it&#8217;s pretty hard for them to screw that upÂ unless they dive into the source components. For a Designer, that&#8217;s powerful. For a Developer who hates CSS or loves design but doesn&#8217;t have time for it, it&#8217;s awesome. For a Business Analyst, that&#8217;s less JIRA tickets that pollute the backlog and never get done in time for people to remember what the ticket was referring to.</p>
<p>Additionally, for other designers,Â you can expose components via variables to allow them to break through the Shadow DOM in a clean and well documented manner, yet still abstract the implementation in case you have to refactor the component later.</p>
<p>Components enable designers to ensure the building blocks developers use aren&#8217;t as easily broken, and developers in turn don&#8217;t have to worry as much about &#8220;Crap, I forgot to re-add that CSS class which I can&#8217;t remember it&#8217;s name after I refactored that partial.&#8221;</p>
<h3>So&#8230; Why Again?</h3>
<p>Interfaces for applications are built using components. Polymer makes it easy for you to buildÂ components using JavaScript, HTML, and CSSÂ by keeping them in the same file.</p>
<p>Application interfaces are typically built by composing components withinÂ components to create more complex views and screens. Polymer can use Polymer components inside of Polymer components. You can also create containers to enable this dynamically.</p>
<p>Polymer encapsulates HTML names and ID&#8217;s via Shadow DOM ensuring you don&#8217;t have naming conflicts that break your application without a runtime exception letting you know it break based on some random design change. It also encapsulates your CSS there as well, inverting the control of how CSS works, ensuring the only CSS changes you can make are opt-in, or explicit via easily found keywords like /deep/, or developer created variables.</p>
<p>For Developers, it enables easier encapsulation and adherence to OOP concepts by making it easy to re-use the visual and non-visual components you create.</p>
<p>For Designers, it helpsÂ ensure their CSS isÂ harder to break by developers who don&#8217;t know any better by wrapping them in core building block components the developers don&#8217;t need to go into.</p>
<h2>How Do I Use It?</h2>
<p>I chose the hard way. I suggest you have more fun and choose the easy ways.</p>
<p>First, check out theÂ <a href="https://github.com/yeoman/generator-polymer">Yeoman generator-polymer</a>. It&#8217;ll get you up and running fast, and has a build system already setup for you.</p>
<p>Second, if Yeoman ain&#8217;t yo thing, go straight to the <a href="https://developers.google.com/web/tools/polymer-starter-kit/">Starter Kit</a> (it&#8217;s what the generator helps get started for you).</p>
<p>Third, you can just go straight to the <a href="https://github.com/polymerelements/seed-element">Seed Element</a> to get up and running with something simple and smaller locally to play with.</p>
<p>Fourth, what was most enlightening for me was to build a component using the 0.5 docs &#8220;<a href="https://www.polymer-project.org/0.5/docs/start/tutorial/intro.html">Your First Polymer Application</a>&#8220;. They haven&#8217;t been updated for 1.0, but if you don&#8217;t mind hitting the <a href="https://www.polymer-project.org/1.0/docs/migration.html">migration guide</a>,Â it still gets you 90% of the way there with the core concepts.</p>
<p>Fifth, <a href="https://twitter.com/rob_dodson">Rob Dodson</a> has a great <a href="https://www.youtube.com/playlist?list=PLNYkxOF6rcIDdS7HWIC_BYRunV6MHs5xo">YouTube channel called Polycasts</a> where he goes over building Polymer components and covers everything and builds on earlier content.</p>
<h2>Polymer Gotchas</h2>
<p>Here some of the things that threw me for a loop.</p>
<h3>Events</h3>
<p>When you read the docs for the iron and paper elements, they have properties and method documentation, but NOT events. As someone who builds GUI&#8217;s, this seems like a glaring oversight. To fix it, first, memorize how events work via the <a href="https://www.polymer-project.org/1.0/docs/devguide/utility-functions.html">fire method</a>.</p>
<p>If someone goes:</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-6.17.25-PM.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4926" src="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-6.17.25-PM.png" alt="Screen Shot 2015-09-18 at 6.17.25 PM" width="281" height="63" /></a></p>
<p>Then you knowÂ the event to listen for is &#8216;on-change&#8217;:</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-6.18.23-PM.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4927" src="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-6.18.23-PM.png" alt="Screen Shot 2015-09-18 at 6.18.23 PM" width="815" height="54" srcset="https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-6.18.23-PM.png 815w, https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-6.18.23-PM-300x20.png 300w" sizes="auto, (max-width: 815px) 100vw, 815px" /></a></p>
<p>Every single one of the paper elements links directly to the source code. Dig in there for a &#8220;fire&#8221; method. If you don&#8217;t find it, then see which behaviors it implements (think <a href="https://en.wikipedia.org/wiki/Decorator_pattern">Decorator pattern</a> or multiple inheritance ) and find their source code in the <a href="https://github.com/polymer">Polymer repo</a> via the search function. Otherwise,Â scroll back to the top, and see what components it&#8217;s using. The fire method bubbles by default, so the components its using by composition could be the ones who actually fire the original event.</p>
<p>Remember, fire(&#8216;moo-cow&#8217;) results in a &lt;component on-moo-cow=&#8221;onWubWubWub()&#8221;&gt;&lt;/component&gt;. If you use camelCase instead of dash-case for fire events, you&#8217;ll drive yourself nuts when things don&#8217;t work.</p>
<h3></h3>
<h3>animationConfig Placement</h3>
<p>I lost 2 days trying to get animations to work because both times I put it outside of the properties object. It&#8217;s supposed to <a href="https://www.youtube.com/watch?v=Lwvi1u4XXzc">go inside</a>. If you think I&#8217;m not a moron, <a href="https://github.com/PolymerElements/neon-animation/pull/73">please +1 this PR</a>.</p>
<h3>Non-Visual Components</h3>
<p>Once you start getting knee deep in building visual Polymer components for a few days, you forget that you could build non-visual ones as well. Since you can onlyÂ use inheritance on native controls, most of your code will be composition: enhancing existing tags.</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-6.29.13-PM.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4928" src="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-6.29.13-PM.png" alt="Screen Shot 2015-09-18 at 6.29.13 PM" width="920" height="1128" srcset="https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-6.29.13-PM.png 920w, https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-6.29.13-PM-245x300.png 245w, https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-6.29.13-PM-835x1024.png 835w" sizes="auto, (max-width: 920px) 100vw, 920px" /></a></p>
<h3>Core Things Nobody Tells You About</h3>
<p>If you&#8217;ve been building applications on the front end for awhile, you start to have some expectations on where the basic things are. Here they are.</p>
<h4>Ajax/XHR/HTTP Requests</h4>
<p>Use <a href="https://elements.polymer-project.org/elements/iron-ajax">iron-ajax</a>.</p>
<h4>Making selectable lists</h4>
<p>Use <a href="https://elements.polymer-project.org/elements/iron-selector">iron-selector</a>.</p>
<h4>Pub Sub</h4>
<p>If you miss your <a href="http://backbonejs.org/#Events-trigger">_.trigger</a> or <a href="https://docs.angularjs.org/api/ng/type/$rootScope.Scope">$rootScope.$broadcast</a>Â then use <a href="https://elements.polymer-project.org/elements/iron-signals">iron-signals</a>.</p>
<h4>Basic CSS Layout</h4>
<p>Read the source for <a href="https://github.com/PolymerElements/iron-flex-layout/blob/master/iron-flex-layout.html">iron-flex-layout</a>, and remove the dashes in your head. This allows you to do <a href="https://elements.polymer-project.org/guides/flex-layout">everything you could in 0.5</a>, except usingÂ the class attribute.</p>
<p>This:</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-6.41.44-PM.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4929" src="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-6.41.44-PM.png" alt="Screen Shot 2015-09-18 at 6.41.44 PM" width="435" height="116" srcset="https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-6.41.44-PM.png 435w, https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-6.41.44-PM-300x80.png 300w" sizes="auto, (max-width: 435px) 100vw, 435px" /></a></p>
<p>Becomes this:</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-6.41.48-PM.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4930" src="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-6.41.48-PM.png" alt="Screen Shot 2015-09-18 at 6.41.48 PM" width="442" height="112" srcset="https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-6.41.48-PM.png 442w, https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-6.41.48-PM-300x76.png 300w" sizes="auto, (max-width: 442px) 100vw, 442px" /></a></p>
<h4>ResponsiveÂ Layouts / Media Queries</h4>
<p>When you&#8217;re buildingÂ components or screens that have 2 layouts, you use the <a href="https://elements.polymer-project.org/elements/iron-media-query">iron-media-query</a> inline. IfÂ you start duplicating markup for each media query, justÂ refactor it to a component.</p>
<h4>Icons</h4>
<p>There&#8217;s like 5 icon classes&#8230; ignore them. Just install <a href="https://github.com/PolymerElements/iron-icons">iron-icons</a>, then import the ones you need or all of them. To see which ones are available, navigate to the bower_components/iron-icons/demo/ folder on your local web server to see which ones you can use.</p>
<p>ALL of the icons use the same naming structure: &#8220;category:name&#8221;, whether an <a href="https://elements.polymer-project.org/elements/iron-icon">iron-icon</a> or a <a href="https://elements.polymer-project.org/elements/paper-icon-button">paper-icon-button</a>. So if you see the icon attribute, that&#8217;s what the icon name really means.</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-7.12.19-PM.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4932" src="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-7.12.19-PM.png" alt="Screen Shot 2015-09-18 at 7.12.19 PM" width="642" height="136" srcset="https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-7.12.19-PM.png 642w, https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-7.12.19-PM-300x64.png 300w" sizes="auto, (max-width: 642px) 100vw, 642px" /></a></p>
<h4>Infinite Scrolling List</h4>
<p>&#8230; ah, the question you wish C# developers would ask you on interviews vs. red/black tree sorting&#8230; *ahem* If you need one, use <a href="https://elements.polymer-project.org/elements/iron-list">iron-list</a>.</p>
<h4>Images</h4>
<p>They have a really cool uber-image component called <a href="https://elements.polymer-project.org/elements/iron-image">iron-image</a>. Way better than img tags.</p>
<h4>localStorage</h4>
<p>They have a nice wrapper around localStorage called <a href="https://elements.polymer-project.org/elements/iron-localstorage">iron-localstorage</a> that would of saved me a lot of time. Basically allows you to use Polymer&#8217;s built-in data-binding with localStorage.</p>
<h2>Routing</h2>
<p>Polymer doesn&#8217;t ship with a router. They did in 0.5, but in 1.x they assume you&#8217;ll use a router that&#8217;s right for you. There are a few Polymer specific ones on Github and <a href="https://customelements.io/">CustomElements.io</a>.</p>
<p>I tried a few, but none work with the way I work with Mediator View&#8217;s doing most of the heavy lifting. Some weren&#8217;t declarative enough or didn&#8217;t support custom &lt;templates&gt;. Worse, the majority only supported 0.5, not 1.x.</p>
<p>I attempted to wrap Angular&#8217;s <a href="https://github.com/angular-ui/ui-router">UI-Router</a> in a component, but got frustrated pretty quickly with the inability to easily have them talk to each other so just went with <a href="https://visionmedia.github.io/page.js/">page.js</a>.Â  It works quite well.</p>
<h2>Scope</h2>
<p>Polymer focuses on HTML and CSS betterment, not JavaScript. As such, all the same problems with scope exist in Polymer script tags since it&#8217;s basic JavaScript. Everywhere you put &#8220;var me = this&#8221;. If you&#8217;re not going to use a framework, I recommendÂ <a href="https://lodash.com/docs#bindAll">Lodash&#8217; bindAll</a>.</p>
<h2>DevOps</h2>
<h3>Code Quality</h3>
<p>The <a href="http://jshint.com/">jshint</a> works in <a href="http://gruntjs.com/">Grunt</a> and <a href="http://gulpjs.com/">Gulp</a>, but I couldn&#8217;t get <a href="http://jscs.info/">jscs</a> to work unless you externalize your script files and ignore the Polymer html files.</p>
<h3>Injector and Wiredep</h3>
<p>As your project grows, you&#8217;ll need some type of module system. The nice thing about Polymer is that it handles load order for you; as long as you have all your imports there, it doesn&#8217;t matter what order they are in. However,Â <a href="https://github.com/polymer/vulcanize">Vulcanize</a>, the build tool for Polymer, doesn&#8217;t always work with 3rd party libraries.Â I use Injector (<a href="https://www.npmjs.com/package/grunt-injector">grunt</a> / <a href="https://www.npmjs.com/package/gulp-inject">gulp</a> ) which now embeds <a href="https://github.com/taptapship/wiredep">Wiredep</a>Â so it automatically puts script tags for all your <a href="https://www.npmjs.com/">npm</a> and <a href="http://bower.io/">bower</a> classes.</p>
<p>I found running these first, then running Vulcanize afterwards excluding the build path classes in the ignorePath option seemed to work. I didn&#8217;t attempt minifiy/uglify the Polymer specific scripts as they weren&#8217;t externalized. I find while developing it&#8217;s easier to target the DOM I&#8217;m working with if it&#8217;s in the same file and I scroll up. It&#8217;d be nice to find a build way to automatically externalize the JavaScript and the CSS.</p>
<p>Also, I couldn&#8217;t get either of the Grunt or Gulp Vulcanize plugins to play nice with my build structure paths so just wrote <a href="https://github.com/JesterXL/Starting-Strength-Polymer/blob/master/Gruntfile.js#L120">raw JavaScript</a> for it and it worked.</p>
<h3>Unit Tests</h3>
<p>I couldn&#8217;t get the <a href="https://github.com/Polymer/web-component-tester">web components tester</a> to work. After spending hours in Grunt fighting with various missing paths, I gave up.Â I reckon if I had used the Yeoman generator, it&#8217;d work.Â I did get the sample seed-element project&#8217;s tests working though.</p>
<h2>What About <a href="http://www.x-tags.org/">X-Tags</a>?</h2>
<p>&nbsp;</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/girl-shrugging.jpg"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4934" src="http://jessewarden.com/wp-content/uploads/2015/09/girl-shrugging.jpg" alt=":: shrugs ::" width="600" height="495" srcset="https://jessewarden.com/wp-content/uploads/2015/09/girl-shrugging.jpg 600w, https://jessewarden.com/wp-content/uploads/2015/09/girl-shrugging-300x248.jpg 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></a></p>
<h2>Why Would I Use Polymer vs. Something Like Bootstrap or Foundation?</h2>
<p>Polymer is part component framework, but it&#8217;s also a way to use the newest stuff, now, and help give Google feedback on direction. Since last year, Polymer has been the &#8220;living prototype&#8221; of the web components standards and has changed as both people have used it, the ideas Google has had to improve upon it, and the standards committeeÂ has started standardizing on the implementations.</p>
<p>Unlike Bootstrap/<a href="http://foundation.zurb.com/">Foundation</a>, you&#8217;re building real web components, not divs with decoration.</p>
<p>A lot of the value that Polymer provides is that it implements Google&#8217;s Material Design. If you don&#8217;t want that look and feel, you can still use most of the <a href="https://elements.polymer-project.org/browse?package=iron-elements">iron</a> and <a href="https://elements.polymer-project.org/browse?package=neon-elements">neon</a> animation elements and just stay away from paper.</p>
<p>For those of us in enterprise development building large applications, Bootstrap reigns supreme, mainly because it has all the components we need, now. Contrast that with Polymer, I had to build a <a href="https://github.com/JesterXL/jxl-paper-date-picker">Calendar / Date Picker</a>Â since most of the ones I found were 0.5 only. I then found another v1 the next day. The community DOES build a lot on Github, but quality does vary, and it&#8217;s not a single project like Bootstrap&#8217;s is.</p>
<p>Bottom line, Bootstrap just has more of everything you need, both in design, typography, components, and layout.</p>
<h2>Could I Use Polymer With Angular, Backbone, or React?</h2>
<p>If you&#8217;re going to use it with Angular, try <a href="https://material.angularjs.org/latest/#/">Angular Material</a> first. You&#8217;re basically marrying yourself to Material Design&#8217;s look and feel, but most clients I know would be mostly ok with that.</p>
<p>If you want to do it yourself, I don&#8217;t recommend it. Angular 1.0 doesn&#8217;t yet play well with Shadow DOM, whereas Angular 2 is getting there. You get <a href="https://github.com/webcomponents/webcomponentsjs/issues/396">weird bugs</a> unless you do it <a href="https://gist.github.com/JesterXL/bf8156a61df7704c4e4a">just right</a>&#8230; which doesn&#8217;t really feel right. If you do forge ahead, you&#8217;ll enjoy that most of your Angular directives can merely have this as their template:</p>
<p><a href="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-9.01.08-PM.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4935" src="http://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-9.01.08-PM.png" alt="Screen Shot 2015-09-18 at 9.01.08 PM" width="588" height="43" srcset="https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-9.01.08-PM.png 588w, https://jessewarden.com/wp-content/uploads/2015/09/Screen-Shot-2015-09-18-at-9.01.08-PM-300x22.png 300w" sizes="auto, (max-width: 588px) 100vw, 588px" /></a></p>
<p>Notice it&#8217;s template, not templateUrl, which means this is a nice way to give your Polymer components Controllers&#8230; sort of. While the methods work, binding and events were hard to figure out if they were working or not.</p>
<p>For <a href="http://backbonejs.org/">Backbone</a>, things are murky. The Backbone View is basically your Polymer component&#8217;s JavaScript, and the &lt;template&gt;&lt;/template&gt; tag contentsÂ is the Handlebars template. Polymer already has a pub sub library, so there is no need for Backbone Events. While in theory Backbone Views could make good Controller classes, it&#8217;d be easier to just do this yourself listening for attached/detached events from your components, a la <a href="http://www.adobe.com/devnet/actionscript/articles/intro-robotlegs-pt1.html">Robotlegs Context</a>.</p>
<p>I haven&#8217;t tried this myself, but I know of one big bank that was investigating this approach last year mainly because they still have a lot of JSP and portals where full applications cannot be built, so instead they share mini-applications. Polymer seems a great fit for this.</p>
<p>After having some experience using their composition strategy, both Angular and Backbone are way harder to integrate with than I originally thought since once you&#8217;re out of the Polymer realm, things get harder to work with. Binding doesn&#8217;t work, so you have to get/set things. Events aren&#8217;t data bound, so you have to use addEventListener. Things like that. It&#8217;s just easier to live and work in the Polymer realm, and take the same approach you do in Backbone architecture: add as you need <a href="https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it">YAGNI</a> style.</p>
<p>More investigation is needed as I might of missed some things or did outside world integration wrong.</p>
<p><a href="https://facebook.github.io/react/">React</a> makes no sense with Polymer. They bothÂ are trying to solve the same thing: faster and easier DOM. React <a href="http://calendar.perfplanet.com/2013/diff/">claims</a> that <a href="http://blog.500tech.com/is-reactjs-fast/">it&#8217;s fast</a>, whereas a lot of the Polymer justification of the &lt;template&gt; tag and Shadow DOM is performance.Â I don&#8217;t know who&#8217;s right, but both build reusable components, have data binding, have a nice component lifecycle, make the DOM easier to work with, and have no implied MVCÂ architecture on top. It&#8217;d be easier to use React within Polymer I think, but again, I don&#8217;t see the point unless you believe the speed benefits could help in the Shadow DOM realm.</p>
<h2>Conclusions</h2>
<p>Polymer&#8217;s great. I like the v1.1 release a lot. Using components feels natural, and is how I builtÂ applications from my Director, Flash, Silverlight, and Flex days. While I hate CSS, I enjoy that Flexbox mostly works, and much of Material Design is already implemented for me. I like the iron and paper components I have out the box.</p>
<p>I&#8217;m disappointed it&#8217;s not as many as Bootstrap. I also miss all of theÂ Angular features I&#8217;ve become accustomed to, mainly ui-router, Controllers, and dependency injection for easier unit testing. Jury&#8217;s out on DevOps. I also miss the 0.5 docs; I&#8217;m guessing the plethora of standards changes at Google is just really fast and maybe their short on documentation resources, or don&#8217;t have an easy way for open source to contribute on that front.</p>
<p>If IÂ had aÂ smaller gig where I wasn&#8217;t building a large, year longÂ application with 20+ developers, AND I could justify the time building the missing Bootstrap components/css if any,Â I&#8217;d definitely choose Polymer. As someone who was forced to the web, it&#8217;s certainly made it a lot more fun to work with.</p>
<p>If you&#8217;d like to learn more, I&#8217;veÂ got <a href="https://github.com/JesterXL/jxl-paper-date-picker">a calendar component</a> I built and a <a href="https://github.com/JesterXL/Starting-Strength-Polymer">Polymer, Node, and MongoÂ reference applications</a> as well.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Sharing CSS Between Polymer Components in Version 1.1 vs 0.5</title>
		<link>https://jessewarden.com/2015/08/sharing-css-between-polymer-components-in-version-1-1-vs-0-5.html</link>
		
		<dc:creator><![CDATA[JesterXL]]></dc:creator>
		<pubDate>Sat, 15 Aug 2015 14:12:17 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[angular]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[dart]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[polymer]]></category>
		<category><![CDATA[styling]]></category>
		<guid isPermaLink="false">http://jessewarden.com/?p=4887</guid>

					<description><![CDATA[Finally figured out how to share styles between components in Polymer. In version 0.5 it was &#60;core-style&#62; and in 1.1, they&#8217;ve changed it use shared styles which is pretty easy to grok for someone who sucks at CSS like me. Sadly, the 1.0 docs for Polymer are quite awful. Even more frustrating is most of [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Finally figured out how to <a href="https://blog.polymer-project.org/announcements/2015/08/13/1.1-release/">share styles between components in Polymer</a>. In version 0.5 it was &lt;core-style&gt; and in 1.1, they&#8217;ve changed it use shared styles which is pretty easy to grok for someone who sucks at CSS like me.</p>
<p><span id="more-4887"></span>Sadly, the 1.0 docs for <a href="https://www.polymer-project.org/1.0/docs/start/getting-the-code.html">Polymer</a> are quite awful. Even more frustrating is most of the Google links still point to v0.5 content, including Github repos that don&#8217;t all point to the newer repos. For example, go figure out how to know how to programmatically listen when a <a href="https://elements.polymer-project.org/elements/paper-radio-group">&lt;paper-radio-group&gt;</a> has changed a selected item by the user clicking it&#8230; ready, go. Oh look, you found misery! I reckon this is because they are still trying to keep ahead all of the Web vendor API changes, general code optimizations, and just resource issues. Not sure the size of the Polymer team. On a whim this morning I checked their blog and finally found what I was looking for since I gave up on the documentation (which was quite great in 0.5).</p>
<p>While I primarily work in raw JavaScript all day and sometimes <a href="https://angularjs.org/">Angular</a>, after messing with Polymer for about 2 weeks now, I really really don&#8217;t get the allure of <a href="http://facebook.github.io/react/">React</a>. When I was messing with Angular 2 months ago in <a href="https://www.dartlang.org/">Dart</a> using the new component syntax, it was immediately apparent how quickly you could build UI&#8217;s. It felt like <a href="http://www.adobe.com/products/flex.html">Flex</a>. Just focusing strictly on the UI, not caring about models and controllers and blah blah blah MVC whatever. Just git-r-done.</p>
<p>Polymer feels the same way; I never messed with the Dart version so just doing the JavaScript version, but even so, it&#8217;s a ton like Angular 1.0, just less&#8230; weird. That, and you can include styles WITH your component vs. &#8220;Uh&#8230; Bootstrap will&#8230; like&#8230; handle that somehow. I don&#8217;t know man, go ask the designer, I&#8217;m just the coder.&#8221;</p>
<p>Took me a few weeks to get re-acclimated to <a href="https://www.google.com/design/spec/material-design/introduction.html">Material Design</a>. <a href="http://getbootstrap.com/">Bootstrap</a> provides you with SO many components including general typography out of the box that work quite quickly, whereas Material Design, or even if you start with <a href="http://www.getmdl.io/">Material Design Lite</a>, there&#8217;s still a ton of onus on you to have SOME designer chops, or have a designer as a friend that can help you.</p>
<p>Anyway, glad to know now how to make my CSS styles follow DRY principles.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Backbone.js for Flash and Flex Developers</title>
		<link>https://jessewarden.com/2012/08/backbone-js-for-flash-and-flex-developers.html</link>
					<comments>https://jessewarden.com/2012/08/backbone-js-for-flash-and-flex-developers.html#comments</comments>
		
		<dc:creator><![CDATA[JesterXL]]></dc:creator>
		<pubDate>Tue, 07 Aug 2012 16:42:47 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[backbone]]></category>
		<category><![CDATA[cairngorm]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[dependencyinjection]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[parsley]]></category>
		<category><![CDATA[require]]></category>
		<category><![CDATA[robotlegs]]></category>
		<category><![CDATA[swiz]]></category>
		<category><![CDATA[underscore]]></category>
		<category><![CDATA[wire]]></category>
		<guid isPermaLink="false">http://jessewarden.com/?p=3268</guid>

					<description><![CDATA[Introduction The JavaScript web development community has a significant amount of application development frameworks, specifically around creating scalable applications using MVC/MVP/MVVM/MVPM/MVPV/MVSC, etc. Flash &#38; Flex have the same, although not as many, nor as many library dependencies. Backbone in particular has some longevity amongst the many frameworks available and has been used in some high [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a href="http://jessewarden.com/2012/08/backbone-js-for-flash-and-flex-developers.html"><img loading="lazy" decoding="async" style="padding-right: 8px; padding-bottom: 8px;" src="http://jessewarden.com/archives/blogentryimages/backboneforas/backbone-for-as-logo.png" alt="" width="320" height="247" align="left" /></a></p>
<h3 style="clear: none;">Introduction</h3>
<p>The JavaScript web development community has a significant amount of application development frameworks, specifically around creating scalable applications using <a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">MVC</a>/<a href="http://martinfowler.com/eaaDev/ModelViewPresenter.html">MVP</a>/<a href="http://en.wikipedia.org/wiki/Model_View_ViewModel">MVVM</a>/<a href="http://martinfowler.com/eaaDev/PresentationModel.html">MVPM</a>/<a href="http://martinfowler.com/eaaDev/PassiveScreen.html">MVPV</a>/<a href="http://martinfowler.com/eaaDev/SupervisingPresenter.html">MVSC</a>, etc. <a href="http://www.adobe.com/products/flash">Flash</a> &amp; <a href="http://www.adobe.com/products/flex">Flex</a> have the same, although not as many, nor as many library dependencies.</p>
<p>Backbone in particular has some longevity amongst the many frameworks available and has been used in some high profile applications (notably <a href="http://pivotaltracker.com">Pivotal Tracker</a>). Since I&#8217;ve recently been fixing a web application project with a varied history, I&#8217;m diving head first into Backbone, and taking a break from diving into <a href="http://angularjs.org/">Angular</a>.</p>
<p>In this article, I&#8217;ll go over what Backbone is, how its features compare to frameworks Flash &amp; Flex Developers are used to, and some implementation details that will help you compare how JavaScript MVC apps compare to Flash and Flex ones.</p>
<p><span id="more-3268"></span>Also, while I&#8217;ll have a lot of future articles on web development, rather than reading 20 billion novels, if you&#8217;re just looking to get immersed in as much web dev as possible to get a 30,000ft view of where things stand, this is a better post to read even if dated. I&#8217;m still learning the web stack, so I&#8217;ll update this post with any inaccuracies pointed out. Just comment or send me an email/tweet.</p>
<h3>What Is Backbone?</h3>
<p>Backbone is basically an MVC framework for writing JavaScript web applications. If you&#8217;ve ever messed with <a href="http://en.wikipedia.org/wiki/Cairngorm_(Flex_framework)">Cairngorm</a>, <a href="http://puremvc.org/">PureMVC</a>, <a href="http://www.robotlegs.org/">Robotlegs</a>, <a href="http://swizframework.org/">Swiz</a>, or <a href="http://www.spicefactory.org/parsley/">Parsley</a>, you&#8217;ll instantly see a lot you recognize. Like a lot of JavaScript MVC frameworks, it is a collection of JavaScript libraries.</p>
<p>Also, it like others has the intentional ability to easily integrate with other toolsets and libraries.Â Examples include UI component frameworks like <a href="http://jquery.com/">jQuery</a> or <a href="http://www.sencha.com/products/touch/">Sencha Touch</a>, HTML template engines like <a href="http://handlebarsjs.com/">Handlebars</a>, and it assumes you&#8217;ll either hand code your CSS or use something like <a href="http://sass-lang.com/">SASS</a>/<a href="http://lesscss.org/">LESS</a> if you need to make your CSS more manageable on larger projects.</p>
<p>While Cairngorm and PureMVC were self contained, Robotlegs depended on <a href="https://github.com/tschneidereit/SwiftSuspenders/">SwiftSuspenders</a> for the <a href="http://martinfowler.com/articles/injection.html">Dependency Injection</a> functionality&#8230; however it is known that you just used Robotlegs without really caring, nor knowing buried in the robotlegs.swc file, there was a Swift Suspenders dependency.</p>
<p>Dependency management is tons harder in JavaScript, but I&#8217;ll briefly cover that plus more on Underscore in a bit. The same holds true for Backbone. It utilizes a library called <a href="http://underscorejs.org/">Underscore</a> to basically fix JavaScript to a certain standard of usability, add many OOP and Array features functional server-side devs love, and to abstract away the browserÂ incompatibilitiesÂ for the 1st and 2nd.</p>
<p>It also utilizes Douglas Crockford&#8217;s <a href="https://github.com/douglascrockford/JSON-js">json.js</a>, the man behind the book &#8220;<a href="http://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742">JavaScript: The Good Parts</a>&#8221; and a promoter of using <a href="https://www.google.com/#hl=en&amp;safe=off&amp;sclient=psy-ab&amp;q=closure+vs+prototype&amp;oq=closure+vs+prototype&amp;gs_l=hp.3..0j0i5j0i5i30j0i8i30.3434.5654.2.5772.20.15.0.2.2.0.134.1355.7j7.14.0...0.0...1c.JHUmsVPluXQ&amp;pbx=1&amp;bav=on.2,or.r_gc.r_pw.r_cp.r_qf.,cf.osb&amp;fp=89dccf89cf1c3a70&amp;biw=1052&amp;bih=723">closure based OOP vs. Object.prototype.</a>Â His json library does the same, allowing the JSON format to workÂ seamlesslyÂ in JavaScript regardless of browser; for older browsers it parses, for newer ones it uses the built in parser. You should be using json2 since it doesn&#8217;t mess with the prototype (omg, purism). You&#8217;ll notice, too, just about every article on JavaScript nowadays assumes this part is &#8220;handled&#8221;; you&#8217;ll see a magic &#8220;JSON&#8221; in the code. It&#8217;s implied it comes form this library, is native, or both. In a development environment, you just include all the libraries mentioned at the bottom if your index.html body tag (so all the GUI and CSS dependencies load first) in script tags.</p>
<h3>Why Backbone?</h3>
<p>If you&#8217;re a Flex Developer, you already know why: it&#8217;s an MVC framework. Sold. Feel free to <a href="#backboneevents">skip this section</a> or just skim 4 &amp; 5.</p>
<p>I was thinking of deleting this section, but then read Smashing Magazine&#8217;s <a href="http://coding.smashingmagazine.com/2012/07/27/journey-through-the-javascript-mvc-jungle/">Journey Through The JavaScript MVC Jungle</a>, and decided more details were needed for those who are questioning why they even need an MVC framework.</p>
<p>For those that don&#8217;t, MVC frameworks helpÂ separateÂ out your visual, data, application, and business logic in distinct areas in your code. This allows you to have multiple developers work on the code, the code to more easily scale for larger applications, and to make it more testable. Putting logic in your DOM, aka your JavaScript mashed into your HTML and CSS on a &#8220;page&#8221;, makes things unmaintable, hard to find bugs, and unreadable. &#8230;for larger applications. Just like Flash, there is fine line that&#8217;s blurred as all get out. Whether you use an MVC framework or not depends on:</p>
<ol>
<li>your business</li>
<li>your team</li>
<li>size of your application</li>
<li>multi-device</li>
<li>server-side vs. client side</li>
<li>website vs. app</li>
</ol>
<p><strong>Your Business</strong></p>
<p><strong></strong>For those who have non-negotiable deadlines, any OOP, design patterns, and frameworks usually get in the way. Paying off technical debt never happens much, so spit and duct tape applications are fine. On the other hand if your business is creating code that will have to live for years and/or is a product for consumers or other businesses, using OOP, design patterns, and a framework is a good idea. Usually. Sometimes you need to just launch and get funding. Also, there is always the risk that a &#8220;Prototype&#8221; suddenly becomes &#8220;The Product&#8221;. Starting out with even a few parts in a framework will prevent a lot of pain down the line.</p>
<p><strong>Your Team</strong></p>
<p><strong></strong>If you&#8217;re a 1 woman show, and management has done the estimates to show that all design, development, testing, and bug fixing can be done just by you, great; architect as you see fit.</p>
<p>However, if you&#8217;re on a team environment because your project is of the size that can in fact utilizeÂ multipleÂ designers and developers to create value in tandem, an MVC framework can allow your team to work with each other, in different files, being productive using modern source control systems. Additionally, Backbone like many frameworks has enough industry traction that documentation &amp; answers to common questions/problems are all online. This makes hiring &amp; training both new &amp; existing team resources much cheaper and faster. The code has SOME semblance of structure, even if the original developer(s) didn&#8217;t follow Backbone conventions to a T.</p>
<p><strong>Application Size/Scope</strong></p>
<p><strong></strong>If you&#8217;re application is just a few screens/pages/widgets, use jQuery, shove you&#8217;re services and data into a dozen files and call it a day. You could still even write it where your service and application logic layer was testable to get unit tests, all without the need of a framework. I&#8217;ve seen a lot of Flash Developers take to this route just fine over the past year for both desktop and mobile. Some even threw everything on the sever and just did HTML/CSS on the client.</p>
<p>If, however, you&#8217;re creating a large application with many screens, a lot of client side logic/data caching, and maybe even iterating on a design, then separating things out cleanly via Backbone, or some other framework, is the way to go. Again, this assumes you&#8217;re not using the server for much beyond services. This&#8217;ll ensure when you create new functionality, you know where it goes. WhenÂ revisitingÂ already created functionality, you know where to look for what.</p>
<p><strong>Multi Device</strong></p>
<p><strong></strong>One thing that isn&#8217;t mentioned much is MVC frameworks can help with mutli-device strategies. People attribute that to HTML5 and make the assumption you&#8217;re coding things in a DRY manner and they can be easily reused. Taking your application logic, data/validation, and services OUT of the presentation layer (what the user see&#8217;s) allows you to test &amp; scale each in isolation.</p>
<p>What usually doesn&#8217;t change is you need all/most/some of the same exact code on a phone as you do the tablet and desktop. While the GUI can change, whether a different HTML and CSS template used for different screen sizes, your core application &amp; business logic does not. BackboneÂ especiallyÂ with it&#8217;s use of the PassiveView pattern makes it (mostly) easy to change the underlying html or templates you&#8217;re using. Even if that code isn&#8217;t DRY because of a hard deadline or a challenging design, all your models and services stay the same helping to somewhat mitigate the problem. There are a variety of responsive design techniques you can use to not really change anything.</p>
<p><strong>Server-Side vs. Client Side</strong></p>
<p><strong></strong>This one is easy. If you&#8217;re development shopÂ primarilyÂ does their websites and/or applications server-side, there are a lot of wonderful frameworks out there that are already &#8220;Backbone on the Server&#8221; as it were. Additionally, they have the library support just like JavaScript does to fill in the gaps.Â These include Ruby on Rails, Django for Python, Java&#8217;s Play Framework or GWT, and good ole&#8217; .NET.</p>
<p>In these instances, 90% of the code and design is done on the server, and a tincy bit of client side code or design is done. In these cases, you don&#8217;t need Backbone because you&#8217;re already doing MVC on the server and treating the entire client as the View. The criticism by some is that, even with delivery or raw HTML/CSS/JS that&#8217;s minified and gzipped by the server, you still utilize a lot more bandwidth and http requests onÂ theÂ client. This is not what you want to be doing with mobile. There are a variety of frameworks and design strategies to mitigate this, though.</p>
<p>If you don&#8217;t do server-side development, then you need something. There is a reason Rails, Django, Play, .NET, GTW, etc. all utilize some form of MVC.</p>
<p><strong>Website vs. Application</strong></p>
<p><strong></strong>Finally, what exactly are you building? To me, even though I&#8217;m still learning JavaScript/HTML/CSS stack, theÂ delineationÂ is pretty clear to me. Why anyone can argue, and be correct, that the same Backbone application with large amount of JavaScript and a complicated build process could be made using simple HTML/CSS, and a tincy bit of jQuery&#8230; I just use the first 5 items to make the decision.</p>
<p>If you have a bunch of web designers on your team, they&#8217;re more apt to inherit something and be successful maintaing it if it&#8217;s in a context they&#8217;re used to. Conversely, if you have a lot of software client developers, they&#8217;ll be more apt to maintain something doneÂ primarilyÂ in code.</p>
<p>If they&#8217;re server-side devs, they&#8217;ll typically have larger expectations of a technology stack even compared to client side developers&#8230; hence rather developing on the server instead.</p>
<p>Bottom line, if you&#8217;re just building a website with some progressively enhanced interactivity, you don&#8217;t need a framework. If you&#8217;re doing a lot of service calls, have &#8220;state&#8221; on the client, and have a lot of user interaction &amp; things they need to input, you&#8217;re probably building an application and probably should use a framework.<br />
<a name="backboneevents"></a></p>
<h3>Events</h3>
<p>Many frameworks have a messaging system that&#8217;s independent of the stack it&#8217;s on. This is also sometimes called the &#8220;event bus&#8221;. Cairngorm has CairngormEventDispatcher on top of Flash Player Events. PureMVC has Notifications. Robotlegs injects a special base class with a unique EventDispatcher instance. Backbone, much like ActionScript 2&#8217;s <a href="http://www.adobe.com/support/documentation/en/flex/1/asdocs/mx/events/EventDispatcher.html">EventDispatcher</a>Â or <a href="http://help.adobe.com/en_US/flashlite/dev/2x3x/WS006f4c657bd0baee1e63e3d11cddf884e3-7ffb.html">ASBroadcaster</a> in ActionScript 1, uses the <a href="http://en.wikipedia.org/wiki/Decorator_pattern">Decorator pattern</a>Â to add event listening and broadcasting to any JavaScript object. It relies on the Underscore library to do this. Underscore does in fact use the _ as it&#8217;s class name. Yes, there are basic ECMA level event dispatching capabilities in JavaScript, but they don&#8217;t have good cross browser support, and are harder to modify. AS1:</p>
<pre lang="actionscript">var obj = {};
var listener = {};
ASBroadcaster.initialize(obj);
obj.addEventListener(listener);
listener.alert = function()
{
	trace("Alert!");	
};
obj.broadcastMessage("alert", "Sup.");</pre>
<p>AS2:</p>
<pre lang="actionscript">import mx.events.EventDispatcher;
import mx.utils.Delegate;
var obj = {};
var listener = {};
EventDispatcher.initialize(obj);
obj.addEventListener("alert", Delegate.create(listener, onAlert));
listener.onAlert = function(event)
{
	trace("Alert!");	
};
obj.dispatchEvent({type:"alert", target: obj});</pre>
<p>AS3:</p>
<pre lang="actionscript3">import flash.events.EventDispatcher;
import flash.events.Event;

var dispatcher:EventDispatcher = new EventDispatcher();
var listener:Object = {};
listener.alert = function(event:Event):void
{
	trace("Alert!");	
};
listener.addEventListener("alert", listener.alert);
dispatcher.dispatchEvent(new Event("alert"));</pre>
<p>Backbone via Underscore:</p>
<pre lang="javascript">var object = {};

_.extend(object, Backbone.Events);

object.on("alert", function(msg) {
  alert("Triggered " + msg);
});

object.trigger("alert", "an event");</pre>
<p>Notice this uses a callback as an anonymous function. If you&#8217;d prefer a proper function attached to a class or a closure or some other object, you can do that too.</p>
<p>In ActionScript 3, if your events grow, you start utilizing packages to organize Event classes to their domain of interest.</p>
<p><img loading="lazy" decoding="async" src="http://jessewarden.com/archives/blogentryimages/backboneforas/package-events.png" alt="" width="309" height="248" /></p>
<p>In Backbone, they want you to utilize namespaces (a colon toÂ separateÂ noun:verb) to delineate them.</p>
<pre lang="javascript">myCollection.trigger("selection:changed", myIndex);
socketWatcher.trigger("user:join", userModel);</pre>
<p>While JavaScript doesn&#8217;t support constants, many IDE&#8217;s can infer them through code hinting / intellisense like <a href="http://www.jetbrains.com/idea/">IntelliJ/Webstorm</a>, <a href="http://www.sublimetext.com/">Sublime</a>, and <a href="http://www.aptana.com/">Aptana</a>. Although magic strings don&#8217;t go away in JavaScript, this is how you can mitigate the growth, make them easier to test, and prevent misspelling bugs.</p>
<p>You can also trigger many events in 1 call by adding a space.</p>
<pre lang="javascript">book.on("change:title change:author", someCallbackFunction);</pre>
<p>Since JavaScript has the same stupid scope challenges that ActionScript 1/pre-Delegate, you can optionally provide a scope (called a context) as the 3rd parameter.</p>
<pre lang="javascript">model.on('change', this.render, this)</pre>
<p>Unlike ActionScript, the Underscore event system allows you to hear about all events via &#8220;all&#8221; which is basically a reserved word/event name.</p>
<pre lang="javascript">var logger = {};
logger.on("all", function(eventName)
{
	console.log("Event: " + eventName);
});</pre>
<p>Notice here I&#8217;m using console which is basically JavaScript&#8217;s trace. This breaks IE. Don&#8217;t do it. Use <a href="http://log4javascript.org/">log4javascript</a> unless you&#8217;re a WebKit Only Kid.</p>
<p>To remove events, in Flash you just use removeEventListener:</p>
<pre lang="actionscript3">myListener.removeEventListener("alert", onAlert);</pre>
<p>Using Underscore, they have a lot more options here.</p>
<pre lang="javascript">// Removes just the `onChange` callback.
object.off("change", onChange);

// Removes all "change" callbacks.
object.off("change");

// Removes the `onChange` callback for all events.
object.off(null, onChange);

// Removes all callbacks for `context` for all events.
object.off(null, null, context);

// Removes all callbacks on `object`.
object.off();</pre>
<p>Finally, dispatchEvent is to trigger. ActionScript:</p>
<pre lang="actionscript3">object.dispatchEvent(new Event("myEvent"));</pre>
<p>Underscore:</p>
<pre lang="javascript">object.trigger("myEvent", arg1, arg2, etc);</pre>
<p>You can pass as many arguments as you want, and they&#8217;ll get passed in.</p>
<p>Take a hint from a guy who survived AS1 and AS2: pass an object as the first and only parameters; it&#8217;ll make your API more flexible and is an easier convention to follow vs. being forced to use event order from 2 disparate places in code.</p>
<p>Let&#8217;s review.</p>
<p>ActionScript: EventDispatcher<br />
Backbone: Underscore.js</p>
<p>ActionScript: addEventListener<br />
Backbone: on</p>
<p>ActionScript: removeEventListener<br />
Backbone: off</p>
<p>ActionScript: dispatchEvent<br />
Backbone: trigger</p>
<p>ActionScript: MyClass extends EventDispatcher<br />
Backbone: _.extend(MyClass, Backbone.Events);</p>
<h3>Backbone.Model</h3>
<p>A Backbone Model is basically a PureMVC Proxy. That is, a Model that handles both access control to your data, change events via the Observer pattern, and it wraps a service layer to some web service that the Model&#8217;s data maps to on the back-end.</p>
<p>In Cairngorm it&#8217;d be basically the same thing. In Robotlegs it&#8217;d be a Model that has a Service injected into it. In Swiz, Parsley, and even in Robotlegs, the Model doesn&#8217;t usually contain validation, nor a service(s) with error handling. Sencha&#8217;s ExtJS and Touch do this as well with their Models, and it&#8217;s a common theme you&#8217;ll see with a lot of JavaScript frameworks. Doesn&#8217;t make it right, just something you&#8217;ll have to wrap your head around. Think a Rails ActiveRecord on the client with the ability to be mapped to various services; like localStorage vs. an actual Ajax call to some web service.</p>
<p>Additionally, it&#8217;s implied they are a single entity. Usually the whole point of Models or ValueObjects in ActionScript was to create a combination of data from both what the middle tier provided, but also things the client needed as well. There wasn&#8217;t always such a tight coupling between a database table and the Model you&#8217;re viewing. This is how Backbone Model&#8217;s are viewed.</p>
<p>Assuming you&#8217;re creating a framework-less Model in ActionScript, you&#8217;d go:</p>
<pre lang="actionscript">package
{
	import flash.events.EventDispatcher;

	class Person extends EventDispatcher
	{
		private var _firstName:String = "Jesse"

		public function get firstName():String
		{
			reutrn _firstName;
		}

		public function set firstName(value:String):void
		{
			if(value !== _firstName)
			{
				_firstName = value;
				dispatchEvent(new Event("firstNameChanged"));
			}
		}

		function Person()
		{
			super();
		}
	}
}</pre>
<p>If you&#8217;re using Flex:</p>
<pre lang="actionscript3">package
{
	import flash.events.EventDispatcher;

	class Person extends EventDispatcher
	{
		[Bindable]
		public var firstName:String = "Jesse";

		function Person()
		{
			super();
		}
	}
}</pre>
<p>Or PureMVC:</p>
<pre lang="actionscript3">package
{
	import flash.events.EventDispatcher;

	class PersonProxy extends Proxy
	{

		public static const NAME:String = "Person";

		private var _firstName:String = "Jesse";

		public function get firstName():String
		{
			return _firstName;
		}

		public function set firstName(value:String):void
		{
			if(value !== _firstName)
			{
				_firstName = value;
				sendNotification("firstNameChanged", _firstName);
			}
		}

		function Person()
		{
			super(NAME);
		}
	}
}</pre>
<p>In Backbone it&#8217;d be:</p>
<pre lang="javascript">Person = Backbone.Model.extend({

	firstName: "Jesse"
});</pre>
<p>Notice how you&#8217;re &#8220;extending&#8221; a Backbone.Model. Classes &amp; inheritance in JavaScript are a rabbit hole (all the things ActionScript 1 fixed in ECMA are still not fixed in JavaScript&#8230; not even in Chrome nightly builds), so for now let&#8217;s just pretend it&#8217;s what you think it is.</p>
<p>For working with Backbone Model&#8217;s, you use the get and set function convention. Sencha&#8217;s ExtJS and Touch do this as well. Meaning, you do not set things like this:</p>
<pre lang="javascript">// Wrong
var person = new Person;
person.firstName = "Cow";</pre>
<p>Instead, you set it:</p>
<pre lang="javascript">// Correct
var person = new Person;
person.set("firstName", "Cow");
// or object syntax
person.set({"firstName": "Cow"});</pre>
<p>The set method will trigger a &#8220;change&#8221; event automatically dispatched (triggered) from your Model. If you pass a</p>
<pre lang="javascript">{silent: true}</pre>
<p>as the 2nd parameter, it won&#8217;t trigger the event.</p>
<p>These events are automatically name spaced to the properties that changed. For example, in Flex, the convention was &#8220;propertyName&#8221; + &#8220;Changed&#8221;, like so:</p>
<pre lang="actionscript3">[Bindable(event="firstNameChanged")]
public var firstName:String = "Jesse";</pre>
<p>In Backbone, while the change will fire for anything, if you&#8217;re just interested in a specific property, you can do the same thing:</p>
<pre lang="javascript">person.on("change:firstName", function(model, firstName)
{
	log("Person's change firstName, model: ", model, ", firstName: ", firstName);
});</pre>
<p>You do NOT have to define these yourself like you do in Flash/Flex, it&#8217;s done &amp; triggered for you automatically based on the property names on your model.</p>
<p>Like Sencha&#8217;s ExtJS, the Models have a validate method that can be applied on a per property basis. If the validate method is there, it&#8217;s run. If it doesn&#8217;t validate your change, the property isn&#8217;t set, and the change event isn&#8217;t triggered, and an error event is triggered instead. You can either listen for these, or pass an error callback into the set method itself.</p>
<p>A Model has a lot of other methods only server-side people care about. The only ones you&#8217;ll care about are fetch, parse, toJSON, and isValid.</p>
<p>Now for the scary things:</p>
<ul>
<li>Model&#8217;s have a fetch function that creates a <a href="http://api.jquery.com/jQuery.ajax/#jqXHR">jQuery XMLHttpRequest</a> instance to populate your model from some url. Basically a lighter weight HTTPService (or nice wrapper for URLRequest).</li>
<li>A built in parse method which defaults to smartly reading JSON responses. In Flash/Flex, we&#8217;re used to either using a Factory class, or a ValueObject that knows how to &#8220;build itself&#8221;.</li>
<li>A save method that does the same, asking jQuery to serialize and save your updated Model.</li>
</ul>
<p>One last thing to note that is mentioned in the 2nd bullet. ALL parsing is basically done in the Model. It&#8217;s assumed your middle tier is giving you JSON (bad assumption for larger companies who areÂ infatuatedÂ withÂ XML. Yes, I know it&#8217;s 2012, they don&#8217;t). You have the option to override the parse function and parse it however you want, like in the case of using XML.</p>
<p>This, as opposed to using Factories inside of your Service class, or using self-building ValueObjects. Then placing the results in your Model&#8230; vs. your Model class doing everything.</p>
<p>Individually these are strange, but ok. Together, they&#8217;re whack. A mash of functionality, at least in Flex projects, I&#8217;m used to separating out&#8230; even without unit tests. You don&#8217;t have to use these functions they provide for you, but it&#8217;s very clear they did a lot of work making it easy as pie to use Backbone with someone like Ruby on Rails without the client doing a lot of work.</p>
<p>Either way, the jQuery ajax calls wrap HTTP requests really well, so it&#8217;s not like you can&#8217;t introspect what&#8217;s going on. Callbacks work and Safari/Chrome/Firefox have better-than-Flash/Flex networking debugging tools as well.</p>
<h3>Backbone Collections</h3>
<p>Some brief notes about Backbone Collections. Like Sencha&#8217;s Ext JS, Model&#8217;s have an implied one to one relationship with some back-end service that populates your Model class. Collections are basically a bunch of Models. So if you get a &#8220;list of Contacts&#8221;, in Backbone it&#8217;d be a &#8220;Collection of Models&#8221;.</p>
<p>Backbone uses Underscore to add 50 billion useful array methods to it so working and filtering your Model lists is easier. The &#8220;nice&#8221; feature of Collections is you can set the Model that it contains, and all our add methods will automatically convert the JSON you pass to it. :: shrugs :: I&#8217;d rather have unit tests verify these access points, or even&#8230; you know&#8230; strong typing. Still, there&#8217;s tons of value if you&#8217;re using formalized JSON; I&#8217;ll show you in a second.</p>
<p>Collections have a lot of the same methods as a Model for interacting with the server, parsing, etc. This is where setting the Model of the Collection handles the parsing/populating for you.</p>
<pre lang="javascript">Backbone.sync = function(method, model) {
  alert(method + ": " + model.url);
};

var Accounts = new Backbone.Collection;
Accounts.url = '/accounts';

Accounts.fetch();</pre>
<p>The fetch method is a Model &amp; Collection method for &#8220;go get data from the server at my url&#8221;. It&#8217;s like HTTPService&#8217;s send method or URLRequest&#8217;s load. It creates a jQuery XMLHTTPRequest internally. For those interested, I believe it&#8217;s using the multiple concurrency option (as opposed to first/last which you could configure for Flex HTTPService).</p>
<p>Notice if the Accounts model property is &#8220;Account&#8221;, then whatever comes back from the server will automatically be parsed to an Account Model. The url is the web service URL.</p>
<p>Also rad is the sync method. There&#8217;s a cool infrastructure here that you can read more about on Backbone&#8217;s site. Suffice to say they&#8217;ve abstracted serialization of your Models, whether you&#8217;re saving to a database or LocaleStorage (the string key value store you get in browsers that has more space the Flash&#8217;s SharedObject). This makes caching, mocking, and testing a lot easier.</p>
<p>One thing I found curious is your Model&#8217;s have a validate function but Collections do not. My guess is it&#8217;s trivial to use a forEach with a validate call, so they saw no need to add. Most Flash/Flex developers don&#8217;t really write these as much as they should. You usually either let the server guys code tell your data is bad, you use unit tests, or hope strong-typing finds problems when creating ValueObjects from UI controls. Sencha follows this validate mentality as well.</p>
<h3>Router</h3>
<p>Web applications are unique in that they have an address. Some even have an address that represents a state they can exist in. There is often a symbiotic relationship between the URL and the application. A different URL can put the application in a different state. Conversely, the application state is reflected in the URL.</p>
<p>The format, however, varies. The short of it is, everyone likes slashes, but # are used for backwardsÂ compatibilityÂ for those browsers that don&#8217;t support the History API (basically IE 9 and below). Backbone&#8217;s Router abstracts this for you.</p>
<p>If you&#8217;ve ever utilized <a href="http://www.gaiaflashframework.com/">Gaia</a> to build a Flash website, you&#8217;ll know exactly what to use Backbone Router for. Sort of. Instead of mapping your web site&#8217;s pages, you&#8217;re mapping both page URL&#8217;s as well as URL query parameters to run functions. Yes, you could have those functions change a page, or just draw a new one. Gaia handled all of this internally including branching, hijacking, and URL modification. Backbone Router does a lot of the same but is a little lower level so you to do a little more work.</p>
<p>There are basically 2 features you can utilize. The first is when you go to a different section or state in your application, you can update the URL in the web browser.</p>
<p>The second is when the URL changes. Whether the user modifies the URL in the url bar, they press the back or forward button, or even if the user comes to the URL via a book mark or copy pasta. All can trigger a callback function for each type of URL so your application can get itself into the proper state, get the data it needs, or whatever else to correctly represent the URL.</p>
<p>Notice the routes hash below:</p>
<pre lang="javascript">var Workspace = Backbone.Router.extend({

  routes: {
    "help":                 "help",    // #help
    "search/:query":        "search",  // #search/kiwis
    "search/:query/p:page": "search"   // #search/kiwis/p7
  },

  help: function() {
    ...
  },

  search: function(query, page) {
    ...
  }

});</pre>
<p>You extend the Router class, and then define the routes in the URL, and what callback function to call. While straightforward, you can use all kinds of string matching for more dynamic URL&#8217;s. Internally, those routes will call addCallback to initialize it. When you want to update the URL, just call navigate.</p>
<p>Using the Backbone.history class, you can monitor change events, support the back button in your app, etc.</p>
<h3>View</h3>
<p>A Backbone.View isn&#8217;t a View that a Flash or Flex Developer would call a View. It&#8217;s actually a Controller class on top of aÂ <a href="http://martinfowler.com/eaaDev/PassiveScreen.html">Passive View</a>Â that allows your GUI to have a less coupled integration into Backbone. All your HTML and CSS, whether made by hand or using a templating library like <a href="http://mustache.github.com/">Mustache</a> or <a href="http://handlebarsjs.com/">Handlebars</a>, has no code in it.</p>
<p>All the code that updates via the Models is done in the View.</p>
<p>All the code that listens for user gestures is done in the View.</p>
<p>So it&#8217;s the Controller in the Passive View pattern. Make sense?</p>
<p>I&#8217;ve seen 2 people utilize Robotlegs Mediators like this. One was a colleague who&#8217;d create MXML with zero ActionScript in it. Just like you do in HTML, he&#8217;d assign click handlers to MXML component id&#8217;s (or Sprite/MovieClip names) all in the Mediator. When his Model Actors would send out change events, he&#8217;d use the injected Models to update the View&#8217;s data usually with intimate knowledge of the view&#8217;s structure since it didn&#8217;t have any getter/setters, nor binding, to help with the drawing.</p>
<p>PureMVC could be done in the same way.Â There was a sect of people in the early Cairngorm days who used a ViewModel in aÂ similarÂ fashion.</p>
<p>A Backbone View was specifically created to handle HTML and CSS, and as such, has a LOT more references than just the passive view reference. Those are:</p>
<ul>
<li>el</li>
<li>id</li>
<li>className</li>
<li>tagName</li>
<li>attributes</li>
</ul>
<div><span style="font-size: medium;"><span style="line-height: 24px;">Just stick to id, and it&#8217;ll act just like a member variable in ActionScript, or an ID in MXML.</span></span></div>
<p>Here&#8217;s a tiny Robotlegs Mediator:</p>
<pre lang="actionscript">package
{
public class AvatarViewMediator extends Mediator
{
	[Inject]
	public var view:AvatarView;

	[Inject]
	public var model:PersonModel;

	public override function onRegister():void
	{
		addContextListener("onPersonModelChanged", updateImage);
		addViewListener("onImageClicked", onImageClicked);
		updateImage();
	}

	private function updateImage(event:Event=null):void
	{
		view.image = model.userImageURL;
	}

	private function onImageClicked(event:MouseEvent):void
	{
		dispatch(new Event("onAvatarImageClicked"));
	}
}
}</pre>
<p>When the ActionScript GUI class is created, it&#8217;s Mediator is created. It immediately updates the Avatar GUI with the latest user image. If the Model ever changes thereafter, the image is immediately updated. Finally if the user clicks on the image, it&#8217;ll dispatch an event on the frameworks event bus to let someone else handle it; maybe a Command, maybe another Mediator&#8230; etc.</p>
<p>Here&#8217;s the equivalent in JavaScript:</p>
<pre lang="javascript">// make a global event bus like Robotlegs, or PureMVC's Notifications
eventBus = _.extend({}, Backbone.Events);
Backbone.Model.prototype.eventBus = Backbone.Collection.prototype.eventBus = Backbone.View.prototype.eventBus = eventBus;

var personModel = new PersonModel;

var AvatarView = Backbone.View.extend({
	id: "avatar-div",

	initialize: function()
	{
		this.model.on("change", this.render, this);
	},

	events:
	{
		"click .avatarImage":	"onImageClick"
	},

	render: function()
	{
		var imageURL = this.model.get("imageURL");
		$(this.el).html(this.template('
&lt;img src="&lt;%= imageURL %&gt;" alt="" /&gt;'));
		return this;
	},

	onImageClick: function()
	{
		this.eventBus.trigger("onAvatarImageClicked");
	}
});

var aView = new AvatarView({model: personModel});</pre>
<p>Using Underscore, we listen for change events from our Model. Also notice View&#8217;s are assumed to have 1 Model. If you&#8217;ve seen any reasonably sized Robotlegs/PureMVC app, you know this isn&#8217;t often the case, heh. It&#8217;s assumed this is not null when the View is created.</p>
<p>The click handler listens for a click event from our HTML div. Our render function, run when the View is shown and when our Model updates, draws itself.</p>
<p>Notice the id is just a string; I actually use the el, or &#8220;HTML element&#8221; to set its html. The template method is an Underscore method to do cool stuff; suffice to say it refreshes the div with a newly updated Image tag with our correct URL from the model. The purists will decry this, saying that HTML should never be put into View&#8217;s and instead you should use a template library like I mentioned above.</p>
<p>Ignore the return this in the render function. That&#8217;s for chaining support, a method for getting functional programmers off, making code unreadable, and helping the browser swallow exceptions.</p>
<p>And now for the hack. You&#8217;ll notice if I want a global event system like Robotlegs, you just create your own eventBus, and shove the mofo on Backbone&#8217;s prototype. Here&#8217;s a <a href="http://lostechies.com/derickbailey/2011/07/19/references-routing-and-the-event-aggregator-coordinating-views-in-backbone-js/">longer explanation</a> if you care about why. That allows you to then send the application level event in the onImageClick callback.</p>
<p>One thing for those of you who remember ActionScript 2: notice the 3rd parameter of of the model.on. This ensures the callback is executed in the correct scope. It&#8217;s basically ensuring you don&#8217;t have to use <a href="http://www.adobe.com/support/documentation/en/flex/1/asdocs/mx/utils/Delegate.html">Delegate.create</a>. These are pretty hard to debug, too, since you&#8217;ll sometimes get &#8220;method is undefined&#8221; methods which aren&#8217;t true; it&#8217;s actually a null pointer exception since this refers to the function vs. the class. Just be sure to always set it.</p>
<h3>Dependency Injection</h3>
<p>Notice that all the dependencies, in this case the PersonModel, is already created and passed into the View&#8217;s constructor. In larger applications, this isn&#8217;t always the case, or gets unwieldy. There are various Dependency Injection frameworks out there to help with this, such as <a href="https://github.com/cujojs/wire">Wire</a>.</p>
<p>Robotlegs handled this via Dependency Injection as well as through Command startup conventions. Basically, as your application grew, you&#8217;d offload a lot of the startup to wiring up your dependencies, or instantiating them yourself if they required something more than a &#8220;new Thing&#8221;. Things such as &#8220;MainContext&#8221; would become &#8220;StartupCommand&#8221; which then broke off into &#8220;InitializeModels&#8221;, &#8220;InitializeMediators&#8221;, which even later broke off into &#8220;InitializeProductModels&#8221;, etc. You had a refactoring path.</p>
<p>You&#8217;ll eventually want to do the same with Backbone as your applications grow,Â especiallyÂ if your Collections get kind of large. The browsers have a lot better libraries &amp; functionality to serialize &amp; read your data back compared to Flash Player in the browser, so it&#8217;s not always a huge deal to save your data to disk. They also destroy easier too.</p>
<p>Here&#8217;s how you configure a <a href="http://en.wikipedia.org/wiki/Singleton_pattern">Singleton</a> OmnitureModel in Robotlegs:</p>
<pre lang="actionscript">// ApplicationContext.as
injector.mapSingleton(OmnitureModel);</pre>
<p>Here&#8217;s how you do it using Wire:</p>
<pre lang="javascript">// ApplicationContext.js
omniModel: {
   create: {
      module: "models/OmnitureModel'
   }
}</pre>
<p>Wire also supports a modicum of binding expressions so if you need some extra data initialized in your created class, whether constructor arguments or not, you can do so. This is invaluable for Backbone View&#8217;s who often need at least 1 Model reference when they boot up.</p>
<p>Although I&#8217;m still learning DI in JavaScript, I found Wire helpful in configuring Backbone Models to work with local data sources instead hardcoded service URL&#8217;s. You just create a locale application context js file (like a new Robotlegs Context file) to configure the application to use locale data sources instead. So far I&#8217;ve been only able to get this to work in a few browsers as you&#8217;ll see below.</p>
<h3>Local File Access</h3>
<p>Flash was nice in that it had a <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Security.html#sandboxType">localTrusted</a>Â <a href="http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e3f.html">security sandbox</a> later with a unique per system file for <a href="http://blogs.adobe.com/penguinswf/2008/08/secrets_of_the_mmscfg_file_1.html">mms.cfg</a> configuration to allow secure sandboxes. Browsers aren&#8217;t like this.</p>
<p>Firefox requires <a href="http://stackoverflow.com/questions/3481977/is-there-a-way-to-bypass-javascript-jquerys-same-origin-policy-for-local-acce">some config</a> changed to allow this.</p>
<p><a href="http://stackoverflow.com/questions/4556429/disabling-same-origin-policy-in-safari">Safari</a> and <a href="http://stackoverflow.com/questions/3102819/chrome-disable-same-origin-policy">Chrome</a> still want you to launch it in a certain mode.</p>
<p>I still haven&#8217;t figured out IE.</p>
<p>I&#8217;ve been using <a href="http://www.charlesproxy.com/">Charles</a> for mapping to local directories on my machine. This is used to fool the browser into working, even for production URL&#8217;s, so should work in IE when I have more coffee.</p>
<p><a href="http://www.johnkpaul.com/">John Paul</a> suggested I use Underscore&#8217;s <a href="http://underscorejs.org/#wrap">wrap</a> function as another alternative which I haven&#8217;t tried yet.</p>
<h3>Modules / Packages / Dependencies</h3>
<p>As your application grows, you&#8217;ll quickly outgrow initializing everything in your index.html; ie you&#8217;ll start to get a lot of classes. While Backbone comes with Underscore to give you basic inheritance beyond Object.prototype, you still have no package solution like ActionScript 2/3/Java/Ruby/Python/PHP/Corona/C#&#8230; (hell, everyone but JavaScript) give you.</p>
<p>Additionally, you don&#8217;t have a dependency management solution; you have to manually control who&#8217;s loaded, and when. That is simply not feasible in a reasonably sized JavaScript application, even with 1 developer vs. 4.</p>
<p>This is where <a href="http://requirejs.org/">RequireJS</a> comes in.</p>
<p>Considering Require has to account for how you create &#8220;classes&#8221; in a language that provides basically (lol, basic&#8230; yeah&#8230; heh&#8230; sigh&#8230; :: takes a shot ::) 3 ways to do so (<a href="http://www.adobe.com/devnet/html5/articles/javascript-object-creation.html">Object.new</a>, Object.prototype, and closures), various libraries that have their own dependencies, as well as how all libraries handle putting themselves on the global objects (ie window, document, etc.) differently&#8230; Require has a lot of work to do on just cleaning up the language.</p>
<p>ActionScript 1 solved part of this via the <a href="http://livedocs.adobe.com/flashlite/3.0/docs/help.html?content=00004837.html">#initclip</a> / #endinitclip pragmas. You&#8217;d put those at the top of your class with a number, like #initclip 3, and you could then control the load order of classes.</p>
<p>ActionScript 2 solved the packages part by building packages that compiled down to object dot notation, and abstracted both that as well as the #initclip stuff away from developers.</p>
<p>ActionScript 3 gave you namespaces with traits to speed up prototype chain lookup speed.</p>
<p>JavaScript has none of that.</p>
<p>Require tries to do all of that. And then some, such as optimization. Just read the <a href="http://requirejs.org/docs/why.html">why</a>Â and you&#8217;ll get it. Backbone apps work just fine with Require, and I encourage you to do so to ensure your application can reasonably scale on a multi-person team right out of the gate.</p>
<p>Here&#8217;s how you use Robotlegs in a class within a package (set of nested folders):</p>
<pre lang="actionscript">// MainContext.as
package com.jxl.minecraftrecipes.rl
{
	import com.jxl.minecraftrecipes.rl.mediators.FavoritesRecipeViewMediator;
	import com.jxl.minecraftrecipes.rl.mediators.RecipeViewMediator;

	import flash.display.DisplayObjectContainer;

	import org.robotlegs.mvcs.Context;

	import views.FavoritesRecipeView;
	import views.RecipeView;

	public class MainContext extends Context
	{
		public function MainContext(contextView:DisplayObjectContainer=null, autoStartup:Boolean=true)
		{
			super(contextView, autoStartup);
		}

		public override function startup():void
		{
			this.injector.mapSingleton(FavoritesModel);

			mediatorMap.mapView(RecipeView, RecipeViewMediator);
			mediatorMap.mapView(FavoritesRecipeView, FavoritesRecipeViewMediator);

			super.startup();
		}
	}
}</pre>
<p>Here&#8217;s how you do the something similiar in Require:</p>
<pre lang="javascript">// config.js
(function() {
   require.config({
      baseUrl: "./js",
      optimize: "none",
      paths: {
         "../../libs",
         handlebars: "../../libs/handlebars/hbs"
      },
      packages: [
         {
            name: "underscore",
            location: "../../libs/underscore_132",
            main: "underscore",
         },
         {
            name: "backbone",
            location: "../../libs/underscore_132",
            main: "underscore",
         }
   });
}).call(this);</pre>
<p>Basically configure the root directory (&#8220;js&#8221;), set some paths so you can use them either as additional source paths, or short cut names (like I did with handlebars), and finally determine your packages: where they are and what their names are. Keep in mind Require has a strict coding convention for what packages are.</p>
<h3>Optimization</h3>
<p>When you compile a Flex or ActionScript application, here&#8217;s basically what happens:</p>
<ol>
<li>all MXML is converted to ActionScript</li>
<li>all ActionScript is converted to ABC byte code (small, procedural)</li>
<li>ABC is converted to MIR (a language JUST above machine code; easier to target different chipsets &amp; optimizations in MIR)</li>
<li>some MIR is converted to native code, some is compiled natively via JIT, and some just chills out</li>
<li>all of that is compressed via gzip with additional optimizations to shrink it to a small file size (remember, it was made this way when modems ruled t3h interwebz and bandwidth was tincy and faulty)</li>
<li>images are compressed, whether using PNG or JPEG</li>
<li>audio files are compressed (ADPCM, MP3, Speex, etc)</li>
<li>fonts are converted to 1 of the 3 font engines, sometimes decreasing file size as only certain glyphs are converted to specific vector graphics)</li>
<li>any other file is embedded and gzipped</li>
<li>all this is put into a single SWF file, usually on frame 2, with a class on frame 1 to show a preloader and &#8220;new&#8221; frame 2.</li>
</ol>
<p>Why is this good? You get an ultra compressed, self-contained, single HTTP request file with all dependencies delivered to the client in a streaming fashion. And it works. This is why we Flash Devs never got JavaScript&#8217;s eval, because our code is actually compiled. JavaScript in the browser has none of that.</p>
<ul>
<li>All files are un-optimized text. Seems trivial, but for large applications, this can add up. For smart phones and tablets, while sometimes fast, this costs people money.</li>
<li>Since there are multiple files, this is multiple HTTP requests. These take both time to create/destroy, and elongate how long it takes for your application to start and/or transition to a new section. This is really bad on some mobile devices, not just desktop. It&#8217;s REALLY fun to use these apps on slow VPN.</li>
<li>If a class isn&#8217;t loaded let and you try to use it, things break.</li>
<li>Browsers love to swallow null pointer exceptions making the above really challenging to debug.</li>
<li>While you could theoretically remember to load certain files in certain orders, God help you if you ever have to, heck, WANT to refactor. On a multi-person team, even with Git, you&#8217;re eff&#8217;d.</li>
</ul>
<p>Require has a variety of optimization tools that basically combine all your files into a single JS file, strip out all whitespace, convert all your variables to 1 letter variables, amongst other things. Basically makes your code unreadable, too;Â obfuscationÂ isn&#8217;t the goal here, though. There are many others too like <a href="http://www.crockford.com/javascript/jsmin.html">JSMIN</a> and Yahoo&#8217;s <a href="http://developer.yahoo.com/yui/compressor/">YUI</a>, many of which you can <a href="http://refresh-sf.com/yui/">use in a browser</a>.</p>
<p>Conclusions</p>
<p>As you can see, Backbone has a lot of the core features you need to build applications in JavaScript. It has Models that follow the typical Observer pattern of holding your data and broadcasting messages for those who care to know about changes. It has View&#8217;s (which act as Robotlegs Mediators or the Controller on top of PassiveView HTML) allowing you to handle the traditional race condition of &#8220;my data is ready, but my view is not&#8221; vs &#8220;my view is ready but my data is not&#8221; by both accessing Models directly and listening for messages via Underscore&#8217;s messaging system which you can make a global event bus if you wish. Finally, it&#8217;s Router allows you to marry your application as a <a href="http://jessewarden.com/2012/07/finite-state-machines-in-game-development.html">state machine</a> against the browsers&#8217; URL bar to support both deep linking, back/forward navigation, and history.</p>
<p>Riding on top of Underscore, it ensures you have all the basicÂ necessitiesÂ you need for making JavaScript easier to use. Although, I still think if you&#8217;re going to utilize JavaScript swapping out dynamic HTML for Views, then you really need a good templating engine such as Handlebars or Mustache.</p>
<p>The current pain point I&#8217;m still working on and haven&#8217;t figured out yet is unit testing Backbone models. On reasonable sized Flex projects that have issues, my first order of business is to break out the parsing logic and the service logic into separate classes so I can create them as units to be easily tested. This copious <a href="http://jessewarden.com/2012/04/consulting-chronicles-6-refactoring.html">refactoring</a> continues until &#8220;a Model&#8221; consists of a variety fo classes.Â Backbone puts all of them together into 1 class and with browsers having really strict local file access rules + the fact services are actually inside of it via jQuery Ajax calls, it has made it challenging to fake their service calls to fixtures/mocks&#8230; and test only 1 thing. Anyway, I&#8217;m still learning.</p>
<p>Hope this helps!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://jessewarden.com/2012/08/backbone-js-for-flash-and-flex-developers.html/feed</wfw:commentRss>
			<slash:comments>14</slash:comments>
		
		
			</item>
		<item>
		<title>RIA Unleashed 2011</title>
		<link>https://jessewarden.com/2011/10/ria-unleashed-2011.html</link>
					<comments>https://jessewarden.com/2011/10/ria-unleashed-2011.html#comments</comments>
		
		<dc:creator><![CDATA[JesterXL]]></dc:creator>
		<pubDate>Tue, 01 Nov 2011 04:35:33 +0000</pubDate>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[fitc]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[riaunleashed]]></category>
		<guid isPermaLink="false">http://jessewarden.com/?p=2966</guid>

					<description><![CDATA[Just wanted to give a post mortem on RIA Unleashed 2011, a conference up in Boston run by the FITC crew. Specifically I wanted to mention some thoughts on gaming, JavaScript, and leadership. I&#8217;m glad I went to RIA Unleashed this year. First year run by the FITC crew who always have their act together. [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/fitc/6286634575/"><img loading="lazy" decoding="async" style="padding-right: 8px;" src="http://jessewarden.com/archives/blogentryimages/riaunleashed2011/fitc_mobile_gaming_corona_air_jesse_warden.jpg" alt="Mobile Gaming with Corona and Adobe AIR" width="320" height="320" align="left" /></a>Just wanted to give a post mortem on <a href="http://riaunleashed.com">RIA Unleashed</a> 2011, a conference up in Boston run by the <a href="http://fitc.ca">FITC</a> crew. Specifically I wanted to mention some thoughts on gaming, JavaScript, and leadership.</p>
<p>I&#8217;m glad I went to RIA Unleashed this year. First year run by the FITC crew who always have their act together. I always like the crowd in Boston. This year was different for a few reasons.</p>
<p><span id="more-2966"></span></p>
<p>&nbsp;</p>
<p><b>Corona</b></p>
<p>I gave a 4 hour work shop on <a href="http://www.fitc.ca/events/presentations/presentation.cfm?event=121&#038;presentation_id=1677">Corona SDK by Ansca Mobile and Adobe AIR for mobile gaming</a>. Some of the Flash Lite team members formed their own company and created Corona, a way to build games and simple applications for Android and iOS. Through a performant, built-in Box2D physics/collision engine, light weight language &#038; API, and partnerships with other social services it has scored a lot of points with people trying to hit the simple gaming &#038; app market for the Indie&#8217;s, those learning, and those looking to reduce complexity in their development stack.</p>
<p>The AIR part was a little frustrating because things are extremely in flux right now with Adobe&#8217;s stack. The future of Flex is mobile applications. The future of Flash Player is low level functionality to support as high end gaming as you can in browser. The future of the Flash IDE appears to be supporting this gaming &#038; mobile workflows. However, none of the gaming engines &#038; supporting frameworks are mature enough yet, most are browser focused vs. mobile, and Flash Player&#8217;s new GPU related display mechanisms aren&#8217;t in AIR 3 for devices yet. They will be soon, the landscape itself is in flux, and &#8220;learning&#8221; to develop &#8220;games in Adobe AIR for mobile&#8221; will be changing big time for the next 12 months as we wait for the tech to hit devices and the libraries/frameworks to morph/be created to mobile work flows.</p>
<p>I really REALLY enjoyed teaching the <a href="http://www.anscamobile.com/">Corona SDK</a>. It&#8217;s been a LONG time that I&#8217;ve gotten to speak on something I enjoyed and had ZERO to do with helping my fellow devs build their skill set for their career. This was, &#8220;Learn this, it&#8217;s fun!&#8221;. Granted, I tried to give an overview of the consumer business landscape regarding paid vs. ads vs. micro-payments.</p>
<p>The trend I&#8217;m seeing is those building games, once they see Corona, are blown away with how simple it is, and what you can produce with very little effort, regardless of their background.</p>
<p>Sitting in on some of <a href="http://www.fitc.ca/events/presentations/presentation.cfm?event=121&#038;presentation_id=1681">Jesse Freeman&#8217;s HTML5 gaming with ImpactJS session</a>, it&#8217;s also very clear there are some great minds working to ensure HTML5 is also a valid platform for gaming. It also pointed out some gaping holes of needs in AIR and Corona gaming with regards to helpful libraries and toolsets.</p>
<p>I may not see any money from this, but damn is it fun and great to be learning something development related that&#8217;s out of my comfort zone (&#8230;and that&#8217;s not Sales or Biz Dev related).</p>
<p><b>JavaScript</b></p>
<p>I met this kat named <a href="https://twitter.com/#!/dougneiner">Doug Neiner</a>. He&#8217;s part of the <a href="http://jquery.com/">jQuery</a> team and is the perfect example of what the negative detractors against Flash/Flex think we should be like. Naturally, I did everything in my power to screw with him and learn everything I could in the short time I spent with him.</p>
<p>In our first meeting at dinner, I spilt my beer all over myself and let him think he did it. He was overly gracious and apologetic. And sincere. We chatted about guns. Damn.</p>
<p>I even tried to screw with him regarding religion. He took that one in stride too. Not insecure. Damn.</p>
<p>So finally with more liquor in me we got into a long discussion regarding JS devs perceptions of Flash, misconceptions about what they get paid, and how they develop, what frameworks &#038; design patterns they use, the nomenclature, and basically every question I could possible think to ask with <a href="http://twitter.com/commadelimited">Andy</a> to help mediate. He did a bang up job considering our language barrier (I butcher and give no respect to true meanings of Design Patterns). He was very forthcoming with information, tactful, unapologetic, and sought to understand. I learned we have a TON in common. I mean like 90%. Damn.</p>
<p>I suggested we do a code review of some of the Flex projects I had worked on in the past. The next day we briefly did so. It was eye opening to see the code they wrote after our previous nights conversations. It + the techniques + the patterns + the lingo seemed very familiar.</p>
<p>They do all the same shit we do. Seriously. What&#8217;s truly different?</p>
<ol>
<li>Their display list is slow, ours is fast.</li>
<li>They thusly use CSS to not only off load display list redraw code, but save having to write a lot of JavaScript because of it. Most Flash/Flex devs don&#8217;t. Our CSS isn&#8217;t true CSS and doesn&#8217;t handle a lot of mouse/keyboard/touch events.</li>
<li>They have to remember what works in what browser on what platform, and remember the already created/solved fallbacks.</li>
<li>They are now creating, and getting paid to do so, some of the same types of browser based applications that we do.</li>
</ol>
<p>That&#8217;s it.</p>
<p>For those of you who bring up loose typing, let me just say every single person, me included, who&#8217;s gotten used to JavaScript and closures does just fine (doesn&#8217;t mean they love it). On smaller projects. Additionally, the amount of tools regarding code coverage, testing frameworks, and other language pre/post compilers out there for JavaScript is solving the problems they have.</p>
<p>I now understand why Flex is <a href="http://blogs.adobe.com/flex/2011/08/flex-where-were-headed.html">100% focused on mobile</a>. You can&#8217;t fight that encroachment, half being true, half being hype with real money behind it.</p>
<p>While the larger scale browser based applications may suffer from lack of a strongly typed language, it&#8217;s very clear the JavaScript community has enough resources behind it to &#8220;figure it out&#8221;. Even if that takes 5 years.</p>
<p>My short time with Doug was great. He&#8217;s a really nice guy, helpful, and is extremely hard to take the piss out of. We have much in common with our browser brethren.</p>
<p>What remains to be seen on the technical side is how they handle Enterprise sized applications. Most I&#8217;ve seen is coded on the server-side and the client is generated (Google&#8217;s GWT, Microsoft&#8217;s .NET, Oracle&#8217;s ADF, Python/Ruby HTML templates). This is not how these guys develop; they develop just like us. They&#8217;re deep into the client code and browser and design. They do the work we do.</p>
<p>What I could gather is most is currently offloaded to the server, but based on some of the projects Doug showed me, it&#8217;s very clear traditional Flash &#038; Flex applications (not websites nor widgets) are next in line.</p>
<p>It&#8217;s also very clear the jQuery team scored big time getting Doug on board. He is whip smart, passionate, and has good character.</p>
<p><a href="http://www.flickr.com/photos/fitc/6299487045/sizes/l/in/photostream/"><img loading="lazy" decoding="async" style="padding-right: 8px;" src="http://jessewarden.com/archives/blogentryimages/riaunleashed2011/fitc_refactoring_jesse_warden.jpg" alt="Refactoring - Jesse Warden" width="320" height="214" align="left" /></a><b>Leadership</b></p>
<p>Which leads me to leadership. It was very clear a lot of people are lost. I&#8217;ve seen it online for awhile, but seeing it in person confirmed it. For 10+ years Macromedia &#038; Adobe have lead us technologically. Now they&#8217;re not. (paraphrasing Freeman here&#8230; or maybe I&#8217;m not&#8230; *ahem*) Many of our thought leaders have either left or haven&#8217;t recognized their responsibilities. In in the past, I&#8217;ve done my best to petition people like <a href="http://waxpraxis.tumblr.com/">Brandon Hall</a>, <a href="http://www.bit-101.com/blog/">Keith Peters</a>, and others to recognize what happens when they disappear or do certain things without context. Even normally secure people get the insecurity of the masses leaked upon them like spittle in a violent scuffle. This affects them.</p>
<p>It&#8217;s not just us. Microsoft is really taking some bold (crazy?) moves with Windows 8. While Apple recognizes some people drive trucks (Desktops and Laptops) and others cars (mobile) and thus made 2 OS&#8217;s for each platform, Microsoft is forcing both into the same OS. While Silverlight still has a lot of value and a future, it&#8217;s very clear where Microsoft is heading. Those who don&#8217;t wish to ride the Silverlight wave have left to other techs, or migrated back to the Win32 land.</p>
<p>Mobile development itself is still in it&#8217;s infancy. We have extreme hype continually thrown at us, yet the toolsets are still growing and changing. While some companies are making a lot of their revenue either partially or wholly from it, the &#8220;RIA&#8221; aspect doesn&#8217;t seem to have transitioned to the Flex and Flash world yet. Keep in mind, this could be because I&#8217;ve done zero marketing on what we&#8217;ve accomplished on mobile regarding our <a href="http://www.youtube.com/watch?v=wt9_75YjFLs">mobile Dashboard</a> and my <a href="http://www.youtube.com/watch?v=ZiZCHlJDPdc">mobile gaming</a> &#038; <a href="http://jessewarden.com/2011/08/corona-and-cocoonp2p-now-in-hd-jxltv-episode-10.html">mobile application</a> work. I&#8217;m starting to hear about (from FITC Toronto, email, and Twitter convo&#8217;s) more and more Agency mobile work. If the consumers are paying, and companies are paying agencies, then it&#8217;s only a matter of time before it gets into the Enterprises and startups wishing to fund applications for B2B.</p>
<p>Either way, it&#8217;s very clear a lot of people are either picking a path that seems safe, or one that pays the bills. Only a few are saying, &#8220;This is fun AND makes me money, I&#8217;m going here.&#8221; If they do, they don&#8217;t define if that money actually pays for their mortgage/rent.</p>
<p>It was clear that there is still a lot of uncertainty, about the tech, business, and political landscape both here in the states and internationally. Thus there is also a ton of opportunity. While I&#8217;m disappointed a lot of people I respect haven&#8217;t provided what I perceived as much needed guidance in these confusing times, I get why a lot of them don&#8217;t. It gets tiring justifying obvious things after awhile. I get tired of telling my 2 year old no, but it&#8217;s my responsibility as a parent. Others aren&#8217;t the &#8220;parents&#8221; of the industry, but the power of their words, insight, and confidence about the future really do soothe the masses in ways they may not fully understand. I swear I&#8217;m not projecting; I see the impact on people not having their thought leaders spout a direction.</p>
<p><b>Conclusions</b></p>
<p>RIA Unleashed is clearly in good hands, FITC did a bang up job. Work shops are fun, I&#8217;d love to do another, especially for a younger crowd at a local school or something. It&#8217;s very clear from my Refactoring preso I need more imagery to convey humanistic challenges in programming. The next consulting article I do, I&#8217;ll remedy that.</p>
<p>It&#8217;s also very clear there isn&#8217;t clarity the future yet, at least for Flash/Flex devs. If you want to do Ruby, Python, or Java on the server, you&#8217;re golden. If you want to do iOS or native Java for companies on B2B and some consumer offerings, you&#8217;re set. The Flash agency landscape is very confusing to me, I have no idea what&#8217;s going on. The Flex landscape is the same as it ever was. While Adobe&#8217;s mostly focused on mobile, there still seems to be a lot of people who aren&#8217;t using JavaScript/HTML/CSS on the client for large scale apps yet; if they are, it&#8217;s server-side generated. I&#8217;m not hearing anything yet for Flex 4 mobile work. I personally blame Adobe&#8217;s lack of hard marketing about how awesome it is to build mobile apps in Flex, Europe&#8217;s debt, and the USA&#8217;s budget woes. Maybe end of 2012 we&#8217;ll start to see a change when the bigger companies get balls to start targeting the growing demographic who wants apps vs. websites.</p>
<p>For HTML5, it seems the huge push is out west. While I occasionally hear about growing JavaScript/HTML/CSS application projects here on the east coast, it seems business as usual, and in California/the valley, business is unusual. i.e., we don&#8217;t care if this technology is inappropriate, if you say HTML5, we&#8217;ll give you tons of Series A funding. Mobile too? Here&#8217;s more.</p>
<p>&#8230;which, again, is I guess why Adobe is still pushing hard on Flex mobile. They know that once Android saturates the market more, the manufacturers will continue to screw up their browser implementations with crappy GPU&#8217;s, thus ensuring those who want highly branded applications with a lot of functionality will choose Flex. Or Flash. It&#8217;s strange, because I keep hearing about those who wish to do web deployments to prevent having to do the 3 development efforts (web, iOS, Android). I used to question and get concerned about what they are doing, but after using <a href="http://soundcloud.com">SoundCloud.com</a> on my iPhone&#8217;s browser vs. the SoundCloud applications for both Android and iOS, it&#8217;s very clear: those who want the best experience will go native. It remains to be seen if the right someone(s) see what Flex and AIR can really do on mobile, and go, &#8220;Man&#8230; this looks great, and can be developed in a shorter time frame&#8230; and be re-used across tons of devices with just design changes to handle the variety of resolutions and functionality changes with our existing design tools. Let&#8217;s do this!&#8221;</p>
<p>We&#8217;ll see. And that&#8217;s what sucks&#8230; this whole &#8220;we&#8217;ll see&#8221;. Remember when we KNEW the Ajax guys were full of shit? Now they&#8217;re taking some of our widget jobs. Yes, you could do &#8217;em over the weekend, but some of those were fun, man&#8230; and nice to have some money on the side of you weren&#8217;t a full time freelancer. Things were so certain then. The only certainty I have now is:</p>
<p>1. The AIR for Android and iOS is really compelling and no one who matters seems to know about it.<br />
2. The Flex in the Enterprise and mid-size software shops seems un-moveable. While the HTML5 hype is replacing a lot of Flex jobs, just like the iPad did for financial firms moving to HTML/native vs. Flex for some jobs, the HTML5 is mostly hype. That doesn&#8217;t mean you can ignore it; a lot of companies make decisions on a CTO&#8217;s whim, even if that decision is completely wrong technologically. Either way, you lose a gig. There still seem to be a lot of people who want to write a TON of ActionScript, quickly, and thus, Flex is still in demand.</p>
<p>#keepYourHeadsUp</p>
<p><a href="https://github.com/JesterXL/Corona-SDK---Adobe-AIR-Workshop-and-Refactoring-Presentation">Need the Presentations and Code from RIA Unleashed 2011?</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://jessewarden.com/2011/10/ria-unleashed-2011.html/feed</wfw:commentRss>
			<slash:comments>30</slash:comments>
		
		
			</item>
	</channel>
</rss>
