<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Draw &amp; Code on Medium]]></title>
        <description><![CDATA[Stories by Draw &amp; Code on Medium]]></description>
        <link>https://medium.com/@DrawandCode?source=rss-87743bcd46df------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_27F2fl2RPz8X9HnoH_OVA.png</url>
            <title>Stories by Draw &amp;amp; Code on Medium</title>
            <link>https://medium.com/@DrawandCode?source=rss-87743bcd46df------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 14:45:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@DrawandCode/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to kill a good idea with a dis-‘app’-ointing product]]></title>
            <link>https://medium.com/@DrawandCode/how-to-kill-a-good-idea-with-a-dis-app-ointing-product-5524adae0170?source=rss-87743bcd46df------2</link>
            <guid isPermaLink="false">https://medium.com/p/5524adae0170</guid>
            <category><![CDATA[ideas]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[ui-design]]></category>
            <category><![CDATA[product]]></category>
            <category><![CDATA[apps]]></category>
            <dc:creator><![CDATA[Draw & Code]]></dc:creator>
            <pubDate>Wed, 12 Jul 2017 23:01:00 GMT</pubDate>
            <atom:updated>2017-07-12T23:01:00.763Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Ever found an app, or some other type of product, that’s such a great idea you can’t help but think, “dammit!, I totally could have come up with that!”?</strong></p><p>Scrolling through my newsfeed today, I stumbled upon an app based on the most brilliant idea. I won’t go into details here, but the concept is right up my street and sounds perfect. It solves a very real problem, and I couldn’t wait to start using it. And yes, I felt a pang of envy — why didn’t I think of that?!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/305/0*o9OXAYkALp3gnjJE.gif" /></figure><p>Pushing my envious thoughts aside, I immediately installed and opened the app. It doesn’t take long before I’m reminded of 3 key things that can kill a good idea and a product.</p><h3>1. Introduce pain into the sign up process</h3><p>Before I can do anything, I have to sign up. Righto, this is fairly standard nowadays. I’m presented with the usual suspects — signing up with Facebook, which I never do, or email. So I go ahead and enter my email and create a password.</p><p>First disappointment: the app doesn’t integrate with Apple’s Activities, so I can’t use <a href="https://1password.com/">1Password</a> to generate a password for me. Oh well, I’m still keen enough to continue.</p><p>The app then tells me I need to verify my email by opening it and tapping on a ‘Verify’ button. Ok, that’s cool. I go ahead and do it. I tap the button, then get taken back to the app. Weeee, here we go.</p><p>Uh, the app is now asking me to enter my email and password again. Kind of frustrating. I enter my email and password (again, this would have been easier with 1Password but I digress…) and uh oh, I get an alert saying I need to verify my email. Again. They have sent me another email.</p><p>Normally I would have kicked this into touch at this point, but I really, REALLY want to use this product!</p><p>So I open the new email, go through the process again, head back to the app, and get the same alert. Glutton for punishment that I am, I try a third time. Maybe I got the password wrong. Nope, still the same alert. With a heavy heart, I concede defeat and delete the app.</p><p>Thinking that was the end of the story, an email lands in my inbox the next day, full of apologies, with a couple of dad jokes thrown in. Apparently they were experiencing some technical issues, and they kindly ask me to try again. Ok, sure thing, benefit of the doubt and all that, let’s try again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/100/0*P2oZi0ZZ79y6nV95.gif" /></figure><p>I download the app again, tap to sign up and hoorah, I’m in!</p><h3>2. Make sure you include a few basic UI no-nos</h3><p>It doesn’t take me long to realise the UI is a little clunky. UI is my bag, so I may be more critical than most, but there were some very basic errors. For example, the keyboard covers vital content and won’t allow me to scroll beyond it. I need to collapse the keyboard and find the field, then tap in it to bring the keyboard back. Tut.</p><h3>3. Fail to deliver, and throw in a few dead ends</h3><p>The app is a location-based service, so I add my home postcode and let the app do its thing. No results found. Huh, ok, well I live a little out in the sticks so perhaps that’s to be expected. I work in the city, however, so I add my office postcode, thinking this should do the trick. Nope, nothing. So now I’m plum out of luck, left with no options. I can’t do anything. I can’t even continue.</p><p>Disappointment sets in, and I realise this isn’t going to be the awesome product I thought it would be. Maybe one day, but unfortunately not today. I hit the home button, press and hold the app icon, and send it once more into jiggling oblivion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*m3z2UC_9BPiAFep4.gif" /></figure><p>I was totally on board with the concept and really, really wanted to use this app. And I would have been a total advocate if it did what it promised. But for now, that awesome concept remains just that. A concept.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/0*HYOghkNL9s9WSxnx.jpeg" /></figure><p>With so many apps released every day, you only get one shot at winning people over. If you disappoint your ‘idea’ fans like me from the outset, chances are you’ve lost them forever. Or maybe you’ve just inspired them to go and create a much better product than yours.</p><p>On that note, I’ve got a bit of time on my hands. I might just go ahead and try and build it myself.…</p><p>By <a href="https://medium.com/@matimage">Mat Rutherford</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5524adae0170" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a GraphQL API in Rails — Part 3: Best Practice]]></title>
            <link>https://medium.com/@DrawandCode/building-a-graphql-api-in-rails-part-3-best-practice-8e4a655463d4?source=rss-87743bcd46df------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e4a655463d4</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[graphql]]></category>
            <dc:creator><![CDATA[Draw & Code]]></dc:creator>
            <pubDate>Fri, 07 Apr 2017 07:37:50 GMT</pubDate>
            <atom:updated>2017-04-10T01:32:44.646Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the final post in a series covering three topics relating to GraphQL:</p><ol><li><a href="https://medium.com/@DrawandCode/building-a-graphql-api-in-rails-part-1-a40aaf7e165f#.gbowa283r">What is GraphQL?</a></li><li><a href="https://medium.com/@DrawandCode/building-a-graphql-api-in-rails-part-start-coding-8b1de6d75041#.182pcqr2k">Building a basic API with Rails</a></li><li><a href="https://medium.com/@DrawandCode/building-a-graphql-api-in-rails-part-3-best-practice-8e4a655463d4">Some best practices</a></li></ol><p>As I mentioned previously, I decided to write this series as Github recently released its <a href="http://githubengineering.com/the-github-graphql-api/">GraphQL API alpha</a>. Github has been at the forefront of API-driven development for some time now, and its RESTful API is an exemplary API design referenced by many developers. So it’s always pretty interesting to explore new Github releases.</p><p>This post is based on my talk at <a href="https://www.meetup.com/Ruby-On-Rails-Oceania-Sydney/">RoRoSyd Meetup</a>. If you’d like to know more, you can check out my <a href="http://slides.com/waynechu/graphql">slides</a> and <a href="https://github.com/wayne5540/graph_blog">an example repo</a>.</p><p>Alright, let’s get started on part 3!</p><h3>1. Interfaces</h3><p>Say we have 2 types that share many fields, like id, updated_at, and created_at basic ActiveRecord fields, for example. How do we clean these types? One way to do it is by using interfaces.</p><p>Let’s take a look.</p><p>Before refactoring, UserType and PostType look like this:</p><pre># app/graph/types/user_type.rb<br>UserType = GraphQL::ObjectType.define do<br>  name &quot;User&quot;<br>  description &quot;A user&quot;<br><br>  field :id, types.Int<br>  field :email, types.String<br>  field :updated_at do<br>    type types.Int<br><br>    resolve -&gt; (obj, args, ctx) {<br>      obj.updated_at.to_i<br>    }<br>  end<br>  field :created_at do<br>    type types.Int<br><br>    resolve -&gt; (obj, args, ctx) {<br>      obj.created_at.to_i<br>    }<br>  end<br>end</pre><pre># app/graph/types/post_type.rb<br>PostType = GraphQL::ObjectType.define do<br>  name &quot;Post&quot;<br>  description &quot;A post&quot;<br><br>  field :id, types.Int<br>  field :title, types.String<br>  field :content, types.String<br>  field :updated_at do<br>    type types.Int<br><br>    resolve -&gt; (obj, args, ctx) {<br>      obj.updated_at.to_i<br>    }<br>  end<br>  field :created_at do<br>    type types.Int<br><br>    resolve -&gt; (obj, args, ctx) {<br>      obj.created_at.to_i<br>    }<br>  end<br>end</pre><p>Now let’s create an active_record_interfaces.rb file and define id, updated_at, and created_at.</p><pre># app/graph/types/active_record_interfaces.rb<br><br>ActiveRecordInterface = GraphQL::InterfaceType.define do<br>  name &quot;ActiveRecord&quot;<br>  description &quot;Active Record Interface&quot;<br><br>  field :id, types.Int<br>  field :updated_at do<br>    type types.Int<br><br>    resolve -&gt; (obj, args, ctx) {<br>      obj.updated_at.to_i<br>    }<br>  end<br>  field :created_at do<br>    type types.Int<br><br>    resolve -&gt; (obj, args, ctx) {<br>      obj.created_at.to_i<br>    }<br>  end<br>end</pre><p>In doing so, our UserType and PostType become much clearer:</p><pre># app/graph/types/user_type.rb<br><br>UserType = GraphQL::ObjectType.define do<br>  interfaces [ActiveRecordInterface]<br>  name &quot;User&quot;<br>  description &quot;A user&quot;<br><br>  field :email, types.String<br>end</pre><pre># app/graph/types/post_type.rb<br><br>PostType = GraphQL::ObjectType.define do<br>  interfaces [ActiveRecordInterface]<br>  name &quot;Post&quot;<br>  description &quot;A post&quot;<br><br>  field :title, types.String<br>  field :content, types.String<br>end</pre><h3>2. Service objects</h3><p>We use resolve blocks to handle each field’s behaviour. However if we add code logic into a resolve block, it becomes fragile, and it’s also not easy to test. That’s why control flow logic should be abstracted to a Service Object and not placed in a resolve block.</p><p>Here’s an example.</p><p>This code:</p><pre>CreatePostMutation = GraphQL::Relay::Mutation.define do<br>  # ...<br><br>  resolve -&gt; (object, inputs, ctx) {<br>    post = ctx[:current_user].posts.create(title: inputs[:title], content: inputs[:content])<br><br>    {<br>      post: post<br>    }<br>  }<br>end</pre><p>Could be:</p><pre>CreatePostMutation = GraphQL::Relay::Mutation.define do<br>  # ...<br><br>  resolve -&gt; (object, inputs, ctx) {<br>    Graph::CreatePostService.new(inputs, ctx).perform!<br>  }<br>end</pre><p>In the second case, we only need to test Graph::CreatePostService. It’s more testable and easier to maintain.</p><h3><strong>3. Use the Relay module</strong></h3><p>In <a href="https://github.com/rmosolgo/graphql-ruby">graphql-ruby gem</a>, there are a couple of built in modules with the Relay namespace. If you want your API to look like <a href="https://developer.github.com/early-access/graphql/">GitHub GraphQL API</a>, or you just want to integrate it with <a href="https://facebook.github.io/relay/">Relay</a>, it will save you tons of time.</p><p>Check out the modules below to get a taste:</p><ul><li>GraphQL::Relay::ConnectionType</li><li>GraphQL::Relay::Node</li><li>GraphQL::Relay::Edge</li></ul><p>These are all my experiences, and things I’ve learned. Do you have any more tips to share? Leave a comment here. Thanks!</p><p>By <a href="https://medium.com/@waynechu">Wayne Chu</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e4a655463d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prototyping APIs for mobile apps]]></title>
            <link>https://medium.com/@DrawandCode/prototyping-apis-for-mobile-apps-74881d1050a4?source=rss-87743bcd46df------2</link>
            <guid isPermaLink="false">https://medium.com/p/74881d1050a4</guid>
            <category><![CDATA[prototyping]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Draw & Code]]></dc:creator>
            <pubDate>Tue, 21 Mar 2017 06:21:19 GMT</pubDate>
            <atom:updated>2017-03-21T06:21:19.059Z</atom:updated>
            <content:encoded><![CDATA[<p>Unless your mobile app is completely self contained, it’s likely to be using a server component in some shape or form. And when front-end features depend on their back-end implementations, the app teams are left waiting for their server counterparts, wasting time and money. Prototyping can mitigate this.</p><h3>To prototype or not to prototype</h3><p>The skeptics among us will question the need for prototyping in the first place. Shouldn’t the aim be to ensure the readiness of the APIs before any app development kicks off? In the ideal world, yes, but factors like tight deadlines, last-minute requirement changes and resourcing problems can make that impossible.</p><p>That’s not the only argument for prototyping though. Even when there’s time and resources are available, the API design may not work as well in practice as first thought.</p><p>Consider a server component originally written for a web application and now reused for native mobile apps. What works for the former may result in many unnecessary calls for each screen in the latter, which is not optimal and can be difficult for back-end engineers to foresee. The solution is prototyping the proposed changes, ensuring they work well with the apps and then handing them over to the server team to implement in production.</p><h3>Basic solution</h3><p>Choosing the prototyping tool for your APIs depends on your proficiency in back-end development. The easiest option is simply to construct responses for your endpoints as static JSON or XML files and host them on a local web server.</p><p>Improving that idea further, services like <a href="https://apiary.io/">Apiary</a> can publicly host the static responses for you. They also allow you to easily define paths to your endpoints, provide documentation for each one and many other things likely introduced since this article was written.</p><h3>Advanced solution</h3><p>When static responses aren’t enough, the next step is writing prototype APIs in lightweight frameworks, which allows you to add any logic missing from the static responses. It may seem slightly wasteful to create a whole new API just for prototyping, but it really isn’t, considering how little code you need to create a fully-functioning web service in many frameworks.</p><p>The choice of framework is relatively easy, because production factors like performance are completely irrelevant for a prototype and the only goal here is producing something quickly. Therefore, it’s a good idea to choose a framework based on the language that you are most comfortable with.</p><p><a href="http://www.sinatrarb.com/">Sinatra</a>-like frameworks are my personal preference. They’re lightweight and there’s one available for virtually every language in existence. It really doesn’t take much to write a working API, the code is readable and there’s no boilerplate that many web frameworks are fraught with.</p><p>Below is an example application written in <a href="http://flask.pocoo.org/">Flask</a>, the Python variant of Sinatra.</p><pre>from flask import Flask <br>app = Flask(__name__)</pre><pre>@app.route(“/”)<br>def hello(): <br> return “Hello World!”</pre><pre>if __name__ == “__main__”: <br> app.run()</pre><p>That’s it. There are no configuration files that I’m omitting, that’s the whole working application.</p><p>To go further and be able to save data, you can use a NoSQL database, such as <a href="https://www.mongodb.org/">MongoDB</a>. There is no need to define a schema; just import the library and start running queries.</p><h3>Hosting</h3><p>Once your prototype API is ready for the apps to use, you need somewhere to host it. For development purposes running it on your machine and pointing the apps to your local IP address is sufficient. However, when you need to demo it to your colleagues or clients, you need something more solid.</p><p>The most convenient solution is going with a PaaS (platform as a service) provider, such as <a href="https://www.heroku.com/">Heroku</a> or <a href="https://cloud.google.com/appengine/docs">Google App Engine</a>. With a PaaS you don’t have to worry about configuring and maintaining your server instances, you just deploy the application and use it straight away. As an added bonus, most of these come with a free tier suitable for prototypes.</p><h3>Conclusion</h3><p>Prototyping is good. Although it may seem like extra work, it helps prevent deadlocks in app development and allows mobile engineers to implement and test features that aren’t yet available in the production APIs. On top of this, with the variety of simple solutions at hand, from static response hosting to lightweight web frameworks, there are options available regardless of your skill level or how much time you have.</p><p>By Mike G.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74881d1050a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unboxing Safedome — why package design and the onboarding experience matter]]></title>
            <link>https://medium.com/@DrawandCode/unboxing-safedome-why-package-design-and-the-onboarding-experience-matter-92f8b0ad71fd?source=rss-87743bcd46df------2</link>
            <guid isPermaLink="false">https://medium.com/p/92f8b0ad71fd</guid>
            <category><![CDATA[bluetooth-low-energy]]></category>
            <category><![CDATA[design]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[packaging]]></category>
            <category><![CDATA[onboarding]]></category>
            <dc:creator><![CDATA[Draw & Code]]></dc:creator>
            <pubDate>Mon, 13 Mar 2017 23:36:06 GMT</pubDate>
            <atom:updated>2017-03-27T03:54:45.309Z</atom:updated>
            <content:encoded><![CDATA[<p>Customers are naturally drawn to products that look good. And the same applies to packaging. That’s because it’s the first point of contact a consumer has with a product. An immediate, positive response to packaging is likely to influence how your customer perceives your product. Even better, great packaging is bound to attract even more potential customers.</p><p>After spending two years investing in, testing and tweaking <a href="https://safedome.com/">Safedome</a>, we knew we had to get the onboarding experience right.</p><p>Our task was to create a package for the Safedome card. A credit card-sized card with the smallest electronics in the world that slips easily into your wallet. Shipping out Safedome stuck to a welcome letter and thrown into a DL envelope was never going to be an option.</p><p>So we asked ourselves: “How do we deliver a premium technology product in a no-nonsense, efficient, cost-effective way that also embraces the product’s values and ethos?”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*tT7YxDL9ak1oHVy4.jpg" /></figure><h3>Getting the balance right</h3><p>As a designer, I’m always aware of my many responsibilities: to the environment, to the product, to my boss’s vision, to the customer. Striking a balance between all of these responsibilities is always a challenge.</p><h3>Even Apple can get it wrong</h3><p>I was reminded of the Safedome package design process when a box landed on my desk recently — the Apple Watch box.</p><p>I, like many other people, have generally been a huge fan of Apple packaging. The packaging for the Apple Watch, however, felt over-engineered and ostentatious. And it just screamed wastefulness.</p><p>Looking at the packaging, I couldn’t help but think of its environmental impact. Let’s face it, there’s just no need for so much plastic and complexity. Throwing it out straight away seemed wasteful, so I kept it. I then thought: “Surely, I’ll find another use for this.” So I kept it for a few more weeks. Eventually, I threw it out. That long, hefty box just wasn’t going to work as a pencil case for the kids.</p><p>A pricey-looking box also says: “You just spent a whole lot of money that you really didn’t need to on this packaging.” It’s like sending a donation to a charity and then realizing where a lot of it’s actually been spent: on more mailouts begging for even more money. The balance has to be struck, otherwise a brand can look like it’s more concerned with image than substance.</p><h3>Fit, feel and weight</h3><p>For Safedome there were a few things we wanted to get right.</p><ul><li>Fit — The card had to fit snuggly into the box and be easy to remove — behaving exactly as it would in your wallet.</li><li>Feel — The packaging had to feel smooth and tactile — just like your well-loved wallet.</li><li>Weight — The lightness of the card had to be a pleasant surprise — a new product in your already technology-filled busy life that wouldn’t weigh you down.</li></ul><p>Unboxing the card had to be simple, welcoming and efficient — quickly discovered, easy to use, with a minimum of fuss. We were not out to emulate expensive packaging. We wanted to provide you with peace of mind. Just like Safedome does.</p><p>So how did we go about it?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TKoM-KPSDtW7ikyA.jpg" /></figure><h3>First things first — partnering with a good printer</h3><p>When you have a good relationship with a printer you trust, you’re well on the way to having a great job delivered. Knowing we were in safe experienced hands was important to us. It’s the same way we want Safedome customers to feel.</p><p>We decided to work with a printer based in Shanghai with a local office. Having a local contact who shares our passion for detail, precision and finishing made a world of difference.</p><p>We worked hand-in-hand with the printer to get the look and feel right — that smooth, velvety feel of a well-loved wallet. Touch coat, gloss stock, EVA, curved corners, thumb holes, matte varnish, litho printing (not digital) were just a few of the specifications.</p><h3>Samples are a designer’s best friend</h3><p>As with all design jobs, we could have gone in any number of directions. We began playing around with slider styles, unfolding envelopes, traditional boxes and trays with sleeves. All had their pros and cons, and the unit costs varied considerably.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*D3sdQ7ot06ip2-sj.jpg" /></figure><p>In the end, samples really helped us make our final decision. Sliders were too convoluted and tricky — there were too many moving parts. Envelopes just weren’t secure enough. And boxes were overkill for the slim Safedome card. It turned out a tray with sleeve cover was simple, compact, easy to use and cost effective.</p><h3>The tray</h3><p>The Safedome card sits in a high-density foam called EVA. To slot the card neatly into the foam, we had to cut a hole in the EVA the size of the card and then insert another piece of foam 2 mm thinner inside. We then glued pre-printed card on both sides. On one side we had a thumb hole cut out, so the customer could easily pop the card out of the tray.</p><h3>The sleeve</h3><p>We wanted a matte finish and feel, however the board we used was actually a gloss stock. The printer recommended gloss so that we would achieve the best solid black. You can actually choose from 7 different blacks in the Pantone book. Our choice, Black 6c, is a rich black that’s neither warm nor cool in appearance. Once the ‘touch coat’ laminate was applied to the outer of the sleeve, we achieved both the rich black and the velvety tactile finish we were after.</p><h3>The leaflet</h3><p>We decided on an 8-page concertina fold that served as a quick introduction to the product and its setup. Copy was kept to a minimum. The curved corners of the leaflet provided a soft, welcoming feel that fitted snuggly with the tray.</p><p>The weight, construction and folding mechanisms all had to work as one when put together.</p><h3>Ultimately, less is more</h3><p>We didn’t want excess — that unnecessary waste and clutter that often comes with packaging. After all, at home we only have so much space for empty boxes and gift bags that go to rest for months on end in the hope of being reused one day. And let’s be honest, just like the Apple Watch box, they all get thrown out eventually.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ir1joFrmJUkLeK8t.jpg" /></figure><p>We didn’t want our customers to feel guilty about throwing anything away, so we consciously kept the packaging as minimal as possible.</p><p>A simple, clean experience that pleasantly surprises — and gets out of the way fast.</p><p>by Debra Jason</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92f8b0ad71fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Functional Reactive Programming vs background execution]]></title>
            <link>https://medium.com/@DrawandCode/functional-reactive-programming-vs-background-execution-868a6b6d17a?source=rss-87743bcd46df------2</link>
            <guid isPermaLink="false">https://medium.com/p/868a6b6d17a</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[reactive-programming]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Draw & Code]]></dc:creator>
            <pubDate>Wed, 08 Feb 2017 00:34:00 GMT</pubDate>
            <atom:updated>2017-02-08T00:34:00.204Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This article assumes you have some experience with ReactiveCocoa. If you don’t, check out this </em><a href="http://nshipster.com/reactivecocoa/"><em>NSHipster article</em></a><em> and its </em><a href="http://github.com/ReactiveCocoa/ReactiveCocoa"><em>GitHub</em></a><em> to get started.</em></p><p>At Maxwell Forest, we have drunk the Functional Reactive Programming (FRP) kool aid and it was delish! ReactiveCocoa is the nuts and bolts of the Safedome iOS app and it handles the app’s complexities exceptionally well. The path from pure OOP to FRP is confusing and scary and sometimes feels a bit avant-garde. If you’re not careful, FRP can introduce problems that you don’t encounter as much in conventional iOS projects. One potential problem is signals being triggered during background execution.</p><h3>Background execution</h3><p>Background execution has good documentation; the most useful section is ‘Being a Responsible Background App’. Essentially, Apple doesn’t want your app using up more resources than it needs to or doing things that don’t make sense while the app doesn’t have a visible interface.</p><h3>ReactiveCocoa</h3><p>ReactiveCocoa can do things at the wrong time quite easily. In Safedome, events such as Bluetooth peripherals connecting or disconnecting, Bluetooth being turned on or off, and background fetch API requests can happen at any time that propagate changes throughout the app, even when in the background! Many bindings that we had for these events were causing crashes and violated three of Apple’s background execution guidelines:</p><ul><li>Do not make any OpenGL ES calls from your code</li><li>Avoid updating your windows and views</li><li>Do minimal work while running in the background</li></ul><h3>A simple solution</h3><p>One of the coolest things about ReactiveCocoa is that you can create your own custom signal operators. We created a throttleUntilActive operator that makes sure events aren’t passed through until the app is in the foreground or if that is already the case are passed through immediately.</p><h3>The code</h3><p>We created a RACSignal category and named it RACSignal+ApplicationStateSupport for all of our application state signals.</p><h3>Background and foreground signals</h3><p>We used the NSNotificationCenter+RACSupport category method rac_addObserverForName:object:to create two signals to notify us of the app state changes. One for when it enters the background and the other for when it goes in the foreground and becomes active.</p><pre>+ (RACSignal *)didBecomeActiveSignal {<br>   return [[NSNotificationCenter defaultCenter] rac_addObserverForName:UIApplicationDidBecomeActiveNotification object:nil];<br>}</pre><pre>+ (RACSignal *)didEnterBackgroundSignal {<br>   return [[NSNotificationCenter defaultCenter] rac_addObserverForName:UIApplicationDidEnterBackgroundNotification object:nil];<br>}</pre><p>It would be nicer to use UIApplicationWillEnterForegroundNotification, but unfortunately, that gets sent while the app is still in the background, so we have to use UIApplicationDidBecomeActiveNotification instead.</p><h3>Knowing if the app is in the background or foreground</h3><p>At this point we can get events for when the app is entering the background or has become active, but UIApplicationDidBecomeActiveNotification also gets sent when the user closes the Control Panel or Notification Center while the app is in the foreground. To avoid getting false positives, we need to merge these two signals into one that knows if a UIApplicationDidBecomeActiveNotification event has come after a UIApplicationDidEnterBackgroundNotification event.</p><pre>+ (RACSignal *)isActiveSignal {<br>   return [[[RACSignal<br>           merge:@[[[self didEnterBackgroundSignal] mapReplace:@NO],<br>                   [[self didBecomeActiveSignal] mapReplace:@YES]]]<br>           startWith:@([UIApplication sharedApplication].applicationState != UIApplicationStateBackground)]<br>           distinctUntilChanged];<br>}</pre><p>The merge part sends NO when didEnterBackgroundSignal fires and YES when didBecomeActiveSignal fires. startWith ensures that the start value reflects the application state when the signal gets created. The last part, distinctUntilChanged, prevents a signal from sending the same event multiple times.</p><p>This creates a signal that has the behaviour we need. When the app enters the background it sends NO, when the app enters the foreground it sends YES.</p><h3>Preventing a signal from sending in the background</h3><p>We now need to use isActiveSignal to prevent another signal from sending events in the background, but still send the latest event if it does eventually enter the foreground. RACSignal if:then:else is perfect for this job. It takes three arguments, all being RACSignals. Depending on the value of the if signal, it will send the latest value of either the then or else signals. We can wrap this up and expose it in the header file to create our throttleUntilActive operator.</p><pre>- (RACSignal *)throttleUntilActive {<br>   return [RACSignal if:[RACSignal isActiveSignal] then:self else:[RACSignal never]];<br>}</pre><p>If isActiveSignal sends YES, then throttleUntilActive will send the latest value of self, otherwise it doesn’t send anything.</p><h3>How to use it</h3><p>To use this operator just call it on any RACSignal!</p><pre>// Doesn’t update the views in the background. Nice!<br>RACSignal *updateViewsSignal = [backgroundEventSignal throttleUntilActive];</pre><h3>When to use it</h3><p>throttleUntilActive can block any side effects from happening in the background, so it needs to be used carefully. In Safedome we’ve mainly used it to protect our UI, but it can be used with anything that shouldn’t run in the background.</p><h3>Conclusion</h3><p>We integrated throttleUntilActive into <a href="https://safedome.com/">Safedome</a> fairly late in the development and this broke a lot of animations and transitions. We would have saved ourselves much heartache if we had done this earlier. Don’t make the same mistake and make sure your UI bindings are safe during background execution as early as possible!</p><p>By Aiden B.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=868a6b6d17a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a GraphQL API in Rails — Part 2: Start Coding]]></title>
            <link>https://medium.com/@DrawandCode/building-a-graphql-api-in-rails-part-start-coding-8b1de6d75041?source=rss-87743bcd46df------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b1de6d75041</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Draw & Code]]></dc:creator>
            <pubDate>Tue, 07 Feb 2017 00:56:23 GMT</pubDate>
            <atom:updated>2017-04-07T07:39:03.042Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the second post in a series where I’ll be covering three topics relating to GraphQL:</p><ol><li><a href="https://medium.com/@DrawandCode/building-a-graphql-api-in-rails-part-1-a40aaf7e165f#.gbowa283r">What is GraphQL?</a></li><li><a href="https://medium.com/@DrawandCode/building-a-graphql-api-in-rails-part-start-coding-8b1de6d75041">Building a basic API with Rails</a></li><li><a href="https://medium.com/@DrawandCode/building-a-graphql-api-in-rails-part-3-best-practice-8e4a655463d4">Some best practices</a></li></ol><p>As I mentioned in <a href="https://medium.com/@DrawandCode/building-a-graphql-api-in-rails-part-1-a40aaf7e165f#.o11e81ix8">Part 1</a>, the reason why I decided to write this series is because Github recently released its <a href="http://githubengineering.com/the-github-graphql-api/">GraphQL API alpha</a>. Github has been at the forefront of API-driven development for some time now, and its RESTful API is an exemplary API design referenced by many developers. So it’s always pretty interesting to explore new Github releases.</p><p>This post is based on my talk at <a href="https://www.meetup.com/Ruby-On-Rails-Oceania-Sydney/">RoRoSyd Meetup</a>. If you’d like to know more, you can check out my <a href="http://slides.com/waynechu/graphql">slides</a> and <a href="https://github.com/wayne5540/graph_blog">an example repo</a>.</p><p>Alright, let’s get started on Part 2!</p><h3>Building a basic API with Rails</h3><p>(Note: Content from <a href="http://slides.com/waynechu/graphql#/4">slide#4)</a></p><p>Before we start writing code, let’s define the top level user story and build it step by step.</p><p>Top level user story:</p><p>1. As a user, I need an account so I can use API.</p><p>2. As a user, I can get my account information from API.</p><h4>1. As a User, I need an account so I can use API.</h4><p><strong>a. Install an authorisation gem</strong></p><p>This is really easy in Rails. All you need to do is install the authentication gem you want. <a href="https://github.com/plataformatec/devise">Devise</a> and <a href="https://github.com/thoughtbot/clearance">Clearance</a> are both good options. In this example, I’ll use Clearance, just to try something new, but you can choose whatever you want, it really doesn’t matter.</p><p>I won’t go through how to install Clearance because you can find all that out in the documentation, but basically you only need 3 commands:</p><pre>$ rails generate clearance:install<br>$ rails generate clearance:routes<br>$ rake db:migrate</pre><p>Pretty easy, thanks Ruby community~! 🙏</p><h4>b. Set the API token and user model</h4><p>Wait, there is one more thing to do. You’ll need an auth_token to authorise the user through API. I’ll use <a href="https://github.com/robertomiranda/has_secure_token">has_secure_token</a> (if you use Rails 5+, it’s built in, so you don’t need to install this gem) to simply generate User#api_token. This means our user model will look like this:</p><pre>class User &lt; ActiveRecord::Base<br>  include Clearance::User<br>  has_secure_token :api_token<br>end<br><br># == Schema Information<br>#<br># Table name: users<br>#<br>#  id                 :integer          not null, primary key<br>#  created_at         :datetime         not null<br>#  updated_at         :datetime         not null<br>#  email              :string           not null<br>#  encrypted_password :string(128)      not null<br>#  confirmation_token :string(128)<br>#  remember_token     :string(128)      not null<br>#  api_token          :string</pre><p>That’s it, we finished story 1! Yay~! 🎉</p><h4>2. As a user, I can get my account information from the API.</h4><p>Ok, time to create a GraphQL API.</p><p>Our goal is to build an API endpoint that can receive a query like this:</p><pre>query {<br>  me: viewer {<br>    id<br>    email<br>    created_at<br>  }<br>}</pre><p>and return a JSON response like this:</p><pre>{<br>  &quot;data&quot;: {<br>    &quot;me&quot;: {<br>      &quot;id&quot;: 1,<br>      &quot;email&quot;: &quot;wayne.5540@gmail.com&quot;,<br>      &quot;created_at&quot;: 1477206061<br>    }<br>  }<br>}</pre><p><strong>a. Install the necessary gems</strong></p><pre>Settings<br># Core gem<br>gem &#39;graphql&#39;, &#39;~&gt; 1.0.0&#39;<br><br># Awesome gem to build a graphql api explorer, not necessary<br>gem &#39;graphiql-rails&#39;<br><br># TDD<br>group :development, :test do<br>  gem &#39;rspec-rails&#39;, &#39;~&gt; 3.5&#39;<br>  gem &#39;shoulda-matchers&#39;<br>  gem &#39;factory_girl_rails&#39;<br>  gem &#39;faker&#39;<br>end</pre><p><strong>b. Create an API endpoint</strong></p><p>The request would be &#39;POST /graphql?query=graphql-query&#39; POST/graphql?query=graphql-query with the authorization header {“Authorization&quot; =&gt; “Token #{user.api_token}&quot;}</p><p>We therefore need to create a route for this:</p><pre># config/routes.rb<br>Rails.application.routes.draw do<br>  post &quot;graphql&quot; =&gt; &quot;graphqls#create&quot;<br>end</pre><p>And then a controller:</p><pre>class GraphqlsController &lt; ApplicationController<br>  before_action :authenticate_by_api_token!<br><br>  def create<br>    query_string = params[:query]<br>    query_variables = JSON.load(params[:variables]) || {}<br>    context = { current_user: current_user }<br>    result = Schema.execute(query_string, variables: query_variables, context: context)<br>    render json: result<br>  end<br>end</pre><p>Schema.execute(query_string, variables: query_variables, context: context) is the basic usage of the graphql gem. We pass query string, graph variables, and context into Schema, which we will define later.</p><h3><strong>About GraphQL type</strong></h3><p>Before we go any further, let’s take a look at a graphql type system so we can understand what happens inside our controller action. Here’s the query example I showed you before:</p><pre>query {<br>  me: viewer {<br>    id<br>    email<br>    created_at<br>  }<br>}</pre><p>Note that it actually contains 3 different scopes: Schema, QueryType, and UserType.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/0*WJwjXsb2KGSqv6kG." /></figure><p>Each type is defined by us. The images below should give you a better idea.</p><h4><strong>Schema Type</strong></h4><p>The most outer scope is a Schema containing 2 special types: Query and Mutation.Think of Query as a GET request and Mutation as a POST request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cnDkgisxeM4uX8zL." /></figure><h4><strong>Query Type</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bniYjunDP04jzkga." /></figure><h4><strong>User Type</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ze0kwTY0k-rruGsDFPgug.png" /></figure><h3>Define GraphQL types</h3><p>Now it’s time to define these types by code, which is pretty easy to do using GraphQL::ObjectType API:</p><p><strong><em>UserType</em></strong><em>.</em> To define the user type, we define each field. We customise the response using the resolve block, otherwise it will fetch by the field’s name (i.e. the field id will use user.id as the response). In this example, we want updated_at and created_at to be the Integers, so I’ll call obj.updated_at.to_i in updated_at field’s resolve block.</p><pre># app/graph/types/user_type.rb<br>UserType = GraphQL::ObjectType.define do<br>  name &quot;User&quot;<br>  description &quot;A user&quot;<br><br>  field :id, types.Int<br>  field :email, types.String<br>  field :updated_at do<br>    type types.Int<br><br>    resolve -&gt; (obj, args, ctx) {<br>      obj.updated_at.to_i<br>    }<br>  end<br>  field :created_at do<br>    type types.Int<br><br>    resolve -&gt; (obj, args, ctx) {<br>      obj.created_at.to_i<br>    }<br>  end<br>en</pre><p><em>***QueryType</em>* As with the UserType, we create a viewer field and point it to UserType:</p><pre># app/graph/types/query_type.rb<br>QueryType = GraphQL::ObjectType.define do<br>  name &quot;Query&quot;<br>  description &quot;The query root of this schema&quot;<br><br>  field :viewer do<br>    type UserType<br>    description &quot;Current user&quot;<br>    resolve -&gt;(obj, args, ctx) {<br>      ctx[:current_user]<br>    }<br>  end<br>end</pre><p>The context[:current_user] is passed in by Schema.execute and can be used in every field under Schema. Here we don’t actually need to pass current_user into UserType because UserType itself can also retrieve current_user. I’ve used this example, however, to show how we pass user objects into UserType by returning current_user inside the QueryType#viewer resolve block.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ONO-ogxv33pNnW-tJEHnUw.png" /></figure><h4><strong>Schema</strong></h4><pre># app/graph/schema.rb<br><br>Schema = GraphQL::Schema.define do<br>  query QueryType<br>end</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KVTAXd7Lr9qOPJkHBPUjkg.png" /></figure><h3>Last setup</h3><p>We’re getting there, we just need to add some setups here:</p><h4><em>Autoload graph types</em></h4><pre># config/application.rb<br>module GraphBlog<br>  class Application &lt; Rails::Application<br>    # ...<br>    config.autoload_paths &lt;&lt; Rails.root.join(&#39;app&#39;, &#39;graph&#39;, &#39;types&#39;)<br>  end<br>end</pre><h4><em>Setting GraphQL (UI interface to interact with graph API)</em></h4><p>First, mount GraphQL engine into Rails routes:</p><pre># config/routes.rb<br><br>Rails.application.routes.draw do<br>  # ...<br>  mount GraphiQL::Rails::Engine, at: &quot;/graphiql&quot;, graphql_path: &quot;/graphql&quot;<br>  # ...<br>end</pre><p>Then set up the default authorization header:</p><pre># config/initializers/graphiql.rb<br><br>GraphiQL::Rails.config.headers[&#39;Authorization&#39;] = -&gt; (context) {<br>  &quot;Token #{context.request.env[:clearance].current_user.try(:api_token)}&quot;<br>}</pre><p>Now we can start Rails server and go to <a href="http://localhost:3000/graphiql">http://localhost:3000/graphiql</a> to play around.</p><p>Here are some examples to try:</p><pre>query {<br>  viewer {<br>    id<br>    email<br>  }<br>}</pre><pre>query {<br>  me: viewer {<br>    ...userFields<br>  }<br>  alsoIsMe: viewer {<br>    ...userFields<br>  }<br>}<br><br>fragment userFields on User {<br>  user_id: id<br>  email<br>}</pre><p>Yeah! Now we have our first graphQL API endpoint on our Rails project! 🎉</p><p>This is just a rough guide on how to start building GraphQL API on Rails. In Building a GraphQL API in Rails — Part 3 — Best Practice I’ll show you some best practices.</p><p>by <a href="https://medium.com/@waynechu">Wayne Chu</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b1de6d75041" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[8 philosophies of Fight Club applied to UX design]]></title>
            <link>https://blog.prototypr.io/8-philosophies-of-fight-club-applied-to-ux-design-c1d35e465a2e?source=rss-87743bcd46df------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1d35e465a2e</guid>
            <category><![CDATA[ux-design]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[ux]]></category>
            <category><![CDATA[life]]></category>
            <category><![CDATA[film]]></category>
            <dc:creator><![CDATA[Draw & Code]]></dc:creator>
            <pubDate>Mon, 23 Jan 2017 23:01:34 GMT</pubDate>
            <atom:updated>2017-01-23T23:01:34.250Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*niTWITOPa7RMGv-EZsPqEQ.jpeg" /></figure><p>David Fincher’s brilliant Fight Club got a bumpy reception when it burst onto the scene in the 90s. However, its stature has only grown in the years since, and the film retains its power to influence to this day. If anything, it’s even more relevant today than it ever was. As one of my all-time favourite films, I think it has a lot to teach us all, and can even lead to a more robust and rewarding life.</p><p>For reasons of full disclosure: I was 23 when Fight Club came out, so I was slap-bang in the middle of its target demographic. So I guess I was predestined to love this movie. Chuck Palahniuk’s philosophies, as channeled through protagonist Tyler Durden, spoke directly to me then and still resonate now, nearly 20 years later (jeez, now I’ve thought about that, I feel old!).</p><p>As well as helping you become a better person and enjoy a more fulfilling life, Tyler’s life philosophies can also be applied to my chosen career, UX, in a myriad of ways. Let me present: <strong>Fight Club UX.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*vR7T4DY4gF7nDGa9." /></figure><h3><strong>1. Only when you’ve lost everything are you free to do anything.</strong></h3><p>Tyler gives us this little nugget while burning the narrator’s hand with a toxic chemical. This is basically his version of no pain, no enlightenment kind of thing. He’s certainly got an extreme way of demonstrating his point, but his words resonate.</p><p>While I wouldn’t quite endorse losing everything, there is something to be said for decluttering and refining. There is that giddy feeling of excitement and endless possibility that comes with starting again with nothing. It can also be a bit scary. I should know, I moved to the other side of the world in my thirties, ditching most of my old possessions along the way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*cDunXhigfuDNlKQt." /></figure><p>Applied to UX, Tyler’s philosophy means removing everything unnecessary, superfluous or merely trinkets. Anything that gets in the way of the user achieving their goal is flotsam. Every element in your design should work hard and have a purpose.</p><p>Or as another great writer, Antoine De Saint-Exupery, puts it:</p><blockquote><em>“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.”</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*3nkGX36Hb-jpc3D3." /></figure><h3><strong>2. Sticking feathers up your butt does not make you a chicken!</strong></h3><p>This is essentially Tyler telling us to be true to ourselves. Don’t try and be something you’re not.</p><p>If you find a terrific solution that someone else has implemented, but it’s very specific to a particular audience or demographic, don’t just try to port it to yours without thinking about it. Whether it’s a certain interaction paradigm or navigation structure, think through the vital questions of why, who, how and when it’s going to be used.</p><h3><strong>3. The things you own end up owning you.</strong></h3><p>What we do isn’t the be all and end all of people’s lives. Ok, if someone really loves what we do and spends their every waking moment interacting with it then great. Realistically, don’t expect that. If they dip in every now and then, that is an excellent result and you should be proud. After all, our users have got lives to live.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*g_ifkPN3D_rcRvOv." /></figure><h3><strong>4. Reject the basic assumptions of civilization, especially the importance of material possessions.</strong></h3><p>Hmm. Tyler is rallying against material possessions here, which I think is even more of an issue now than it was 20 years ago. I would actually love to know what Tyler’s reactions to Facebook, Snapchat, Instagram and the like would be. Obviously Tyler goes to pretty extreme ends to make his point, but essentially he is telling us to be aware of what we actually need versus what we want.</p><p>That’s why it’s very important that we create experiences that really matter to people. Whether it’s solving a problem, making their lives easier somehow, or just simply delighting them. Take care in your work, and if you make just one person’s life a little better, be proud.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*oL-nhimZmZobcLU0." /></figure><h3><strong>5. This is your life, and it’s ending one minute at a time.</strong></h3><p>Ok, this is rather depressing sentiment, so let’s look at it in a different way. Life is fleeting and our time here is short. We have to make every moment count.</p><p>We can apply this philosophy to UX in two different ways. Firstly, a user will make up their mind pretty quickly on whether or not they’ll continue to use our product or service. If it doesn’t do what they want it to, or it frustrates them, they’ll drop it and probably never come back. Why? Because life is too short to waste on subpar stuff. Secondly, it’s too short for us to waste creating anything other than excellence. If we can make our user’s life just a little bit better during their brief time on this Earth, isn’t that time well spent?</p><h3><strong>6. You are not a beautiful and unique snowflake.</strong></h3><p>This one’s interesting. Tyler reminds us that we’re all the same decaying organic matter, so ultimately what does individuality matter? This one’s also a bit of a downer, so I’ll try and spin it in a more useful way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*3wdBH0cTn4075PBD." /></figure><p>As UX-ers, should we try and reinvent the wheel each time we begin a new project? Arguably not, that’d be stupid. It’s okay to lean on others who have come before.</p><p>Use successful solutions that are out there to help inform your work (but remember not to stick feathers up your butt). If people enjoy using a certain paradigm, then ride those coattails and utilise it to help users engage with your creation. Yes, originality is great but be careful not to create frustration and throw stumbling blocks in the way.</p><h3><strong>7. May I never be complete. May I never be content. May I never be perfect.</strong></h3><p>We want our work to be as good as it can possibly be, but if we reach that point, do we then just stop? I don’t believe so. We should constantly push ourselves and our work to be better.</p><p>One of the enablers that allows us to push ourselves further is testing. Test constantly. I try to test every 2 weeks through every cycle of our product or services design, development and delivery. This can include validating flows, elemental placement, hierarchy, etc., through to getting constant feedback once our baby is delivered and out in the world.</p><p>Which brings me nicely to the final lesson…</p><h3><strong>8. I say stop being perfect, I say let’s evolve, let the chips fall where they may.</strong></h3><p>Tyler is telling us here that it’s okay to not be, or even strive to be, perfect. If things aren’t exactly perfect, that’s fine — they won’t stay like that forever. Make the best of the situation, and appreciate and enjoy what you have.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/0*DGapZ7ZUJo6uEBTf." /></figure><p>As for UX, well, this one is pretty self explanatory. Whatever you’re working on right now might not be perfect. And that’s okay, it doesn’t have to be. Whatever you are working on can evolve, it’s not fixed. And that is exactly what good UX should do. We should always be responding to our users wants and needs and continually creating a product or service that they love.</p><p>As UXers, I say we embrace Fight Club UX and hold its philosophies and messages close, because it really can help us create better experiences.</p><p>If you’ve taken anything from this, or even think you can bring some of it into your workflow, then great, go ahead and share it, that’ll make me a happy snowflake. Oh, but let’s not forget the first rule of Fight Club UX …</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*-kaaDk-nBHXKQEqg." /></figure><p>By <a href="https://medium.com/@matimage">Mat Rutherford</a>, UX Lead for <a href="http://onefill.com/">Onefill</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1d35e465a2e" width="1" height="1" alt=""><hr><p><a href="https://blog.prototypr.io/8-philosophies-of-fight-club-applied-to-ux-design-c1d35e465a2e">8 philosophies of Fight Club applied to UX design</a> was originally published in <a href="https://blog.prototypr.io/">Prototypr</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to communicate with iframes inside WebView]]></title>
            <link>https://medium.com/@DrawandCode/how-to-communicate-with-iframes-inside-webview-2c9c86436edb?source=rss-87743bcd46df------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c9c86436edb</guid>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Draw & Code]]></dc:creator>
            <pubDate>Fri, 20 Jan 2017 00:56:11 GMT</pubDate>
            <atom:updated>2017-01-22T22:48:39.594Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the core functionalities at the heart of <a href="http://onefill.com/">Onefill</a> is its ability to auto-fill even the most complex forms on a website with a single tap and 100% precision. The technology we built allows us to do just that, but with one exception — iframes.</p><p>And while you might think that iframes are a thing of the past (who would use them these days, right?), the reality is they’re often powering the most critical piece of functionality of any online store — the payment form.</p><p>Before I go on, a quick shout-out. If you want to work with us on problems like this one, we’re hiring right now — native mobile development, Javascript, and other roles. Check out our jobs page and let’s have a chat! <a href="http://onefill.com/meettheteam/">http://onefill.com/meettheteam/</a></p><p>Now back to iframes. Many payment processors (e.g. <a href="https://stripe.com/">Stripe</a>, or <a href="https://www.braintreepayments.com/">Braintree</a>) offer their customers a way to accept payments in the simplest possible way — by just dropping a piece of javascript into their checkout page. This renders an iframe with a form provided by the payment processor that accepts card details — meaning the merchant never sees them at all, and everyone involved in the process feels safer.</p><p>The problem for us is that this, together with modern browser security mechanisms like <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS">CORS</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy">same-origin policy</a>, mean that we can’t automate the process of entering credit card data if we only inject Onefill’s JavaScript helpers into the main page, and the payment form is rendered inside an iframe.</p><p>After some experimentation, however, we’ve found an approach to support iframe — at least with iOS web view — and to communicate with it.</p><h3>Conclusions first</h3><ol><li>Use WKWebView instead UIWebView or WebView for 2 reasons: a) <a href="https://developer.apple.com/reference/webkit/wkwebview">Apple recommends it</a>; and b) There is <a href="https://developer.apple.com/reference/webkit/wkuserscript">an API</a> to inject JS into iFrame</li><li>Use built-in <a href="https://developer.apple.com/reference/webkit/wkuserscript">WKUserScript API</a> to inject JS, set forMainFrameOnly as false to inject JS into every frames (including iframe)</li><li>To communicate between iframe and app, use JS webkit API</li></ol><h3>And now for the code</h3><p>It turns out the problem can be solved if we split it into two parts:</p><ol><li>how to inject our Javascript helpers into an iframe; and</li><li>how to establish interactions between our code in an iframe, and the one in the main frame.</li></ol><p>Let’s look at these one by one.</p><p>Just a note: To run the code in this blog post you’ll need:</p><ul><li>Xcode: Version 8.2.1 (8C1002)</li><li>Swift: Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1)</li></ul><h3>1. Injecting JavaScript helpers into an iframe</h3><p>It’s actually really easy to inject JavaScript helpers in an iframe these days. All you need to do is use WKUserScript API to inject JavaScript into all frames, and specifically a forMainFrameOnly parameter when creating an injectable user script object.</p><p>Example: Inject a script to make every h1 tag red.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/432bd44bada4d798085a8c5e8185a6bb/href">https://medium.com/media/432bd44bada4d798085a8c5e8185a6bb/href</a></iframe><p>As you can see, all we have to do is simply create WKUserScript, and configure it with forMainFrameOnly: false, which means that this script will be executed in all frames of WKWebView, and not just the main one.</p><p>After that, add it to an instance of WKUserContentController, create a WKWebView with that controller, and load your page with iframe — you should see your code being executed in all of them.</p><h3>2. Communicating with iFrame</h3><p>Using JavaScript webkit API is almost the same as injecting JavaScript helpers into an iframe, however we need to implement WKScriptMessageHandler protocol to receive message sent by JavaScript.</p><p>Once we’ve got our code running inside all iframes, we need to communicate with it to execute specific tasks. This can be done by implementing WKScriptMessageHandler protocol, and adding that resulting class to WKUserContentController used with the web view.</p><p>Once that’s done, the handler becomes available to JavaScript code running inside the frame as window.webkit.messageHandlers.&lt;handlerName&gt; object, exposina g postMessage method that accepts string data and sends it back to the main iOS application.</p><p>The application then becomes the communication medium, passing and orchestrating messages back and forth between various frames on the page, and allowing them to work together and execute cross-iframe tasks.</p><p>Here’s an example of the full configuration, with message handler being attached to the web view:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc787829217515fd1786b8d8cdec2413/href">https://medium.com/media/cc787829217515fd1786b8d8cdec2413/href</a></iframe><p>So that’s it. Of course, WKWebView is available only on iOS 8 — but thankfully old OS support is not that big of an issue on iOS platforms.</p><p>Now I’m off to implement the orchestration code, and find a similar solution for Android!</p><h3>References</h3><ol><li><a href="https://kinderas.com/technology/2014/6/15/wkwebview-and-javascript-in-ios-8-using-swift">wkwebview-and-javascript-in-ios-8-using-swift</a></li><li><a href="http://nshipster.com/wkwebkit/">WKWebit</a></li><li><a href="https://developer.apple.com/videos/play/wwdc2014/206/">2014 WWDC about WKWebView</a></li><li>Apple API Docs:</li></ol><ul><li><a href="https://developer.apple.com/reference/webkit/wkuserscript">WKUserScript</a></li><li><a href="https://developer.apple.com/reference/webkit/wkusercontentcontroller">WKUserContentController</a></li><li><a href="https://developer.apple.com/reference/webkit/wkwebview">WKWebView</a></li></ul><p>By <a href="https://medium.com/@waynechu">Wayne Chu</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c9c86436edb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How we use JavaScript to support Onefill]]></title>
            <link>https://medium.com/@DrawandCode/how-we-use-javascript-to-support-onefill-ec88331eabfb?source=rss-87743bcd46df------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec88331eabfb</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[online-shopping]]></category>
            <category><![CDATA[apps]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[mobile-apps]]></category>
            <dc:creator><![CDATA[Draw & Code]]></dc:creator>
            <pubDate>Fri, 06 Jan 2017 00:41:15 GMT</pubDate>
            <atom:updated>2017-02-08T06:04:10.715Z</atom:updated>
            <content:encoded><![CDATA[<p>Building a set of tools to support the <a href="http://onefill.com/">Onefill</a> mobile app has forced us to look at and explore some fresh angles when it comes to using JavaScript. This article focuses on one of the core things we’re doing: form-filling.</p><p>Filling in a form is a seemingly simple action, but it brings a lot of challenges and complexity when applied at scale. After all, our goal is to automate the completion of arbitrarily complex forms with 100% precision, 100% of the time.</p><p>In this post, I’ll focus on two essentials steps involved in this process:</p><ol><li>Finding an element to fill; and</li><li>Inserting data into that element.</li></ol><h3>Step 1: Finding an element</h3><p>The main problem we’re solving is how to interpret all forms that you might encounter online, and understand their structure and the semantics of the individual elements. Is this ‘name’ field supposed to be for your last name or your full name? Does this ‘address’ field expect your full residential address, or only the first line of it?</p><p>To make sure we always get it right, we built a Chrome extension that helps our engine identify the elements, find their selectors and create mappings between our data items and the form structure.</p><p>Firstly, in order to point at any element on the page, we need to know the shortest path (or the selector) of the element we’re trying to find. We can then listen to a click event of the page.</p><p>And as we’re looking to integrate with hundreds and thousands of different online stores, we have chosen to stay away from using any helper libraries or frameworks, and instead leverage the power of JavaScript available in today’s browsers (after all, <a href="http://youmightnotneedjquery.com/">you don’t need jQuery</a>):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*4FpeoMOYbjGTd_T1olswGw.png" /></figure><p>In this case it’s important to use ‘<strong>true’, </strong><a href="https://developer.mozilla.org/en/docs/Web/API/EventTarget/addEventListener">which stands for ‘useCapture</a>’, as the last argument. Nested event bubbling and capturing are two ways of propagating events occurring in an element that sits within another element, when both elements have registered a handle for that event.</p><p>In most cases, bubbling works fine. But here is a quick example of what happens when we don’t use capture. If we look at the checkout page of <a href="http://lasada.sg/">Lazada.sg</a> (in a mobile view), we are unable to capture the card number selector when we use bubbling.</p><p>Here is a screenshot of the html structure and webpage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kZZqajgxK0XLIXHz." /></figure><p>Using event capturing helps to solve this problem, and also helps detect clicks on this page.</p><p>Why? First let’s check the flowchart below (see <a href="https://www.w3.org/TR/DOM-Level-3-Events/#event-flow">how capture and bubbling works</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/0*IejjUbG12Q5qM9VZ." /></figure><p>One important thing we need to remember is bubbling can be stopped.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*NQFPBcsfSlOjQigzBz-AbQ.png" /></figure><p>So when we click an element, if the target website has also got an click event listener, it could stop bubbling. See more info <a href="https://davidwalsh.name/javascript-events">here</a>.</p><p><strong>Highlighting the element</strong></p><p>When building the Chrome extension to quickly map out forms and websites, we aimed to:</p><ol><li>Provide as much of a visual assistance to its users as possible</li><li>Help users move along as quickly as possible.</li><li>Help users quickly identify any problem; and</li><li>Provide a visual confirmation that everything has been captured correctly (e.g. when we have receive a selector, we highlight the target element by changing its background color to light green (#…)).</li></ol><p>To do all this, we firstly need to find the element. Then we need to change the background color.</p><p>We use the code below to find the element we need.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*kzKmBrCH_9epvxdNnBkOPg.png" /></figure><p>When capturing the selector of the element, we use certain rules to make sure it’s unique and the shortest path, so we can use ‘querySelector’ instead of querySelectorAll’.</p><p>Here are some basic logics of how to find the shortest path:</p><ol><li>Check if target element got an <strong>id</strong></li><li>If an <strong>id</strong> exists, check that the <strong>id</strong> is unique. (YES, some websites use same <strong>id</strong> 2+ times)</li><li>If no <strong>id</strong> exists, or the <strong>id</strong> is not unique, then check <strong>class</strong></li><li>Find shortest path with class selector or use a tag as a path identifier</li></ol><p>In the end, what we expect is something like ‘input#input-email’, ‘ul#payment-mode-list &gt; li &gt; a &gt; div &gt; span’, etc.</p><p>Then, we highlight the element:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*1J93Q7HDe4xVbgcuXwoETA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/0*fW_rojstoWfPe5Me." /></figure><h3>Step 2: Inserting data</h3><p>Filling in data for a specific element might mean different things when we’re completing a form. For example, we might need to change a selected value of a drop-down, enter a value into a text input, select a radio button, etc.</p><p>We call one of these a “value” action (when a value needs to be entered or selected in a form):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*WZZ-IwsI5m8dEwRZug6RWQ.png" /></figure><p>We call another simpler one a “click” action, when all we need to do is click on an element:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*lDlH9TYO4MzK7Ian08rXwA.png" /></figure><h4>Triggering an event</h4><p>In order to make our data injection look more like a human behavior, we trigger a set of events after filling in the data.</p><p>For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*Vb1-Wlfx1QwoaT7xT_0ZZg.png" /></figure><p>This step is necessary as some websites listen to these events to execute various steps — e.g. run a validation check to unlock the “save” button, or load the next part of the form, etc.</p><h4>What if we cannot see an element on the webpage?</h4><p>Some content can be loaded dynamically in response to other user actions, and is not available initially on the page. A very common example is how the address data is presented to the user. If a website wants to know a user’s state, quite often the list of states is loaded after a user has selected their country.</p><p>Check out below the three drop-down list status screenshots and the network activities when switching from status 1 to status 3 (using <a href="https://www.coffeecompany.com.au/">CoffeeCompany.com.au</a> here as an example):</p><p>Status 1: Default drop-down</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*w5WyRT1XTIt0Ip48." /></figure><p>Status 2: Country selected as `US`. State drop-down shows US states</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/0*JNujmO-rBSD8-3Fx." /></figure><p>Status 3: Country selected as `AU`. State drop-down shows Australian states</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/0*hcFXUTJADaZFvYBW." /></figure><p>Captured network request</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VmsQ9pTmAmLqho7n." /></figure><p>We can see from the network log that the state endpoint was called two times when we switched the country.</p><p>This means we have to select the country first, and wait until the state is loaded before proceeding to select the state value.</p><p>This whole process normally happens within 1–2 seconds (mostly depending on the customer’s network speed), but what we need to do is fill in both dropdowns not only with the correct data, but also in the correct order.</p><p>The best way we’ve found to handle this issue is to override the network request object (XMLHttpRequest), and wrap its <strong>open</strong> function with our own listener. This way we can monitor when XMLHttpRequests are fired/completed, and we can tell our engine when to fill or check the next element.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*Y0wjJD2TD8EyDMvY7O0eyg.png" /></figure><h3>Conclusion</h3><p>Nowadays, there are many things we can do by using JavaScript without any extra libraries. Using third party libraries is not necessarily a bad thing, but for some simple functions that can be accomplished by using only native JavaScript functions, we’re better off choosing native JavaScript to make it more efficient.</p><p><a href="http://onefill.com/">Onefill</a>’s ultimate goal is to offer a better online shopping experience. With our JavaScript engine injected, we can provide the best assistance throughout the entire <a href="http://onefill.com/">Onefill</a> shopping experience.</p><p>By <a href="https://medium.com/@safounder">Dubang Liu</a>.</p><h4>Some related links you might be interested in:</h4><p><a href="http://youmightnotneedjquery.com/">http://youmightnotneedjquery.com/</a></p><p><a href="https://github.com/oneuijs/You-Dont-Need-jQuery">https://github.com/oneuijs/You-Dont-Need-jQuery</a></p><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener">https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener</a></p><p><a href="https://www.w3.org/TR/DOM-Level-3-Events/#event-flow">https://www.w3.org/TR/DOM-Level-3-Events/#event-flow</a></p><p><a href="https://davidwalsh.name/javascript-events">https://davidwalsh.name/javascript-events</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec88331eabfb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a GraphQL API in Rails — Part 1]]></title>
            <link>https://medium.com/@DrawandCode/building-a-graphql-api-in-rails-part-1-a40aaf7e165f?source=rss-87743bcd46df------2</link>
            <guid isPermaLink="false">https://medium.com/p/a40aaf7e165f</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Draw & Code]]></dc:creator>
            <pubDate>Tue, 03 Jan 2017 00:44:08 GMT</pubDate>
            <atom:updated>2017-02-07T07:09:48.776Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the first in a series of blog posts where I’ll be covering three topics relating to GraphQL:</p><ol><li>What is GraphQL?</li><li>Building a basic API with Rails</li><li>Some best practices</li></ol><p>Yes, GraphQL has been around for a while already. The reason why I decided to write this series is because Github recently released its <a href="http://githubengineering.com/the-github-graphql-api/">GraphQL API alpha</a>. Github has been at the forefront of API-driven development for some time now, and its RESTful API is an exemplary API design referenced by many developers. So it’s always pretty interesting to explore new Github releases.</p><p>This post is based on my talk at <a href="https://www.meetup.com/Ruby-On-Rails-Oceania-Sydney/">RoRoSyd Meetup</a>. If you’d like to know more, you can check out my <a href="http://slides.com/waynechu/graphql">slides</a> and <a href="https://github.com/wayne5540/graph_blog">an example repo</a>.</p><p>Alright, let’s get started!</p><h3>What is GraphQL?</h3><p>First things first, the best way to learn GraphQL is by practising GraphQL. I highly encourage you to play around with some GraphQL tutorials — especially the ones at <a href="http://graphql.org/learn/">graphql.org</a>, and <a href="https://developer.github.com/early-access/graphql/explorer/">Github GraphQL API</a>. Both are very good resources to play around with and learn some stuff.</p><p>So, what’s GraphQL? The official definition is: a query language for your API.</p><p>Don’t look at me, it’s the definition from <a href="http://graphql.org/learn/">graphql.org</a> :) So what does this mean? Let’s take a look at an example to get a better idea:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MIHA8x8GJpi2XsBi." /></figure><p>Yes, it really is as simple as that. You pass your GraphQL query as a parameter in your API request and then let the server figure out how to translate your query into a real SQL (or any other kind of QL that the server might be working with), execute it, and return the data you’ve requested.</p><h3>So… Why?</h3><p>Why was GraphQL born? What are the benefits of using GraphQL, instead of RESTful or RPC API?</p><p>There are two points of view on the benefits of GraphQL for developers.</p><h4>The frontend developer’s view:</h4><ol><li>I can get many resources in a single request; and</li><li>I can customise the response to be what I want it to be.</li></ol><p>As we see in the example, as a frontend developer you can get many resources with a single request — unlike RESTful API, where every endpoint is a resource, and to get multiple resources you have to send and process multiple requests. Also, you can even customise your response names, which makes your life easier when it comes to mapping them onto the models, etc.</p><h4>The backend developer’s view:</h4><ol><li>Versionless API;</li><li>No API documentation; and</li><li>Introspection system.</li></ol><p>One of the best practices of the GraphQL API is that you don’t version your API. By defining your resource type, you don’t need to specify what your API response should look like — your frontend friends will specify it themselves by giving you the query they want. So it’s almost like you only need to define your model abstraction layer for the frontend, leaving everything else to them.</p><p>Moreover, you don’t need to write API documents anymore (thank god!), because by defining your resource (its type, or API model), you also provide the ability to introspect it (think swagger vs. JSON-schema). Your frontend friends can explore the types, and figure out what they need, and request the necessary data from you.</p><h3>GraphQL vs. REST and RPC</h3><p>Let’s take a look at the difference between GraphQL, REST and RPC to make things even clearer:</p><p>## REST</p><p>GET <a href="https://myblog.com/articles">https://myblog.com/articles</a><br>GET <a href="https://myblog.com/articles/1">https://myblog.com/articles/1</a><br>POST <a href="https://myblog.com/articles?title=hello">https://myblog.com/articles?title=hello</a></p><p>## RPC</p><p>GET <a href="https://myblog.com/getAllArticles">https://myblog.com/getAllArticles</a><br>GET <a href="https://myblog.com/getArticle?id=1">https://myblog.com/getArticle?id=1</a><br>POST <a href="https://myblog.com/createArticle?title=hello">https://myblog.com/createArticle?title=hello</a></p><p>## GraphQL</p><p>GET <a href="https://myblog.com/graphql?query=graphql_query_here">https://myblog.com/graphql?query=graphql_query_here</a><br>POST <a href="https://myblog.com/graphql?query=graphql_query_here">https://myblog.com/graphql?query=graphql_query_here</a></p><p>In REST, every endpoint is a resource. In RPC, it is a function. However, in GraphQL we feed the endpoint with sql-like commands passed via query parameter (of course, it’s not a “real” SQL).</p><p>And just before we jump into writing some code, let’s remember an important thing: the separation of concerns. Broadly speaking, this means that whatever API layer or implementation you choose to put on top of your code, it should not change or affect that actual business logic, but wrap it and let your external clients interact with it.</p><p>Quoting GraphQL’s “<a href="http://graphql.org/learn/thinking-in-graphs/#business-logic-layer">Thinking in Graphs</a>” page:</p><blockquote>Where should you define the actual business logic? Where should you perform validation and authorization checks? The answer: inside a dedicated business logic layer. Your business logic layer should act as the single source of truth for enforcing business domain rules.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/0*qDG3Dm-Fpd72kF3O." /></figure><p>Ok, enough theory, let’s write code! Read on here: <a href="https://medium.com/@DrawandCode/building-a-graphql-api-in-rails-part-start-coding-8b1de6d75041#.jfixgudmr">Part 2: Building a GraphQL API in Rails — Part 2</a>.</p><p>by <a href="https://medium.com/@waynechu">Wayne Chu</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a40aaf7e165f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>