<?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 Ramón Guijarro on Medium]]></title>
        <description><![CDATA[Stories by Ramón Guijarro on Medium]]></description>
        <link>https://medium.com/@soyguijarro?source=rss-c1bdca83f267------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*OQvAqdlUukNQRbTR8ZL3Dg.png</url>
            <title>Stories by Ramón Guijarro on Medium</title>
            <link>https://medium.com/@soyguijarro?source=rss-c1bdca83f267------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 02:50:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@soyguijarro/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[Testing strategies for modern web applications]]></title>
            <link>https://medium.com/scopedev/testing-strategies-for-modern-web-applications-71836e480cc6?source=rss-c1bdca83f267------2</link>
            <guid isPermaLink="false">https://medium.com/p/71836e480cc6</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[static-code-analysis]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Ramón Guijarro]]></dc:creator>
            <pubDate>Fri, 21 Feb 2020 14:42:20 GMT</pubDate>
            <atom:updated>2020-02-21T14:44:21.277Z</atom:updated>
            <content:encoded><![CDATA[<h3>Testing Strategies for Modern Web Applications</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*EFwDH-ld8g1iwNkAKcQKtw.png" /></figure><h3>Why frontend testing matters</h3><p>It’s no secret that websites are nowadays more complex than ever. The last decade has seen a big shift on the web: as user expectations have changed with the rise of the smartphone, we’ve effectively transitioned from web pages mostly based on HTML and CSS to web applications driven by tons of JavaScript code. Unlike traditional document-based websites, current webapps have rich interfaces that support heavy user interaction, <a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Client-side_web_APIs/Fetching_data">async data fetching for partial content updates</a>, <a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Client-side_web_APIs/Client-side_storage">data caching</a> and even <a href="https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Offline_Service_workers">offline usage</a>.</p><p>If only because of this complexity, we should be testing our web applications to make sure that they behave as expected. As developers, we want to <a href="https://medium.com/scopedev/testing-in-the-cloud-native-era-41f63a0e101b">increase our confidence in the software we write</a>, and that’s what tests provide. But making sure our webapps work is even more important if we think about the fact that they’re the entry point to our products. It can even be argued that your webapp <strong>is</strong> your product since it’s the thing your users are actually using. When users think about your product, they think about your UI, and all they care about is accomplishing tasks through it. So how do we go about testing it?</p><h3>Interpreting the test pyramid</h3><p>From a conceptual standpoint, besides picking specific testing tools and technologies, one of the first questions that arise is at which level we need to be testing and how many tests of each kind we should be writing. The classic <a href="https://martinfowler.com/bliki/TestPyramid.html">test pyramid</a> quickly comes to mind as an answer, but let’s see how it applies to modern component-based web applications — the kind built with libraries like <a href="https://reactjs.org/">React</a> or <a href="https://vuejs.org/">Vue</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/0*43POxwpBWejylBAb.png" /><figcaption>Traditional testing pyramid, not practical for today’s applications (source: <a href="https://martinfowler.com/articles/practical-test-pyramid.html">https://martinfowler.com/articles/practical-test-pyramid.html</a>)</figcaption></figure><h4>The thin line between unit and integration</h4><p>Following the test pyramid will get us writing lots of unit tests, as those constitute its base. In our webapp context, they’re usually interpreted as testing a single component completely isolated from the rest of the tree, mocking out all of its dependencies and subcomponents. However, this kind of test doesn’t very accurately reflect how people will actually use our app.</p><p>That last statement is especially true for those who believe that a test that writes to the DOM or receives user input cannot be considered a unit test but an integration test, because there is <a href="https://en.wikipedia.org/wiki/Input/output">I/O</a> involved or <a href="https://en.wikipedia.org/wiki/Side_effect_%28computer_science%29">side effects</a> in general. But while you can call it an integration test all you want, it’s probably not the kind of integration test the pyramid is referring to, as it is not noticeably more expensive to run. And hence the advice of not writing as many of them arguably doesn’t apply.</p><p>The technologies used for unit and integration tests of components are in fact usually the same — typically, a test runner like <a href="https://jestjs.io/">Jest</a> that uses an emulated <a href="https://github.com/jsdom/jsdom">browser-like environment</a> under the hood — so sometimes the distinction between them only comes down to who you’re asking.</p><h4>End to end tests are fundamentally different</h4><p>On the other hand, end to end tests at the top of the pyramid much better reflect how users interact with the app. For web applications, these rely on tools that run your tests in an actual web browser, instead of an emulated DOM like the ones we just mentioned. This fact makes them conceptually different and forces you to test from the end user’s point of view. You can think of them as manual tests that are automated.</p><p>Historically, end to end tests have been slow, prone to flakiness, and hard to debug. However recent testing tools and frameworks, like <a href="https://www.cypress.io/">Cypress</a> or <a href="https://pptr.dev/">Puppeteer</a>, are improving all of these aspects to the point where some people are even advocating to invert the test pyramid altogether — something generally considered an antipattern — on the basis that we ought to be testing <strong>exactly</strong> what the user is experiencing.</p><p>I personally wouldn’t go as far as inverting the test pyramid, but what is definitely becoming clearer nowadays is that our webapps could benefit from raising the level at which you’d typically write tests; moving it above single isolated components. Let’s see why.</p><h3>The case for higher-level tests</h3><h4>Why classic unit testing doesn’t cut it</h4><p>Testing our components in isolation and mocking everything around them is not only a poor reflection of their real-world usage — hence not providing that much value in terms of confidence — but it almost inevitably leads to coupling our tests with their implementation details. This can get particularly bad with libraries such as<a href="https://airbnb.io/enzyme/"> Enzyme</a>, which lets developers select nodes based on component names, arbitrarily modify their internal state, and skip rendering of all children altogether with <a href="https://airbnb.io/enzyme/docs/api/shallow.html">shallow rendering</a>.</p><p>Under this approach, it’s common that making almost any change to a component will break its tests, even if its API stays the same. If end users or consumers of the component would not notice changes, why should tests fail? Also, fixing the tests will sometimes force you to basically rewrite them from scratch. This means that those tests will actually hinder your ability to refactor and will never be able to catch regressions. So what’s their value then?</p><h4>Integration tests to the rescue</h4><p>A lot of components in our applications are meant to be working in conjunction with others to form a larger component, a certain screen, or a feature. Features are what users care about and how we should measure confidence in our app. So instead of testing the individual components at the leaves of the tree — what would be usually referred to as unit testing them — look for the higher-level components that constitute true units in terms of features and test these without mocking its children. You will cover the real use case, the tests will take less effort to write and maintain, and you will be able to refactor all the subcomponents without breaking multiple tests.</p><p>To ensure that you’re testing the same way your users would use the app, it’s a good idea to rely on tools like <a href="https://testing-library.com/">Testing Library</a>, since it gives you utilities to query for nodes similarly to how users would find them. And because its queries are based on<a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques"> ARIA roles</a>, testing with it will force you to improve the accessibility of your app as a bonus.</p><p>This approach allows us to write tests that closely imitate real user interactions and are resilient to changes, just as end to end tests would do, which is exactly what we want. But they have the benefit of running much faster, since they’re not using a real browser.</p><h4>The role of end to end tests</h4><p>So if we can get a similar level of confidence with integration tests, what are end to end tests good for then? An excellent use for them in our context is <a href="https://en.wikipedia.org/wiki/Smoke_testing_%28software%29">smoke testing</a>. Build processes of modern webapps have many moving pieces and involve sophisticated tools like <a href="https://babeljs.io/">transpilers</a>, <a href="https://webpack.js.org/">bundlers</a> or <a href="https://developer.mozilla.org/en-US/docs/Glossary/Polyfill">polyfills</a>, with non-trivial configurations that are often different for development and production. That means that your production build could fail whilst the development one is working fine. So a simple test that opens your webapp in a browser and checks that it loads actually gives you quite some value for little investment.</p><p>Another use case for end to end tests is to cover the happy path of your most important user flows, exercising real APIs instead of having network requests mocked — either production ones, or in testing or staging environments. These tests might seem redundant, as well as more prone to exhibit flakiness since they hit real backend services, all on top of being slower. That’s why it’s advisable not to have a ton of them and maybe only run them before a deployment or as a nightly process. But they’re still relevant since they emulate the usage of your app in the most realistic way of all automated types of testing.</p><h3>Making responsible use of mocking</h3><p>We’ve discussed an approach to tests based on emulated DOM technology that tries to get as close as possible to the benefits of end to end browser-based tests, and we’ve seen how too much mocking goes against our goals in this area. But you will still need and want to mock some things in your non-browser tests. So let’s briefly discuss what to mock and how.</p><h4>Global mechanisms</h4><p>You usually won’t want to render your whole app, but at the same time, you’ll want whatever global mechanisms you have in place to be available in your tests. This way, you can confidently rely on those in your code knowing that your tests won’t fail. For example, if you’re using React you will probably have some top-level <a href="https://reactjs.org/docs/context.html#contextprovider">context providers</a>; it can be a good idea to write mocked versions of them and mount them in all your tests.</p><p>In a similar vein, you will want some functions used across your app to always be mocked. A typical example is date formatters: if you ever change the way you format dates in your app, you don’t want to have to modify assertions in every test under the sun. You can write unit tests for those functions to check that the formatting works as expected, and then have global mocks return a constant to ignore these in the rest of your tests. Testing frameworks like Jest allow you to <a href="https://jestjs.io/docs/en/manual-mocks">define global mocks once</a> for your own modules or third party dependencies. And you can always restore the original implementation for a particular test if you need to.</p><h4>Network requests</h4><p>You will also want to mock network requests in your integration tests to ensure that they run fast and are not flaky. You can do that in exactly the same way, as long as all your requests eventually go through the same module. The key is to always encapsulate core functionality like this in reusable modules and consistently rely on them. This will not only make testing easier but improve the architecture of your application, avoiding duplication and reducing the risk of diverging implementations and duplicated errors.</p><h4>Specific components</h4><p>Finally, there are legitimate reasons to mock components in a particular test, besides top-level or global ones. For example, you might want to have actual unit tests for some core components. That’s fine, but instead of using techniques like <a href="https://airbnb.io/enzyme/docs/api/shallow.html">shallow rendering</a> to completely prevent rendering all child components — which might unknowingly hide errors from you — explicitly mock only what you need. Again, Jest makes it easy with <a href="https://jestjs.io/docs/en/mock-functions#using-a-mock-function">mock functions</a>.</p><h3>Going beyond tests with static analysis</h3><p>The easiest tests to maintain are the ones that you don’t need to write. Static analysis tools can automatically catch a lot of bugs for us, effectively saving us from writing certain kinds of tests. These tests tend to be repetitive and cumbersome, so help is even more welcomed.</p><h4>Prevent common bugs</h4><p>A common source of bugs in modern web applications is the incorrect use of components by other consumers, like forgetting to set some mandatory property, or using a mismatching value for it — e.g., a string when a number is expected. This can be addressed with mechanisms like <a href="https://reactjs.org/docs/typechecking-with-proptypes.html">PropTypes in React</a>, but these only warn you in runtime during development, if the particular component happens to be mounted, and via the browser console — so you can miss the warning anyway. A better alternative is to declare types for properties and state of components with tools like <a href="http://typescriptlang.org/">TypeScript</a> or <a href="https://flow.org/">Flow</a>, that perform static checking of the types to ensure that these issues are all caught at build time. They will also support you while making changes in your components and allow you to refactor with greater confidence.</p><p>Another relevant source of bugs in JavaScript applications is null pointer errors, such as <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_access_property">cannot read property <em>x</em> of undefined</a> or <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_a_function"><em>x</em> is not a function</a>. Type checkers can also help prevent these errors, as they will for example statically check if a particular key that your code is trying to access actually exists in an object. They do this based on the <a href="https://www.typescriptlang.org/docs/handbook/interfaces.html">object shapes you declare</a>, and their value is multiplied thanks to <a href="https://www.typescriptlang.org/docs/handbook/type-inference.html">type inference</a> — so you don’t need to explicitly declare types all the time. Support for <a href="https://www.typescriptlang.org/docs/handbook/advanced-types.html#nullable-types">nullable types</a> completes the deal.</p><h4>Define safe data models</h4><p>We can leverage this ability to declare our own types to make our applications safer in some other ways. For example, we can write factory functions that receive data fetched from our backend APIs and process and sanitize it, returning objects safe to use in our components — what we’d call <a href="https://en.wikipedia.org/wiki/Data_model">models</a>. And we can define custom types for the shape of these models and export them to use as prop types of our components. This can help us gracefully handle mistakes in backend responses so that our UI doesn’t break, while still being able to log custom errors to a monitoring service like <a href="http://sentry.io/">Sentry</a> to be aware of the issues.</p><p>We can go even further down this road by using tools that automatically generate type definitions for our API responses. This allows us to use the generated types directly in our components without any extra work, providing a solid safety layer. Since <a href="https://graphql.org/">GraphQL</a> has a type system at its core, APIs based on it are particularly well-suited for this. Tools like <a href="https://graphql-code-generator.com/">GraphQL Code Generator</a> can generate TypeScript and Flow types from a GraphQL schema, and next-generation systems like <a href="https://www.prisma.io/with-graphql">Prisma</a> go one step further and generate them from the database itself.</p><h3>In conclusion</h3><p>Writing tests for our web frontend code is important because it’s the part of our product that our users will be directly interacting with. We want to simulate that interaction as faithfully as possible, so browser-based tests would be the way to go, but they’re too slow to use at scale. However, we can get pretty close with non-browser based tests if we write them at a high enough level, use selectors based on accessibility roles, and make sensible use of mocking. Adding a static type checker to the mix will further increase our confidence and prevent some common bugs.</p><p>So go ahead and write some tests for your webapp. Your users will unknowingly thank you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/174/0*suyXMYjgxQ315pyQ.png" /></figure><p><em>Testing is a core competency to build great software. But testing has failed to keep up with the fundamental shift in how we build applications. Scope gives engineering teams production-level visibility on </em><strong><em>every test</em></strong><em> for </em><strong><em>every app</em></strong><em> — spanning mobile, monoliths, and microservices.</em></p><p><strong><em>Your journey to better applications through better testing </em></strong><a href="https://scope.dev/?utm_source=medium"><strong><em>starts with Scope</em></strong></a><strong><em>.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71836e480cc6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/scopedev/testing-strategies-for-modern-web-applications-71836e480cc6">Testing strategies for modern web applications</a> was originally published in <a href="https://medium.com/scopedev">Scope</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A practical introduction to functional programming (JavaScript edition)]]></title>
            <link>https://medium.com/@soyguijarro/a-practical-introduction-to-functional-programming-javascript-edition-7718c3732b64?source=rss-c1bdca83f267------2</link>
            <guid isPermaLink="false">https://medium.com/p/7718c3732b64</guid>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Ramón Guijarro]]></dc:creator>
            <pubDate>Sun, 15 Jan 2017 21:02:00 GMT</pubDate>
            <atom:updated>2017-01-15T21:02:00.632Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A few months ago, I bumped into an excellent article titled </em><a href="https://maryrosecook.com/blog/post/a-practical-introduction-to-functional-programming"><em>A practical introduction to functional programming</em></a><em> by Mary Rose Cook. This article helped me greatly in understanding the principles behind functional programming, which I was starting to explore at the time. What you’re about to read here is an almost exact reproduction of that article, but with all code examples adapted from Python to JavaScript (ECMAScript 2015 or ES6).</em></p><p>Many functional programming articles teach abstract functional techniques. That is, composition, pipelining, higher order functions. This one is different. It shows examples of imperative, unfunctional code that people write every day and translates these examples to a functional style.</p><p>The first section of the article takes short, data transforming loops and translates them into functional maps and reduces. The second section takes longer loops, breaks them up into units and makes each unit functional. The third section takes a loop that is a long series of successive data transformations and decomposes it into a functional pipeline.</p><p>The examples are in JavaScript. A number of the examples eschew JavaScript conventions for the shake of illustrating functional concepts. This is an educational article after all, and the code presented here is by no means production-ready. Considerations about memory and performance should be made before taking functional approaches in not purely functional but multi-paradigm languages like JavaScript.</p><h3>A guide rope</h3><p>When people talk about functional programming, they mention a dizzying number of “functional” characteristics. They mention immutable data, first class functions and tail call optimisation. These are language features that aid functional programming. They mention mapping, reducing, pipelining, recursing, currying and the use of higher order functions. These are programming techniques used to write functional code. They mention parallelization, lazy evaluation and determinism. These are advantageous properties of functional programs.</p><p>Ignore all that. Functional code is characterised by one thing: the absence of side effects. It doesn’t rely on data outside the current function, and it doesn’t change data that exists outside the current function. Every other “functional” thing can be derived from this property. Use it as a guide rope as you learn.</p><p>This is an unfunctional function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/68177e43bad4aeb903319e377e04d4ff/href">https://medium.com/media/68177e43bad4aeb903319e377e04d4ff/href</a></iframe><p>This is a functional function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/12b08fae02aa273d928180e4687e717c/href">https://medium.com/media/12b08fae02aa273d928180e4687e717c/href</a></iframe><h3>Don’t iterate over lists. Use map and reduce.</h3><h4>Map</h4><p>Map takes a function and a collection of items. It makes a new, empty collection, runs the function on each item in the original collection and inserts each return value into the new collection. It returns the new collection.</p><p>This is a simple map that takes a list of names and returns a list of the lengths of those names:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8ea7bfcf00f25f919985efdfe92dcc3f/href">https://medium.com/media/8ea7bfcf00f25f919985efdfe92dcc3f/href</a></iframe><p>This is a map that squares every number in the passed collection:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/86757bcd2d455ac59a9d11d5da915990/href">https://medium.com/media/86757bcd2d455ac59a9d11d5da915990/href</a></iframe><p>This map doesn’t take a named function. It takes an anonymous, inlined function known as arrow function in JavaScript (sometimes referred to as lambda<em> </em>in a broader functional context). The parameters of the function are defined to the left of the arrow. The function body is defined to the right of the arrow. The result of running the function body is (implicitly) returned.</p><p>The unfunctional code below takes a list of real names and replaces them with randomly assigned code names.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a1b62a3e8132b5060354f0126a67af68/href">https://medium.com/media/a1b62a3e8132b5060354f0126a67af68/href</a></iframe><p>(As you can see, this algorithm can potentially assign the same secret code name to multiple secret agents. Hopefully, this won’t be a source of confusion during the secret mission.)</p><p>This can be rewritten as a map:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3f5d153374537f5c3304377d6446bb90/href">https://medium.com/media/3f5d153374537f5c3304377d6446bb90/href</a></iframe><blockquote><strong>Exercise 1.</strong> Try rewriting the code below as a map. It takes a list of real names and replaces them with code names produced using a more robust strategy.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d8dcb6b1267eabebcb0af6515ff5a38/href">https://medium.com/media/0d8dcb6b1267eabebcb0af6515ff5a38/href</a></iframe><blockquote>(Hopefully, the secret agents will have good memories and won’t forget each other’s secret code names during the secret mission.)</blockquote><blockquote>My solution:</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a04186308fc4106a2691fd3713dd75f/href">https://medium.com/media/2a04186308fc4106a2691fd3713dd75f/href</a></iframe><h4>Reduce</h4><p>Reduce takes a function and a collection of items. It returns a value that is created by combining the items.</p><p>This is a simple reduce. It returns the sum of all the items in the collection.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c146160ed92312f550377b94f4a7a3b/href">https://medium.com/media/8c146160ed92312f550377b94f4a7a3b/href</a></iframe><p>x is the current item being iterated over. a is the accumulator. It is the value returned by the execution of the lambda on the previous item. reduce() walks through the items. For each one, it runs the lambda on the current a and x and returns the result as the a of the next iteration.</p><p>What is a in the first iteration? There is no previous iteration result for it to pass along. reduce() uses the first item in the collection for a in the first iteration and starts iterating at the second item. That is, the first x is the second item.</p><p>This code counts how often the word ‘Sam’ appears in a list of strings:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/668ed6d811158dbb94fc138a22eefb26/href">https://medium.com/media/668ed6d811158dbb94fc138a22eefb26/href</a></iframe><p>This is the same code written as a reduce:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/19f91ecf9d04f21e2b7f1fb3d123b205/href">https://medium.com/media/19f91ecf9d04f21e2b7f1fb3d123b205/href</a></iframe><p>How does this code come up with its initial a? The starting point for the number of incidences of ‘Sam’ cannot be ‘Mary read a story to Sam and Isla.’ The initial accumulator is specified with the second argument to reduce(). This allows the use of a value of a different type from the items in the collection.</p><h4>Why are map and reduce better?</h4><p>First, they are often one-liners.</p><p>Second, the important parts of the iteration — the collection, the operation and the return value — are always in the same places in every map and reduce.</p><p>Third, the code in a loop may affect variables defined before it or code that runs after it. By convention, maps and reduces are functional.</p><p>Fourth, map and reduce are elemental operations. Every time a person reads a for loop, they have to work through the logic line by line. There are few structural regularities they can use to create a scaffolding on which to hang their understanding of the code. In contrast, map and reduce are at once building blocks that can be combined into complex algorithms, and elements that the code reader can instantly understand and abstract in their mind. “Ah, this code is transforming each item in this collection. It’s throwing some of the transformations away. It’s combining the remainder into a single output.”</p><p>Fifth, map and reduce have many friends that provide useful, tweaked versions of their basic behaviour. For example: filter, every, some and find.</p><blockquote><strong>Exercise 2.</strong> Try rewriting the code below using map, reduce and filter. Filter takes a function and returns a collection of every item for which the function returned true.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b364957c5d21d2e66e37ccff506a33ee/href">https://medium.com/media/b364957c5d21d2e66e37ccff506a33ee/href</a></iframe><blockquote>If this seems tricky, try not thinking about the operations on the data. Think of the states the data will go through, from the list of people dictionaries to the average height. Don’t try and bundle multiple transformations together. Put each on a separate line and assign the result to a descriptively-named variable. Once the code works, condense it.</blockquote><blockquote>My solution:</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/77fd00ec2092ac4c9e5646b85b4287e3/href">https://medium.com/media/77fd00ec2092ac4c9e5646b85b4287e3/href</a></iframe><h3>Write declaratively, not imperatively</h3><p>The program below runs a race between three cars. At each time step, each car may move forwards or it may stall. At each time step, the program prints out the paths of the cars so far. After five time steps, the race is over.</p><p>This is some sample output:</p><pre> -<br> --<br> --</pre><pre> --<br> --<br> ---</pre><pre> ---<br> --<br> ---</pre><pre> ----<br> ---<br> ----</pre><pre> ----<br> ----<br> -----</pre><p>This is the program:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a8a0c673881373b07879e8702929aec6/href">https://medium.com/media/a8a0c673881373b07879e8702929aec6/href</a></iframe><p>The code is written imperatively. A functional version would be declarative. It would describe what to do, rather than how to do it.</p><h3>Use functions</h3><p>A program can be made more declarative by bundling pieces of the code into functions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ab17a4d06bd670d1ad37d399b9580124/href">https://medium.com/media/ab17a4d06bd670d1ad37d399b9580124/href</a></iframe><p>To understand this program, the reader just reads the main loop. “If there is time left, run a step of the race and draw. Check the time again.” If the reader wants to understand more about what it means to run a step of the race, or draw, they can read the code in those functions.</p><p>There are no comments any more. The code describes itself.</p><p>Splitting code into functions is a great, low brain power way to make code more readable. This technique uses functions, but it uses them as sub-routines. They parcel up code. The code is not functional in the sense of the guide rope. The functions in the code use state that was not passed as arguments. They affect the code around them by changing external variables, rather than by returning values. To check what a function really does, the reader must read each line carefully. If they find an external variable, they must find its origin. They must see what other functions change that variable.</p><h3>Remove state</h3><p>This is a functional version of the car race code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b3de33ecdbe7d30e4556f2911f89b2ee/href">https://medium.com/media/b3de33ecdbe7d30e4556f2911f89b2ee/href</a></iframe><p>The code is still split into functions, but the functions are functional. There are three signs of this. First, there are no longer any shared variables. time and carPositions get passed straight into race(). Second, functions take parameters. Third, no variables are instantiated inside functions. All data changes are done with return values. race() recurses with the result of runStepOfRace(). Each time a step generates a new state, it is passed immediately into the next step.</p><p>Now, here are two functions, zero() and one():</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a6084bd560d71a19b65d0516b1deb22/href">https://medium.com/media/8a6084bd560d71a19b65d0516b1deb22/href</a></iframe><p>zero() takes a string, s. If the first character is &#39;0&#39;, it returns the rest of the string. If it is not, it returns null. one() does the same, but for a first character of &#39;1&#39;.</p><p>Imagine a function called ruleSequence(). It takes a string and a list of rule functions of the form of zero() and one(). It calls the first rule on the string. Unless null is returned, it takes the return value and calls the second rule on it. Unless null is returned, it takes the return value and calls the third rule on it. And so forth. If any rule returns null, ruleSequence() stops and returns null. Otherwise, it returns the return value of the final rule.</p><p>This is some sample input and output:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3e092b22244000036588eb95731831b/href">https://medium.com/media/e3e092b22244000036588eb95731831b/href</a></iframe><p>This is the imperative version of ruleSequence():</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc3837dca84651e9386418e143234309/href">https://medium.com/media/bc3837dca84651e9386418e143234309/href</a></iframe><blockquote><strong>Exercise 3.</strong> The code above uses a loop to do its work. Make it more declarative by rewriting it as a recursion.</blockquote><blockquote>My solution:</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/33b801855e45d9e90583ad74660e75a5/href">https://medium.com/media/33b801855e45d9e90583ad74660e75a5/href</a></iframe><h3>Use pipelines</h3><p>In the previous section, some imperative loops were rewritten as recursions that called out to auxiliary functions. In this section, a different type of imperative loop will be rewritten using a technique called pipelining.</p><p>The loop below performs transformations on dictionaries that hold the name, incorrect country of origin and active status of some bands.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c72a7d41a2802e811455804a9d107c54/href">https://medium.com/media/c72a7d41a2802e811455804a9d107c54/href</a></iframe><p>Worries are stirred by the name of the function. “format” is very vague. Upon closer inspection of the code, these worries begin to claw. Three things happen in the same loop. The value at the &#39;country&#39; key gets set to &#39;Canada&#39;. Punctuation is removed from the band name. The band name gets capitalized. It is hard to tell what the code is intended to do and hard to tell if it does what it appears to do. The code is hard to reuse, hard to test and hard to parallelize.</p><p>Compare it with this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dfee3c9a5bf1253e4cc6039de01d6fd1/href">https://medium.com/media/dfee3c9a5bf1253e4cc6039de01d6fd1/href</a></iframe><p>This code is easy to understand. It gives the impression that the auxiliary functions are functional because they seem to be chained together. The output from the previous one comprises the input to the next. If they are functional, they are easy to verify. They are also easy to reuse, easy to test and easy to parallelize.</p><p>The job of pipelineEach() is to pass the bands, one at a time, to a transformation function, like setCanadaAsCountry(). After the function has been applied to all the bands, pipelineEach() bundles up the transformed bands. Then, it passes each one to the next function.</p><p>Let’s look at the transformation functions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a24b6a5395b5344166570e433763b3f/href">https://medium.com/media/5a24b6a5395b5344166570e433763b3f/href</a></iframe><p>Each one associates a key on a band with a new value. There is no easy way to do this without mutating the original band. assoc() solves this problem by using Object.assign() to produce a copy of the passed dictionary. Each transformation function makes its modification to the copy and returns that copy.</p><p>Everything seems fine. Band dictionary originals are protected from mutation when a key is associated with a new value. But there are other potential mutations in the code above. In stripPunctuationFromName(), the unpunctuated name is generated by calling replace() on the original name. If replace() is not functional, stripPunctuationFromName() isn’t either.</p><p>Fortunately, replace() does not mutate the strings it operates on. This is because strings are immutable in JavaScript. When replace() operates on a band name string, the original band name is copied and replace() is called on the copy. Phew.</p><p>This contrast between the mutability of strings and dictionaries in JavaScript illustrates the appeal of languages like Clojure. The programmer need never think about whether they are mutating data. They aren’t.</p><blockquote><strong>Exercise 4.</strong> Try and write the pipelineEach function. Think about the order of operations. The bands in the array are passed, one band at a time, to the first transformation function. The bands in the resulting array are passed, one band at a time, to the second transformation function. And so forth.</blockquote><blockquote>My solution:</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/19a7303b34068651c675a65f4fbdd873/href">https://medium.com/media/19a7303b34068651c675a65f4fbdd873/href</a></iframe><p>All three transformation functions boil down to making a change to a particular field on the passed band. call() can be used to abstract that. It takes a function to apply and the key of the value to apply it to.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/557da54c8db8e7294a8e3602d29d97ce/href">https://medium.com/media/557da54c8db8e7294a8e3602d29d97ce/href</a></iframe><p>Or, if we are willing to sacrifice readability for conciseness, just:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b31a51b2e20ec6fe38805381f60f5189/href">https://medium.com/media/b31a51b2e20ec6fe38805381f60f5189/href</a></iframe><p>The code for call():</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4bb0e7fb79498c39c15310f1bb568cf5/href">https://medium.com/media/4bb0e7fb79498c39c15310f1bb568cf5/href</a></iframe><p>There is a lot going on here. Let’s take it piece by piece.</p><p>One. call() is a higher order function. A higher order function takes a function as an argument, or returns a function. Or, like call(), it does both.</p><p>Two. applyFn() looks very similar to the three transformation functions. It takes a record (a band). It looks up the value at record[key]. It calls fn on that value. It assigns the result back to a copy of the record. It returns the copy.</p><p>Three. call() does not do any actual work. applyFn(), when called, will do the work. In the example of using pipelineEach() above, one instance of applyFn() will set &#39;country&#39; to &#39;Canada&#39; on a passed band. Another instance will capitalize the name of a passed band.</p><p>Four. When an applyFn() instance is run, fn and key will not be in scope. They are neither arguments to applyFn(), nor locals inside it. But they will still be accessible. When a function is defined, it saves references to the variables it closes over: those that were defined in a scope outside the function and that are used inside the function. When the function is run and its code references a variable, JavaScript looks up the variable in the locals and in the arguments. If it doesn’t find it there, it looks in the saved references to closed over variables. This is where it will find fn and key.</p><p>Five. There is no mention of bands in the call() code. That is because call() could be used to generate pipeline functions for any program, regardless of topic. Functional programming is partly about building up a library of generic, reusable, composable functions.</p><p>Good job. Closures, higher order functions and variable scope all covered in the space of a few paragraphs. Have a nice glass of lemonade.</p><p>There is one more piece of band processing to do. That is to remove everything but the name and country. extractNameAndCountry() can pull that information out:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9aa8c7318e7f804ad4cb27106a3f1b9/href">https://medium.com/media/c9aa8c7318e7f804ad4cb27106a3f1b9/href</a></iframe><p>extractNameAndCountry() could have been written as a generic function called pluck(), which would be used like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/767982cb45219593818a0db2647cb7e4/href">https://medium.com/media/767982cb45219593818a0db2647cb7e4/href</a></iframe><blockquote><strong>Exercise 5.</strong> pluck() takes a list of keys to extract from each record. Try and write it. It will need to be a higher order function.</blockquote><blockquote>My solution:</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b845a9d8b405d14b473ecfa88636d409/href">https://medium.com/media/b845a9d8b405d14b473ecfa88636d409/href</a></iframe><h3>What now?</h3><p>Functional code co-exists very well with code written in other styles. The transformations in this article can be applied to any code base in any language. Try applying them to your own code.</p><p>Think of Mary, Isla and Sam. Turn iterations of lists into maps and reduces.</p><p>Think of the race. Break code into functions. Make those functions functional. Turn a loop that repeats a process into a recursion.</p><p>Think of the bands. Turn a sequence of operations into a pipeline.</p><p><em>Thanks to Mary Rose Cook for writing </em><a href="https://maryrosecook.com/blog/post/a-practical-introduction-to-functional-programming"><em>A practical introduction to functional programming</em></a><em>. The article has been reproduced and adapted here with permission of the author. Also thanks to </em><a href="https://twitter.com/tinproject"><em>Agustín</em></a><em> for his thorough review of the article and to </em><a href="https://twitter.com/alexguerrero_"><em>Álex</em></a><em>, </em><a href="http://twitter.com/jesgma"><em>Jesús</em></a><em>, </em><a href="http://twitter.com/gootyfer"><em>Israel</em></a><em> and </em><a href="http://twitter.com/sagaban"><em>Santiago</em></a><em> for reviewing the code examples.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7718c3732b64" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I came up with a smart color picker for the web]]></title>
            <link>https://medium.com/@soyguijarro/how-i-came-up-with-a-smart-color-picker-for-the-web-d7a5a942859b?source=rss-c1bdca83f267------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7a5a942859b</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[user-experience]]></category>
            <dc:creator><![CDATA[Ramón Guijarro]]></dc:creator>
            <pubDate>Tue, 29 Mar 2016 21:05:36 GMT</pubDate>
            <atom:updated>2017-01-05T14:56:09.398Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lBvZcbErYIhG6SRSRdgS9w.jpeg" /><figcaption>Photo by <a href="https://www.flickr.com/photos/curioustangles/15723043345/">Danna (Curious Tangles)</a></figcaption></figure><h4>A practical use for color image quantization in day to day user interfaces and the thought process behind it</h4><p>I work at <a href="http://www.guud.tv/">Guud</a>, a small software company that builds digital products to help brands and live events engage their social audience. Lately I’ve been busy working on a new exciting product. For this particular product, we needed to allow our customers to personalize some layouts by uploading custom logo and background images and choosing an accent color. The logo and background pickers were not a problem: a simple file uploader with image preview does the job. But coming up with an interface element for picking an accent color that was actually helpful to our users wasn’t that straightforward. Here’s the thought process that led me from stubbornly questioning the usefulness of the ubiquitous color picker to ultimately arriving at an unusual solution that is however simpler to use and better meets — or even anticipates — our clients’ needs.</p><h4>The not so obvious problem</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*NJ-g5O5XZx7ecMJoFzuKdA.png" /><figcaption>Not the most user-friendly thing in the world.</figcaption></figure><p>My first implementation of the accent color widget was, admittedly, very naive: I added a simple text field to the page with a little color preview box next to it, made sure only hexadecimal color values could be entered into the field and called it a day. I knew this was far from a nice user experience, but I couldn’t think of a truly better alternative at that moment. Of course adding a color picker crossed my mind at first, but I thought choosing from a sea of colors wouldn’t really be of any help to our users. Remember, they’re companies. They have established visual brand identities with official colors. They most probably want to use one of their specific colors, not some kind of similar shade they painstakingly eyeballed with the help of a picker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*H1kvYo6H4qmvIRJw4hdGdA.png" /><figcaption><a href="https://duckduckgo.com/?q=color+picker">DuckDuckGo’s color picker</a>. This might look more helpful, but for our users it really isn’t.</figcaption></figure><p>When I showed my naive accent color widget to my coworker <a href="https://twitter.com/pacunar">Pablo</a>, he was quick to suggest adding a color picker, but I was already convinced it was not the best idea for the above reasons. It would add a fair amount of complexity to the user interface but next to no value. However having to type hexadecimal or RGB numbers into a text box without any help is not exactly user-friendly either. Therefore I begrudgingly accepted that I’d have to add the color picker after all in order for the widget to at least <em>look</em> more user-friendly — even if it really wasn’t for our clients’ purposes. At the end of the day, with or without picker, we could only hope that whoever used the product would know or ask for his company’s exact color values.</p><h4>A fortunate realization</h4><p>I hate knowing something I made is not quite right, so while I moved on to other tasks I kept this issue in the back of my mind. One thing was clear to me: showing the user a limited number of colors to choose from rather than a full-blown color picker would be much desirable. It’d be less intimidating and much simpler to use than a regular color picker, a complex element by its very nature. Displaying a limited color palette and hiding the full-blown picker under some sort of plus button is in fact becoming more and more commonplace in user interfaces. But the main problem remained: no matter what colors I put in this palette, it’d still be useless for our users. Again, they don’t want to pick an accent color from a handful of random shades, but from their companies’ official colors. It was then when it struck me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*uUHr4ELm0mLR29WzjSebtg.png" /><figcaption><a href="https://www.gnome.org/gnome-3/">GNOME</a>’s color picker. These folks are championing user experience in the open source desktop area.</figcaption></figure><p>The best solution was of course to show our users a palette made up of the actual official colors of their companies, which — here comes the magic — the site would automatically extract from the custom logo they had uploaded. This idea didn’t come out of nowhere. I knew this was not only feasible but actually quite easy to implement thanks to my involvement in <a href="https://github.com/FilmViz/">FilmViz</a>, a web tool for automatic film analysis and visual comparison that, among other things, extracts a color palette from each frame of a video. If you’re curious about it, you can read more about FilmViz and how it came to be in this other story below.</p><p><a href="https://medium.com/p/6add1186fea1">My experience at h4ckademy</a></p><h4>The actual implementation</h4><p>A few lines of code were enough to implement this feature with the help of <a href="https://github.com/leeoniya/RgbQuant.js">RgbQuant</a>, the same JavaScript color quantization library we used in FilmViz. Because colors are usually employed with restraint when it comes to logos, the results of the quantization process are pretty impressive. Companies’ main colors show up every time in the extracted palettes. Other colors show up as well in a lot of cases, since logos tend to use up to four colors and the palette size is set to six. However I thought it’d be better to have those extra colors there to cover the odd case of a highly multicolored logo. Since they appear sorted from highest to lowest occurrence, the ones the user probably wants are shown first anyway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FXLODE8qVe2d6TGxYqqIEg.png" /><figcaption>Some color palettes generated with <a href="https://github.com/leeoniya/RgbQuant.js">RgbQuant</a> from a few open source projects’ logos.</figcaption></figure><blockquote>As a side note, let me point out that sorting the colors by hue and luminance would result in a gradual, more natural palette to the eye. However the ultimate aim of the widget is not to be aesthetically pleasing, but to be useful. Hence the most predominant colors are shown first. We tend to forget this sometimes when designing user interfaces.</blockquote><p>As for the actual user interface widget, I knew I wanted both the text field and the little color preview box to stay where they were; I didn’t want to prevent users from manually entering a color value if they wished so, and I wanted them to be able to see the currently selected color at all times. That made clear to me that, to avoid any confusion, the palette should only be on screen when needed and should go away as soon as the user picked a color. However I felt that using something like a modal window or a contextual popover was too much for an element as simple as a small row of color patches. I finally decided to show the color palette over the accent color text field, which was wide enough to fit it, and make it slide in and out from the right — where the color preview box is — with a nice staggered animation. This way it would attract the user’s attention without taking any extra space and would be unequivocally linked to the accent color text box.</p><h4>Devil is in the details</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*Ie_nrfWCRCqKPfR0f6rwHg.gif" /><figcaption>The final result.</figcaption></figure><p>What I had by now was a very good starting point, but a few significant tweaks were made both to the appearance and behavior of the picker until reaching the final result you see above these lines. I think these changes are worth mentioning, because they show how some small refinements can go a long way in improving the overall user experience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MDl_Idw6g-M09dRZag0k4Q.png" /><figcaption>All the stages the widget went through, from my first naive try to the end result.</figcaption></figure><p>First, I restyled the color preview box so that it looked more like an actual button. This improved the palette’s discoverability, as it made much more clear that clicking or tapping the color preview would show or hide the palette. Next, I made the palette show up automatically right after users selected a custom logo, which further improved discoverability as well as reduced the need for users’ input: if they just selected a logo, the next thing they probably want to do is to choose a matching accent color. I also made sure the palette would collapse when users clicked away from it; as I said before, it should only be shown when needed.</p><p>Then I moved the accent color widget below the logo picker, so that the placement of the elements in the page followed the intended order of use. This way the user would be encouraged to pick a logo first without the need for adding explicit directions to the page, which unfortunately a lot of users simply won’t read. This particular page was already a bit busy so avoiding any extra copy was a good thing for this reason as well.</p><p>Finally, I filtered out any light colors extracted from the logo up to a threshold before showing the palette to the user — you might have noticed this already in the open source logos’ image. The accent color is used in this product to highlight certain elements that sit on top of a white background, so it didn’t make sense to offer the users any colors that wouldn’t work with the background.</p><h4>A humble disclaimer</h4><p>I’m obviously not the first one to think about this. In fact, after coming up with the idea I found <a href="https://github.com/leeoniya/RgbQuant.js/issues/14#issue-72327884">an issue at RgbQuant’s GitHub</a> in which someone describes what seems to be the exact same thing. However I’ve rarely seen this kind of stuff in the wild and haven’t heard much discussion around the possibilities of color quantization for improving general purpose user interfaces, so I thought this story would be worth sharing. I also thought it could be valuable to explain the whole thought process that led to this solution and the rationale behind some of the decisions I took.</p><p>Let me finish with a brief statement about building products for the web. This story has been about color image quantization, but it could have been about anything else. The bottom line for me is that, whenever possible, we should strive to provide the best solution for our users, even if it’s not the most obvious or conventional one. The kind of stuff we can do today on the web is incredible. Let’s take advantage of it to the fullest.</p><p><em>Thanks to </em><a href="http://surreal.asturnazari.com/"><em>Carlos</em></a><em>, the mind behind FilmViz, because I would have never come up with this if I hadn’t worked on that project; to </em><a href="https://twitter.com/RoboePi"><em>Roboe</em></a><em>, for giving me valuable feedback on the design that truly helped improve it; to </em><a href="https://twitter.com/gootyfer"><em>Israel</em></a><em>, for his thorough review of this article; and to </em><a href="http://www.guud.tv/"><em>Guud</em></a><em>, for allowing me to work on pretty cool projects and being open to my ideas.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7a5a942859b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My experience at h4ckademy]]></title>
            <link>https://medium.com/@soyguijarro/my-experience-at-h4ckademy-6add1186fea1?source=rss-c1bdca83f267------2</link>
            <guid isPermaLink="false">https://medium.com/p/6add1186fea1</guid>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[experience]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Ramón Guijarro]]></dc:creator>
            <pubDate>Mon, 28 Sep 2015 16:27:11 GMT</pubDate>
            <atom:updated>2016-03-28T09:19:59.173Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<h4>An immersive nine-week code retreat for programmers told from the inside</h4><p>This past summer I was lucky enough to be part of <a href="http://www.h4ckademy.com/">h4ckademy</a>, an immersive learning experience for programmers. I spent nine weeks working on open source projects with like-minded fellows in a self-directed manner. It was awesome. Here’s a recap of my experience.</p><h4>Prior expectations</h4><p>While I approached the experience with an open mind, I had a few ideas of what I wanted to get out of it beforehand. First and foremost, I wanted to work in teams, learn from and collaborate with others. I also knew that I wanted to work on some sort of creative web project. On the technical side, I wanted to practice and improve my JavaScript skills, including learning some JavaScript framework, and dip my toes into data visualization. I’m happy to say that all these objectives were accomplished.</p><h4>What I worked on</h4><p>The first week we met the other participants, got to know each other and learned all about the projects proposed by the <a href="http://www.h4ckademy.com/partners.html">h4ckademy partners</a>. We had to choose one or more of these projects to work on, or we could also work on our own ideas. As most of us, I hesitated between a few of them, but finally decided to go with <a href="https://github.com/thewildboard">WildBoard</a>, an API-ready dashboard sponsored by <a href="https://dokify.net/">Dokify</a>. During the second week I did data modeling and testing in Node.js for this project. It was interesting to be involved in discussing the architecture for a product of this kind. I only have good words for <a href="https://twitter.com/joserobleda">Jose Ignacio Andrés</a>, Dokify’s CTO, who met with the team weekly to follow up on the project and was always at our complete disposal.</p><p>But then our fellow <a href="http://surreal.asturnazari.com/">Carlos Padial</a> came up with the idea for <a href="https://github.com/filmviz">FilmViz</a>, a tool for automatic film analysis and visual comparison that would work right in the web browser. I loved the idea so much, and was so intrigued by its technical feasibility, that I ended up devoting the rest of my time to it. It was also a perfect match to fulfill my learning objectives, since it allowed me to work on data visualization with D3.js and use a JavaScript framework like AngularJS. Working collaboratively also helped me improve my teamwork skills and step up my game with Git and Github.</p><h4>Things I liked</h4><p>What I liked the most about h4ckademy was its diversity. My colleagues ranged from teenagers to people in their late thirties, from engineers to artists, from Spaniards to Turks. We all shared a passion for programming, but each one of us brought different backgrounds and personalities to the table. This diverse, multidisciplinary environment allowed for more interesting exchanges of ideas and a richer experience than I expected. It helped me expand my vision about programming and learn about other related disciplines.</p><p>The same happened with all the workshops, talks and related activities we had. We learned AngularJS from <a href="https://twitter.com/carlosazaustre">Carlos Azaustre</a>, Ember from <a href="https://twitter.com/Serabe">Sergio Arbeo</a>, web scraping from <a href="https://twitter.com/lobomick">Miguel Moraleda</a>, Git from <a href="https://twitter.com/ajspadial">Antonio Padial</a>, open source projects management from <a href="https://twitter.com/xuanxu">Juanjo Bazán</a>, DevOps from <a href="https://www.ticketea.com/">Ticketea</a> or functional programming from <a href="https://twitter.com/dialelo">Alejandro Gómez</a> and <a href="https://twitter.com/jlgarhdez">Pepe García</a>. But we also got to chat with eclectic people like <a href="https://twitter.com/sergioeclectico">Sergio Galán</a>, heard about the basics of data visualization from <a href="https://twitter.com/DavidAlayon">David Alayón</a>, saw some cool stuff on urban spaces by Carmelo Rodríguez from <a href="https://twitter.com/PKMNmad">PKMN</a>, found out about new human-computer interaction devices from <a href="https://twitter.com/kokuma">Juan Alonso</a> or learned about Blender and algorithmic composition from our own <a href="http://surreal.asturnazari.com/">Carlos Padial</a>, <a href="https://twitter.com/RoboePi">Roboe (Roberto Martín)</a> and <a href="https://twitter.com/guardabrazo">Federico Guardabrazo</a>. We were encouraged to give talks to our colleagues and <a href="http://slides.com/soyguijarro/sass-talk">I did so</a> as well.</p><p>Another thing I particularly liked about the experience is that it didn’t end right after the demo day, when projects were presented to the community. We had three more weeks from then that allowed us to focus less on features and more on refining what we had already done. Our FilmViz app went through a major refactoring during this time. Refactoring sessions were held with members from other teams so that we could get external input. Some alumni from the first edition of h4ckademy came by as well, such as <a href="https://twitter.com/rubocoptero">Rubén Antón</a>, who helped us with the business logic and domain model, or <a href="https://twitter.com/alexguerrero_">Álex Guerrero</a>, who showed us how to integrate Gulp into our project. The h4ckademy facilitators gave a hand too: <a href="https://twitter.com/enriqueaf">Enrique Álvarez</a> helped us implement promises for our automatic film analyzer and <a href="https://twitter.com/Serabe">Sergio Arbeo</a> advised us on the performance impact of CSS selectors, among other things. Of course, <a href="https://twitter.com/gootyfer">Israel Gutiérrez</a> was always there, first to come and last to go, trying to make h4ckademy the best possible experience for us.</p><h4>Other activities</h4><p>Besides workshops, talks and coding, we also had a few mentoring sessions with some nice folks that came by to take a look at our projects, like <a href="https://twitter.com/amaiac">Amaia Castro</a>, <a href="https://twitter.com/chernando">Carlos Hernando</a> or <a href="https://twitter.com/salvadelapuente">Salva de la Puente</a>. They provided some interesting insights and suggestions, both technical and non-technical, as well as tons of encouragement. We also had a handful of very useful sessions with <a href="https://twitter.com/moquintana">Mónica Quintana</a>, who helped us develop our soft skills, build our digital identity and improve our employability overall. As part of this effort, <a href="https://twitter.com/a_materiaprima">Ana Carrascosa</a> and <a href="https://twitter.com/_mlorenzo">Marina Lorenzo</a> came by for a fun and very participative workshop about interpersonal communication. There were also weekly meetings on Fridays in order to talk about the progress of the projects, look back at the activities of the week and get input from us for future improvement.</p><p>As previously mentioned, an open source demo day was held at <a href="https://www.campus.co/madrid">Campus Madrid</a> so we could show our projects to the community. We also had one-to-one meetings with the <a href="http://www.h4ckademy.com/partners.html">h4ckademy partners</a> during the demo day, which <a href="http://www.h4ckademy.com/#code-stories">in some cases</a> led to landing a cool job. And we even got to present a few of our projects at <a href="https://madrid.techhub.com/events/techhubtuesday-demo-night-5">TechHub Demo Night</a>.</p><p>All in all, I honestly couldn’t have asked for more. I’ve become a better programmer, improved other important skills for my employability, made a few valuable contacts and met a lot of very interesting people. For free! The best of it all is that this doesn’t end here: h4ckademy is like a big supporting family. They’re all lovely people. Don’t miss the opportunity to meet them and <a href="http://www.h4ckademy.com/">apply for the next edition</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6add1186fea1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>