<?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 Hossam Mourad on Medium]]></title>
        <description><![CDATA[Stories by Hossam Mourad on Medium]]></description>
        <link>https://medium.com/@HMourad?source=rss-16395661d9e0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rlSZZErSbW2rHanUJrhF-A.png</url>
            <title>Stories by Hossam Mourad on Medium</title>
            <link>https://medium.com/@HMourad?source=rss-16395661d9e0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 18:55:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@HMourad/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[What I have learned about Deno so far]]></title>
            <link>https://medium.com/swlh/what-i-have-learned-about-deno-so-far-4ac84999cf1e?source=rss-16395661d9e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ac84999cf1e</guid>
            <category><![CDATA[deno]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Hossam Mourad]]></dc:creator>
            <pubDate>Mon, 01 Jun 2020 16:02:32 GMT</pubDate>
            <atom:updated>2020-06-08T21:58:59.175Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*fidnAi4pWjVyITCV.jpg" /></figure><p>I’m sure most of us by this time know what <a href="https://deno.land/">Deno</a> is. For those who don’t know it is a runtime for JavaScript and TypeScript. It is similar to Node.js but yet different, it is created by the same <a href="https://en.wikipedia.org/wiki/Ryan_Dahl">programmer</a> but it is not here to replace Node.js by any means disregarding how alike they may appear.</p><p>For the last couple of days I’ve been reading Deno’s documentation, reading blog posts and watching tutorials about Deno and in this post I will try to explain what I’ve learned so far about Deno and also my thoughts about some of its principles.</p><h3>1. It is secure by default</h3><p>In Deno, you have to grant your program permissions to perform certain tasks. For example if you have a program that will need network access, you have to run your program with the --allow-net flag or the program will fail. You can check out <a href="https://deno.land/manual/getting_started/permissions">this page</a> to know more about this.</p><p><strong>My thoughts</strong>: I like this feature. It is always a mysterious thing for me to know if a given program is accessing my disk or the network internally without my knowledge which left me cautious about using any third-party module especially in sensitive contexts. With this feature I can definitely tell what the program I’m running is accessing. This feature reminds me of the <a href="https://www.xda-developers.com/files/2014/06/style-typography15_large_xhdpi.png">permission prompt</a> we receive on mobile phones when an app is trying to access any of the device’s resources. I remember vividly deleting mobile phone applications immediately delete after opening them for the first time because they are trying to access a resource that I don’t find essential for the app to function normally.</p><h3>2. It doesn’t save external modules inside your project</h3><p>This is one of the most controversial features of Deno. In simple words you don’t install a third-party module or keep a packages file (like package.json in Node.js) inside your project. In Deno you import modules like the following:</p><pre>import { App } from &quot;https://deno.land/x/attain/mod.ts</pre><p>When you run your program for the first time, the module is downloaded and cached on your desk for future usage. And if you are worried about code editors support for that, I’ve tried the <a href="https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno">Deno VSCode extension</a> and it is working as what you would expect.</p><p><strong>My thoughts</strong>: I’m not sure if I like this feature or not. On one hand I don’t like how packages are handled currently in JavaScript with NPM. There are certain problems with the package.json and node_modules philosophy that needs its own post but I have always felt that it is an area with a lot of improvement room. On the other hand I&#39;m not sure how secure/reliable it is to fetch code from a link. I think this is one of the huge changes in the whole industry not only in Deno that we need to experiment with and monitor in production applications before we can label it with good or bad.</p><h3>3. Supports TypeScript out of the box</h3><p>You can start writing TypeScript code right away, no need to install ts-node or babel. Just use the .ts extension and Deno runtime will compile the file before running it. You can create .js files and Deno will run them right away.</p><p><strong>My thoughts</strong>: One thing to note here is that the file extension is essential in import statements. Because in Deno you can write.js or .ts modules, in imports statements you have to explicitly mention the file extension</p><p>This will work fine:</p><pre>import { assertEquals } from &quot;https://deno.land/std/testing/asserts.ts&quot;;</pre><p>But this will throw an error:</p><pre>import { assertEquals } from &quot;https://deno.land/std/testing/asserts&quot;;</pre><p>This is different from the situation in Node.js so I assume people will find this laborious initially.</p><h3>4. Has a built-in test runner</h3><p>There is a built-in testing runner already implemented in Deno’s namespace. It can be accessed from Deno.test. How does it look?</p><pre>import { assertEquals } from &quot;https://deno.land/std/testing/asserts.ts&quot;; Deno.test(&quot;hello world&quot;, () =&gt; { const x = 1 + 2; assertEquals(x, 3); });</pre><p><strong>My thoughts</strong>: I definitely like this feature. Not because the test runner is powerful or because it contains features that don’t exist in other test runners. I like it because it paves the way for standardization in the JavaScript realm. It has been always a problem in the JavaScript community that there is no standard for anything. There are tenths of libraries that do the same thing and all of them are popular. Adding a built-in test runner will -hopefully- make it the standard library to write tests in Deno and then all the efforts will -hopefully- go into improving it. I’m sure that it is not as powerful as any other test runner that Node.js has but with time I think it will be.</p><h3>5. It is browser-compatible</h3><p>Deno is trying to be as browser-compatible as possible, for example fetch and the global window object are built-in. Also, it supports top-level await.</p><p>This line will work fine:</p><p>without a need for calling an await function inside of an async function but that doesn’t work in all other cases. In this example you have to define the parent function as an async before using await:</p><pre>const addEntry = async ({ request }) =&gt; { const body = await request.body() }</pre><p>This example is using the <a href="https://deno.land/x/oak">Oak third part library</a></p><h3>6. Misc</h3><ul><li>Deno uses ES Modules, you can use import/export VS require in Node.js</li><li>It has <a href="https://deno.land/std">standard modules</a> and <a href="https://deno.land/x">third-party modules</a>. The standard modules are built by the core team of Deno are they are responsible for maintaining them. Another step towards standardization in the community.</li><li>Deno has the same letters as Node</li></ul><p><em>Originally published at </em><a href="https://hossammourad.com/learned-about-deno-so-far/"><em>https://hossammourad.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ac84999cf1e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/what-i-have-learned-about-deno-so-far-4ac84999cf1e">What I have learned about Deno so far</a> was originally published in <a href="https://medium.com/swlh">The Startup</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 run multiple queries at once using GraphQL’s Apollo Client]]></title>
            <link>https://levelup.gitconnected.com/how-to-run-multiple-queries-at-once-using-graphqls-apollo-client-c24bea52e079?source=rss-16395661d9e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/c24bea52e079</guid>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[apollo-client]]></category>
            <dc:creator><![CDATA[Hossam Mourad]]></dc:creator>
            <pubDate>Mon, 24 Jun 2019 12:42:34 GMT</pubDate>
            <atom:updated>2019-06-27T06:08:36.223Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to run multiple queries at once using GraphQL and Apollo Client</h3><p>There are scenarios where you want to run multiple queries at once. For example, you have a page consisting of two components, and each component’s data is derived from a separate query, but you want both of them to be executed and resolved before proceeding with the rendering. There are many ways to achieve this.</p><p>Here are the two queries we will start with. We will look at multiple solutions to execute and resolve them simultaneously.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*8MAJPgO5ul1OsfwxihvupQ.png" /></figure><h4>Solution 1: Define a combined query for both of them</h4><p>Define a combined query that will execute both of them with the shared variables set. This is a simple but unscalable solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LBi8fq8GZia5w0oPk5lLag.png" /></figure><p>And then you can use it with the &lt;Query&gt; component from react-apollo like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1xkw4uGcIYHyAbigy9OZ1g.png" /></figure><blockquote>Note: this will be done in one network call.</blockquote><p>While this works great with this example, it has two drawbacks:</p><ol><li>Since we’re re-using the same variables in both components, if the two queries don’t accept the same variables (or their type definitions), we can’t have multiple definitions for them. For example, one if the two queries is marking a variable as required and the second query doesn’t mark it as required, an error will be thrown in this case as the definitions are not matching.</li><li>It becomes messy easily when it grows and difficult to pass the data around</li></ol><h4>Solution 2: Using the compose utility from apollo-client</h4><p>from apollo-client documentation:</p><blockquote>For utility purposes, react-apollo exports a compose function. Using this function you may cleanly use several component enhancers at once. Including multiple <a href="https://www.apollographql.com/docs/react/api/react-apollo/#graphqlquery-configcomponent">graphql()</a>, <a href="https://www.apollographql.com/docs/react/api/react-apollo/#withapollocomponent">withApollo()</a>, or <a href="https://github.com/reduxjs/react-redux/blob/master/docs/api/connect.md">Redux </a><a href="https://github.com/reduxjs/react-redux/blob/master/docs/api/connect.md">connect()</a> enhancers. This should clean up your code when you use multiple enhancers. <a href="http://redux.js.org/">Redux</a> also exports a compose function, and so does <a href="https://github.com/acdlite/recompose">Recompose</a> so you may choose to use the function from whichever library feels most appropriate.</blockquote><blockquote>An important note is that compose() executes the first enhancer <em>first</em> and works its way forwards through the list of enhancers. In other words, calling three functions like this: funcA(funcB(funcC(component))) is equivalent to calling compose() like this: compose(funcC, funcB, funcA)(component).</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*5y26IVu1xxrsdJc-qK2LWQ.png" /></figure><p>Then the query and mutation will be available in the component props.</p><blockquote>Note: this will do a network call for each GraphQL operation.</blockquote><h4>Solution 3: Using the <a href="https://www.apollographql.com/docs/react/api/react-apollo/#withapollocomponent">withProvider</a> utility from apollo-client</h4><p>from apollo-client documentation:</p><blockquote>A simple enhancer which provides direct access to your <a href="https://www.apollographql.com/docs/react/api/apollo-client#apolloclient">ApolloClient</a> instance. This is useful if you want to do custom logic with Apollo. Such as calling one-off queries. By calling this function with the component you want to enhance, withApollo() will create a new component which passes in an instance of <a href="https://www.apollographql.com/docs/react/api/apollo-client#apolloclient">ApolloClient</a> as a client prop.</blockquote><p>Then you can execute the query like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vC5-oDBgVQktGuE3jed-gg.png" /></figure><h4>Solution 4: Using <a href="https://github.com/pedronauck/react-adopt">react-adopt</a></h4><p>Since the &lt;Query&gt; is a render prop utility from Apollo, react-adopt can be used to combine multiple render props. You can use it like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RSWktplnDuvurVoJCyUosg.png" /></figure><h4>Solution 5: using useQuery utility from react-apollo-hooks</h4><p>This solution might be not applicable for every app because it depends on React Hooks which is only available starting from React version 16.8.</p><p>You can use it like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bIn-rT7n_F5kYocX6gk7Ng.png" /></figure><p><a href="https://gitconnected.com/learn/graphql">Learn GraphQL - Best GraphQL Tutorials (2019) | gitconnected</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c24bea52e079" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/how-to-run-multiple-queries-at-once-using-graphqls-apollo-client-c24bea52e079">How to run multiple queries at once using GraphQL’s Apollo Client</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</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 Refactoring with the Product Owner]]></title>
            <link>https://medium.com/@HMourad/how-to-communicate-refactoring-with-the-product-owner-6ea68af0b637?source=rss-16395661d9e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ea68af0b637</guid>
            <category><![CDATA[martin-fowler]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[product-owner]]></category>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Hossam Mourad]]></dc:creator>
            <pubDate>Mon, 07 Jan 2019 11:13:22 GMT</pubDate>
            <atom:updated>2019-01-07T11:13:22.450Z</atom:updated>
            <content:encoded><![CDATA[<p>TLDR; you don’t, it’s part of your job as a software developer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*kQC8M4y_-vZ1OXSv_ooo9w.png" /><figcaption>Source: <a href="https://dzone.com/articles/what-is-refactoring">https://dzone.com/articles/what-is-refactoring</a></figcaption></figure><p>I’m currently reading <a href="https://martinfowler.com/articles/refactoring-2nd-ed.html">Refactoring 2nd Edition</a> by <a href="https://martinfowler.com/">Martin Fowler</a> which is gladly written in JavaScript, it’s an amazing book, you should go ahead and read it if you’ve been coding for more than 2 years.</p><p>Martin did a one hour webinar online at which he talked about his book, the ideas introduced in it and writing code in general. There was a Q/A section and one of the viewers asked that he finds it hard to communicate refactoring with his product owner and that he finds it challenging to explain to the product owner that this part of the code base needs refactoring before starting on a new feature.</p><p>Martin’s answers was brilliant and insightful, he said that refactoring shouldn’t be discussed with the product owner, it’s part of your job that you should do without discussing much about it. You -as a software developer- don’t go to the product owner and discuss with them that you’re going to use this design pattern not another one because you think it’s better in such and such; Refactoring falls in the same category, it is a practice that you do regularly that will make the codebase better and better over time. Writing new code should not be only about writing a new feature or a bug fix, you should always leave the code in a better shape than you’ve found it -aka refactor- as <a href="https://martinfowler.com/bliki/OpportunisticRefactoring.html">Martin always advise</a>.</p><p>I’m not saying that you should be ignorant about the fact that you should be transparent with your product owner and make them understand that your estimation is higher than usual because part of the effort will be refactoring the current code base before writing the new feature but you don’t have to justify it and not do it if the product owner doesn’t agree, it’s part of your job and you should do it and a good product owner will not fight against that.</p><p>The ideal pull request for me as a reviewer will be one that include a couple of refactoring commits before the actual feature/bug commits. It is a good idea to split your changes into separate commits so it will be easier for reviewers to check the changes in each commit, it becomes hard to review a PR where the feature and the refactoring code changes are grouped all together in one big commit, it becomes difficult to justify the code change and judge if it is required for the new feature or it is just for refactoring.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ea68af0b637" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>