<?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 Manuel Romero on Medium]]></title>
        <description><![CDATA[Stories by Manuel Romero on Medium]]></description>
        <link>https://medium.com/@mrm8488?source=rss-3f2bb9b4510b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_eOyq5lAgOVtQTc9jeH5IQ.jpeg</url>
            <title>Stories by Manuel Romero on Medium</title>
            <link>https://medium.com/@mrm8488?source=rss-3f2bb9b4510b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 20:04:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mrm8488/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[Using ES6 array destructing with Promises]]></title>
            <link>https://medium.com/@mrm8488/using-es6-array-destructors-with-promises-7a952a8581c3?source=rss-3f2bb9b4510b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a952a8581c3</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Manuel Romero]]></dc:creator>
            <pubDate>Mon, 06 Jun 2016 18:26:08 GMT</pubDate>
            <atom:updated>2017-10-10T21:56:19.124Z</atom:updated>
            <content:encoded><![CDATA[<p>As you know, some months ago, it was announced the new features of <em>ES6</em> or <em>EcmaScript2015</em>. In the beginning not all of them were implemented by some browsers or <em>Node.js</em>, but we had tools like <a href="https://babeljs.io/"><strong>Babel.js</strong></a> to allow us to program in <em>ES6</em> and then it would translate the code to<em> ES5</em>.</p><p>I am a <em>Node.js</em> developer and when I read the list of new features of ES6, there was one of them that could help me to continue fighting against <strong>callback hell</strong> and improve the <strong>readability of <em>Promises</em></strong>. In particular, the readability of <em>Promise.all()</em> that, as we know, launches an array of promises in parallel. This feature is <a href="https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Operadores/Destructuring_assignment"><strong>array destructing</strong></a>.</p><p>This is the way I worked with <em>Promise.all()</em> before using <em>ES6</em> array destructing:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/934c49c37816bdb215ac43b632200bee/href">https://medium.com/media/934c49c37816bdb215ac43b632200bee/href</a></iframe><p>In the code above, we have 3 promises that can be launched in parallel: the first is to get the user’s basic information. The second is to get the number of friends of the user and the last one to get the user’s skills.</p><p>As we can see, the variable that contains the result of the <em>Promise.all() </em>function is named <em>results</em>. Results is an array with so many positions as promises were sent as parameter to <em>Promise.all().</em> Moreover, the result of the first promise goes in the first position of the array, the result of the second promise goes in the second position and so on.</p><p>But what I did to improve readability was assigning each result (position) of the array to a new variable. Because access to results[n] is not meaningful.</p><p>Now, let’s see how it can be done directly with <em>ES6</em> array destructing:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa17117628f9ed60b452b26b6393fff9/href">https://medium.com/media/aa17117628f9ed60b452b26b6393fff9/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/43820dfb5948cfec6bd83efeee134aa6/href">https://medium.com/media/43820dfb5948cfec6bd83efeee134aa6/href</a></iframe><p>In the code above, I give a name for each position of the array. These names are the variables that we can manage in the callback. This way we save code and the most important thing, we write readable code easy to understand and easy to maintain.</p><p><em>PS: The two snippets in this post were tested under Node v6.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a952a8581c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Use Mongoose with Promises]]></title>
            <link>https://medium.com/@mrm8488/use-mongoose-with-promises-dfb1396bea89?source=rss-3f2bb9b4510b------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfb1396bea89</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[promises]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Manuel Romero]]></dc:creator>
            <pubDate>Wed, 23 Dec 2015 11:05:14 GMT</pubDate>
            <atom:updated>2015-12-23T11:48:36.635Z</atom:updated>
            <content:encoded><![CDATA[<p>I have been working with <a href="https://nodejs.org/"><em>Node.js</em></a> for more than 2 years and one of the first things you learn since the beginning is that callbacks sucks. Callbacks are the consequence of asynchronous operations. And when we nest several of them (we usually need to do it), we fall in the problem known as <strong><em>callback hell</em></strong>. It means the code becomes less readable, harder to maintain and even less efficient.</p><p>In this post, we are going to see how to use <strong>promises</strong> with <a href="http://mongoosejs.com/"><em>Mongoose</em></a><em> </em>to<em> </em>avoid callbacks<em>. Mogoose</em> is an important <em>ODM</em> that allows us to use <a href="https://www.mongodb.com/"><em>MongoDB</em></a> in <em>Node.js. The problem is,</em> the most of the examples I found on the web use callback style. Let’s see the following example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bf3c2a7e9e71acf0e7be79c2729fff85/href">https://medium.com/media/bf3c2a7e9e71acf0e7be79c2729fff85/href</a></iframe><p>We have defined the simplest schema to store users. Now, let’s do some queries:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1eb0b2e5b45a5960bd077cd44560173/href">https://medium.com/media/f1eb0b2e5b45a5960bd077cd44560173/href</a></iframe><p>Easy, right?</p><p>Now, let’s say we want to find a user to ban it. We could do it in just one operation with the method <em>update</em> in the model, but that way we will not see how good promises are. So, let’s do it in 2 steps:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1511dc5b2852120a5361e1f66937c432/href">https://medium.com/media/1511dc5b2852120a5361e1f66937c432/href</a></iframe><p>To start, we can see the variable <em>error i</em>n the 2 callbacks, what means that we loose the value of the first one in the second callback. We could solve it renaming the variables with something like: <em>error1</em> and <em>error2, </em>but this is not elegant. And, what happen if we have more nested callbacks? Let’s imagine the next scenario:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7846466dbb43af09647328e27d8fa25f/href">https://medium.com/media/7846466dbb43af09647328e27d8fa25f/href</a></iframe><p>Yes, we get a <em>callback hell</em> case! Now, it comes the main reason of this post: using <em>Mogoose</em> with promises. We are going to add to our schema the next statics methods (where we will use promises):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7efbef4b5fe025910f75efde415c1559/href">https://medium.com/media/7efbef4b5fe025910f75efde415c1559/href</a></iframe><p>Now we can do something like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e08a21ceaea9c4aeada51eaef79e4970/href">https://medium.com/media/e08a21ceaea9c4aeada51eaef79e4970/href</a></iframe><p>In the code above, we create the first query and we chain the rest via promises. If any promise in the chain gets an error, the flow automatically goes to the <em>catch</em> function.</p><p>Of course, for using promises with Monogoose is not necessary to define them as static methods in the schema definition, but for me, this way is pretty clear and useful.</p><p>We can also execute promises in parallel if there is no dependency among them. For example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/adc5b017fde8ab95a44f03c2bb5ee96a/href">https://medium.com/media/adc5b017fde8ab95a44f03c2bb5ee96a/href</a></iframe><blockquote>As result, our final code is much more <strong>readable</strong>, <strong>maintainable</strong> and <strong>elegant</strong> (even more <strong>efficient</strong> in certain cases where callback hell can produce memory leaks).</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfb1396bea89" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BIG DATA PARA DUMMIES]]></title>
            <link>https://medium.com/@mrm8488/big-data-para-dummies-c37aa3b67f55?source=rss-3f2bb9b4510b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c37aa3b67f55</guid>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[spanish]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Manuel Romero]]></dc:creator>
            <pubDate>Sat, 21 Nov 2015 16:26:35 GMT</pubDate>
            <atom:updated>2015-11-21T16:33:55.206Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mXqkYqJKpXPHkoi8geGVLA.jpeg" /></figure><blockquote>Muchas son las descripciones técnicas que podemos encontrar en la web si googleamos &quot;big data&quot;. Sin embargo, poco valor o conocimiento aportan a los que no están metidos de lleno o tienen conocimientos técnicos acerca del tema.</blockquote><p>Big data es el día a día de los que utilizamos dispositivos conectados a Internet. Nuestro smartphone, tablet, pc, smartwatch, televisión, frigorífico inteligente, coche (en un futuro cercano), etc están continuamente interaccionando con la red de redes para resolver los problemas y necesidades que el hombre presenta en su día a día.<br>Por ejemplo, a diario: consultamos las noticias de actualidad de nuestra localidad, las del país, el predicción meteorológica en casa y en el trabajo, el tráfico hasta nuestro destino, el precio de aquellos artículos que nos interesan, el estado en las redes sociales de nuestros amigos, el valor del combustible en las gasolineras cercanas, cuánto cuesta la docena de huevos en los supermercados de alrededor, las características de los coches que anuncia la tv, las últimas declaraciones del entrenador de nuestro equipo de fútbol, las ofertas de trabajo en nuestro sector, nuestro próximo destino de vacaciones y un largo etcétera de intereses, inquietudes y necesidades.</p><blockquote>Esto significa que todos y cada uno de los 365 días del año generamos una cantidad ingente de datos con nuestras interacciones directas en indirectas con Internet.</blockquote><p>De ahí se deriva la inminente necesidad de sistemas de almacenamiento y procesamiento de esa vasta cantidad de información para hacerla fructífera, productiva, útil.</p><p>Como solución a este reto nace el concepto de Big Data, que no son más que ese conjunto de herramientas para lidiar con este nuevo paradigma. Y sí, digo nuevo porque tiempo atrás la información que proporcionábamos a Internet era nimia comparada con la de hoy día. Tampoco la computación estaba dotada de la capacidad de almacenamiento y procesamiento de hoy día. Al menos a precios razonables.</p><blockquote>El Big Data supone para las empresas del sector tecnológico una oportunidad única de analizar los datos generados por el usuario para proporcionar soluciones personalizadas completamente a sus necesidades. Para aprender de él y predecir en todo momento qué necesita, cuándo y cómo.</blockquote><p>En este sentido, nuestro frigorífico sería capaz de ordenar yogures de la marca que nos gusta a la tienda más barata cuando se estén agotando sus existencias. De no haber existencias decidirá si los compra en otra tienda algo más cara o pide otro producto similar que no nos desagrada. Nuestro móvil nos ofrecerá plan para el fin de semana en función de lo que nos apetezca o determine que nos puede apetecer. Y dentro de ese plan estará todo calculado: horarios, tráfico, precio, parking, cena, nivel de recomendación de la película en función a nuestros gustos (si es que hemos decidido ir al cine). El pc de una tienda hará automáticamente el pedido de los artículos necesarios para el próximo mes al proveedor adecuado. El coche tomará la ruta más corta hacia nuestro destino, decidirá cuándo repostar y qué opción tomar según el tráfico en tiempo real. Nuestro gestor de correo será capaz de responder a correos de forma autónoma. Nuestro dormitorio ajustará la temperatura e iluminación según buscando el mayor confort. Nuestro asistente virtual nos recomendará una dieta y nos dirá cuando hemos ingerido las calorías necesarias, nos recomendará ropa, corte de pelo, vehículo, locales, etc.<br>Por oro lado y pensando a mayor escala, se podrán crear patrones de comportamiento de delincuentes, asesinos, etc y alertar en tiempo real del riesgo de actuación de ellos.</p><p>Las posibilidades que ofrece son ese estudio matemático de los datos son muchas y muy variadas.</p><p>Parece salido de una película de ciencia ficción, pero nada más lejos de la realidad.</p><p>Es el momento de especializarnos en Big data y crear una sociedad mejor basándonos en el estudio de su comportamiento.</p><blockquote>PS: Mi profesora de Lengua y Literatura decía: “sólo puedes decir que controlas un tema si eres capaz de explicárselo hasta a tu abuela”.</blockquote><p>Autor : Manuel Romero Muñoz.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c37aa3b67f55" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>