<?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 Samim Yaquby on Medium]]></title>
        <description><![CDATA[Stories by Samim Yaquby on Medium]]></description>
        <link>https://medium.com/@samimyaquby?source=rss-e943b57ad9b8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*PdRl4yZoWaqmiTL4.</url>
            <title>Stories by Samim Yaquby on Medium</title>
            <link>https://medium.com/@samimyaquby?source=rss-e943b57ad9b8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 14:51:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@samimyaquby/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[Being Authentic]]></title>
            <link>https://samimyaquby.medium.com/being-authentic-94fca7f0d066?source=rss-e943b57ad9b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/94fca7f0d066</guid>
            <dc:creator><![CDATA[Samim Yaquby]]></dc:creator>
            <pubDate>Sun, 02 Mar 2025 21:05:15 GMT</pubDate>
            <atom:updated>2025-03-02T21:06:47.671Z</atom:updated>
            <content:encoded><![CDATA[<p>Being authentic means being the first to see what everyone else sees, but from a different angle.</p><p>I was riding the 7 train from Queens into Manhattan. From my walk to the station, waiting on the platform, and finally boarding the train, I realized that art is everywhere. Within that short stretch, I saw art in shop windows, signs on Shake Shack, and at the storefront of bodegas. Each sticker, sign, and printed note represents someone’s creative effort. Some were quickly made, others meticulously crafted, and a few even carried the quiet hope of becoming someone’s breakthrough.</p><p>Yet, we rarely notice most of this art. Like the nose between our eyes — always present but seldom acknowledged — our minds filter it out, blending it into the backdrop of daily life.</p><p>Occasionally, though, a piece grabs our attention. It might even stick with us forever. Often, these memorable works have a striking element, something unexpected or shocking. But what truly makes creative work unforgettable? What separates a good joke from a great one, a pleasant melody from a timeless song, or an ordinary video from one that gets millions of views?</p><p>I believe it comes down to one of three essential elements, none of which are easy to achieve: cult value, exhibition value, and relatability. Cult value requires relentless networking and building a passionate community; exhibition value emerges from deep knowledge and a keen sense of what deserves to be displayed and admired; and relatability — my favorite — is the purest form. It is the artist saying: “You see that thing we pass by every day? Let me show you what it looks like from my point of view.”</p><p>Authenticity is about revealing familiar sights through fresh eyes.</p><p>“Boston, as the Eagle and the Wild Goose See It” by James Wallace Black. This photograph offered perhaps the first authentic bird’s-eye view of Boston. It doesn’t look like much, recent birds eye view shots of Boston are way more detailed and perhaps “better” than this. But, imagine how this was received back then. It was authentic and first of its kind. Everything after this was just another Ariel photograph of Boston — with more pixels per inch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xMhJQRt1vMZZH7TrTdMkzw.jpeg" /></figure><p>Again, being authentic means being the first to see what everyone else sees, but from a different angle.</p><p><a href="https://www.youtube.com/watch?v=3GufbJUQlFI">https://www.youtube.com/watch?v=3GufbJUQlFI</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94fca7f0d066" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basket Cases]]></title>
            <link>https://samimyaquby.medium.com/basket-cases-31be0dd7579c?source=rss-e943b57ad9b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/31be0dd7579c</guid>
            <category><![CDATA[thoughts-and-feelings]]></category>
            <category><![CDATA[food-and-drink]]></category>
            <category><![CDATA[philosophy]]></category>
            <dc:creator><![CDATA[Samim Yaquby]]></dc:creator>
            <pubDate>Sat, 04 Jan 2025 19:41:34 GMT</pubDate>
            <atom:updated>2025-01-04T19:41:34.353Z</atom:updated>
            <content:encoded><![CDATA[<p>There was a boy who, when he learned to think, learned that there were three colors. He loved those three colors until he learned that there was yellow, blue, and purple as well. He was about to settle down with these colors, and then he learned that there was orange, beige, crimson, and that there were thousands of other colors. Not only colors — there were alphabets, numbers, and people. People in the past and present. People had names, and they had done things that shaped the present.</p><p>He learned that there wasn’t enough space in his head to understand them all, so he started grouping things into buckets. He would label the buckets and categorize them, he would learn to define the categories and make associations. Then he would put these buckets into larger buckets, going on and on. He never learned anything deep enough. He tried — he spent years on some of these buckets — but he never understood them well enough.</p><p>The truth is that I am like him. I have always categorized music, food, people, books, places, ethnicities, races, and I have never understood them well enough. I don’t have the time, and I never will. Knowledge is infinite, and my time here is finite.</p><p>I, the person who I spend most of my time with, don’t understand myself enough, let alone others. There are some things that I deeply resent, and there are things that I can’t get enough of. I am sure I have been loving the wrong things and hating the wrong buckets.</p><p>But there is one definition that I have put for the bucket of the entirety of life: that there could be an infinite amount of definitions that could live in parallel. They can flow together, and eventually they will all blend into a different form which has its own infinity of explanations.</p><p>At the end, we can only group them into something general enough so that our finite brain cells can understand. And it’s okay if others categorize us into buckets with half-ass definitions. We are all baskets. Buckets. Cases. Basket cases.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Ffi7EaX3FEP8%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dfi7EaX3FEP8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Ffi7EaX3FEP8%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/13e4213c743734ffa8cab48a65a536e9/href">https://medium.com/media/13e4213c743734ffa8cab48a65a536e9/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31be0dd7579c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[@tanstack/react-query Common Issues and Solutions Series]]></title>
            <link>https://samimyaquby.medium.com/tanstack-react-query-common-issues-and-solutions-series-issue-1-141a47911939?source=rss-e943b57ad9b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/141a47911939</guid>
            <dc:creator><![CDATA[Samim Yaquby]]></dc:creator>
            <pubDate>Fri, 18 Oct 2024 17:27:28 GMT</pubDate>
            <atom:updated>2024-10-18T17:35:08.052Z</atom:updated>
            <content:encoded><![CDATA[<h3>Handling Duplicate Data When Manually Updating the Cache in Infinite Queries</h3><p>When working with paginated data using TanStack/React Query’s useInfiniteQuery, you might encounter a situation where you need to manually update the cache to include new data without re-fetching all previous pages. A common example is adding a new comment to a comments list without re-fetching the entire comments thread.</p><p>This manual cache update can lead to duplicates when the same data is eventually fetched again during pagination, resulting in duplicate items in your UI and React warnings about duplicate keys.</p><h3>Scenario</h3><p>You have a comments section that:</p><ul><li>Fetches comments using useInfiniteQuery with pagination.</li><li>Allows users to add new comments.</li><li>Manually updates the cache to include new comments without refetching all pages.</li><li>Displays comments in a scrollable area that loads more comments as the user scrolls.</li></ul><pre>// Fetch comments with pagination<br>const { data, fetchNextPage, hasNextPage } = useInfiniteQuery({<br>  queryKey: [&#39;comments&#39;, postId],<br>  queryFn: fetchComments,<br>  getNextPageParam: (lastPage) =&gt; lastPage.nextPage,<br>});<br><br>// Manually update cache when a new comment is added<br>const addCommentToCache = (newComment) =&gt; {<br>  queryClient.setQueryData([&#39;comments&#39;, postId], (oldData) =&gt; {<br>    if (!oldData) return;<br>    const lastPage = oldData.pages[oldData.pages.length - 1];<br>    lastPage.comments.push(newComment);<br>    return { ...oldData };<br>  });<br>};<br><br>// Add a new comment<br>const handleAddComment = async (commentText) =&gt; {<br>  const newComment = await addCommentToServer(commentText);<br>  addCommentToCache(newComment);<br>};</pre><p><strong>Problem Occurs When:</strong></p><ol><li>A user adds a new comment, which is manually added to the last page in the cache.</li><li>The user scrolls to load more comments, triggering fetchNextPage().</li><li>The newly added comment is fetched again from the server and added to a new page.</li><li>The same comment now exists in multiple pages, leading to duplicates in the UI and React warnings about duplicate keys.</li></ol><h3>Why Does This Issue Happen?</h3><p>When manually updating the cache to include new data:</p><ul><li><strong>Manual Addition:</strong> The new comment is added to the cache manually to avoid refetching all paginated data.</li><li><strong>Server Fetching:</strong> When fetching more data during pagination, the server returns the same new comment because it now exists in the database.</li><li><strong>Duplication:</strong> This results in the same comment appearing in both the manually updated cache and the newly fetched data.</li><li><strong>Duplicate Components and Keys:</strong> You don’t want your user to see their comment twice when they are scrolling through the comments section. And you don’t want duplicate keys for your react components. You may not have the comment ids as keys, but its likely that as you write your comments, you may realize that using comment ids as keys is probably the best way to assign keys. And since React requires that each item in a list rendered with .map() has a unique key prop. Duplicate comments with the same id lead to duplicate key values, causing React to warn about duplicates and potentially leading to rendering issues.</li></ul><h3>How to Solve It?</h3><h3>Solution: Deduplicate Data Before Rendering</h3><p>To prevent duplicates, you need to ensure that each comment appears only once in your UI, even if it exists in multiple pages of your cached data. You can achieve this by deduplicating the merged comments before rendering them.</p><p><strong>Step-by-Step Guide:</strong></p><ol><li><strong>Merge All Pages into a Single Array:</strong></li></ol><p>Combine all pages of comments into one array using flatMap().</p><pre>const mergedComments = data?.pages.flatMap((page) =&gt; page.comments) || [];</pre><p><strong>2. Deduplicate Comments Based on a Unique Identifier:</strong></p><p>Use a Map or an object to remove duplicates based on the commentId.</p><pre>const uniqueComments = Array.from(<br>  mergedComments.reduce((map, comment) =&gt; {<br>    map.set(comment.commentId, comment);<br>    return map;<br>  }, new Map()).values()<br>);</pre><p><strong>3. Render the Unique Comments:</strong></p><p>Use the uniqueComments array to render your comments list.</p><pre>return (<br>  &lt;div&gt;<br>    {uniqueComments.map((comment) =&gt; (<br>      &lt;Comment key={comment.commentId} data={comment} /&gt;<br>    ))}<br>  &lt;/div&gt;<br>);</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=141a47911939" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Black-Box Test Techniques — Software]]></title>
            <link>https://samimyaquby.medium.com/black-box-test-techniques-software-3205d43d1f61?source=rss-e943b57ad9b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/3205d43d1f61</guid>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[black-box-testing]]></category>
            <category><![CDATA[quality-assurance]]></category>
            <category><![CDATA[istqb]]></category>
            <category><![CDATA[test-technique]]></category>
            <dc:creator><![CDATA[Samim Yaquby]]></dc:creator>
            <pubDate>Mon, 20 Apr 2020 16:17:48 GMT</pubDate>
            <atom:updated>2020-04-20T16:17:48.443Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*corotgICJFKY3bWyjYuPHQ.jpeg" /></figure><h3>Black-Box Test Techniques — Software</h3><p>There are three general test technique categories outlined by the International Software Testing Qualification Board(ISTQB), white-box test techniques, black-box test techniques, and experienced-based test techniques. Here we focus on the black-box test techniques.</p><p>The main idea behind black-box test techniques is that you test a software feature without seeing its code. <strong>Test cases are driven directly from the specification or other models that specify what the system should do. </strong>It is an analysis of the outputs based on the inputs, not the inner workings of the system.</p><h3>Equivalence Partitioning</h3><p>It is one of the black-box techniques. We can partition both our inputs and outputs.</p><h4>Input Partitions</h4><p><strong>Valid inputs partition:</strong></p><p>One of the seven testing principles is that exhaustive testing is not possible. For example, in a calculator app, one feature of a calculator app is that it takes positive, negative, and floating point numbers. To test this feature we cannot input all the positive, negative, and floating point numbers that are out there. All we have to test here is one number from every group or <em>partition</em>, to see if our app meets the specification. Any one positive number, a negative number, and a floating point number.</p><p><strong>Invalid inputs partition:</strong></p><p>For our example’s sake let’s assume that beside the input field there is a separate field for operators, so our input field only takes numbers. The partitions we identified above were all the valid inputs that the app should/could accept. For the invalid partition, however, we pass values that the app is not supposed to accept. For example, on a keyboard, besides the numbers we have two more categories of keys — the alphabets and the special characters. We pass one value from each of these groups/partitions and test if our calculator meets the specification by rejecting them as an input.</p><h4>Output Partitions</h4><p>Just as we can test the valid and invalid inputs in our program, we can also partition our expected output values in the same manner and test our application.</p><h3>Boundary Value Analysis</h3><p>One of the common mistakes with loops in code is that our loops end up off by one repetition. It is usually because logical operators operate on the boundary values. We know that errors cluster around these values.</p><p>For example, let’s assume our calculator app has only 9 digit screen space for output, if the output is greater than eight digits, the last digit of our calculator should display a “-”, representing that there are other hidden digits to the number. And if it is shorter than 9 digits it should not display a “-” and istead should display the complete number. If it is equal to 9 digits it should display the complete number. As you can see it can get tricky around the number 9 and this is exactly why errors cluster around boundaries. Testing for these boundary values is a must in situations like this.</p><p>The rule for boundary values is to test values as close to the boundary as possible. In the example above we will test for an 8 digit output, a 9 digit output, and a 10 digit output.</p><h3>Decision Table Testing</h3><p>Product specifications often contain business rules that then define system functions. The same rules may also specify conditions under which each function operates. It is important to assure ourselves that every combination of these conditions are tested.</p><p>The formula for having the total number of possible conditions is the number of states raised to the number of conditions. For example if we have three conditions each having two states, true and false, we get 2³. Look at the following example, we assume a cash transferring feature that has three conditions and each of those conditions could be either true or false at a time. Following are the eight different cases and decisions based on their combinations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*6z5pPIQxDKu1ZwrdHqtBZA.png" /><figcaption>An example of a decision table for a cash transfer feature of an app.</figcaption></figure><h3>State Transition Diagram</h3><p>Decision table was possible when conditions had fixed values. For example, in the table above each condition could either be true or false, it could only have either of the two <em>states </em>as an input at a time.</p><p>In scenarios where conditions (state) keep changing and the application has to behave accordingly, we utilize a state transition diagram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*WjP-IRrjl7hFI9J5QXU1iQ.png" /><figcaption>An example of a state transition diagram for an ATM account access feature.</figcaption></figure><p>In the diagram above the state of our ATM usage process changes. After the card is inserted, on the first try the system has to decide based on a correct or an incorrect pin and an accumulation of one try. On the second try, the system’s state changes, now it has to decide based on a correct or an incorrect pin, and an accumulation of two tries. For the last one, a correct or an incorrect try and one last try before the ATM eats the card. The orange boxes show the changing states of the system.</p><h3>Use Case Testing</h3><p>Use case captures the individual interaction between the user and the system. A user could be a particular type of user and the use case captures the interactions that each user takes part in to produce some output that is of value.</p><p>For example, an admin account holder uploads documents to a portal and a user account holder should be able to read or download those documents. We can test both use cases by developing test cases. Test cases could be based on any of the other techniques we have used. That is: we prioritize, test typical examples, then attempt some in correct process flows, exercise the boundaries, and so on.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3205d43d1f61" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Software Test Management]]></title>
            <link>https://samimyaquby.medium.com/software-test-management-92f184dacbb4?source=rss-e943b57ad9b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/92f184dacbb4</guid>
            <category><![CDATA[test-management]]></category>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[quality-assurance]]></category>
            <category><![CDATA[test-management-plan]]></category>
            <category><![CDATA[istqb]]></category>
            <dc:creator><![CDATA[Samim Yaquby]]></dc:creator>
            <pubDate>Sun, 19 Apr 2020 18:11:25 GMT</pubDate>
            <atom:updated>2020-04-19T20:39:29.154Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IfAHGo_Mr13stMP_9u5WrQ.png" /><figcaption>Software Test Management (ISTQB) Cheat sheet</figcaption></figure><p>Software test management in general is not a precise science. Most organisations have developed their own methods for tackling this problem.</p><p>However, there are institutions in the software testing industry that are trying to standardize some of the software testing practices. International Software Testing Qualification Board ISTQB is one of such organizations.</p><p>I am summarizing some topics related to test management from ISTQB’s foundation guide. This summary should provide a nice checklist for you and bring some method to the madness.</p><p>We test software to mitigate its risks. Risks can have impact right from the initial stages of a project. So early testing saves time and resources and <strong>the higher the risk, the higher the coverage required.</strong></p><p>There are generally two types of risks that we focus on, project related and product related. Managing the project risk helps preserve your capability to deliver.<strong> Project related risks include:</strong> project issues, delays, inaccurate estimates, changes, staff issues, suppliers issues, and technical issues.</p><p><strong>Product risks</strong> on the other hand, are risks to the quality of the product.<strong> </strong>It includes:<strong> </strong>failure-prone software, inadequate system architecture, happy-path solutions, defects causing individual or property harms.</p><h3>Test Organization</h3><h4>Check 1 — Is your testing process independent enough?</h4><p>Authors of code get to read their own code over and over multiple times and as time passes they are less able to see their own errors. This is where independent testing is important. It is important to involve a pair of fresh eyes and a head whose sole purpose in a job is to find defects in an application. Independent testers are likely to recognize different kinds of failures and challenge the author’s assumptions.</p><p>Of course independent testing is not the silver bullet. It comes with a higher collaboration and communication cost. It could delay feedback, developers may lose sense of responsibility because they assume someone else is taking care of that. And independent testers may lack some important contextual information. But, a balanced independence could solve a lot of issues. In a paradigm, a company with no software tests, has the lowest test independence score and a company with outsourced testing has the highest independence score.</p><h4>Check 2 — What test strategy and approach do you need to employ?</h4><p>There are multiple approaches to how an organization sees its applications to be tested. Following are some of the approaches:</p><ol><li><strong>Preventative: </strong>Writing the tests first and then making the solutions(applications) pass them.</li><li><strong>Reactive: </strong>Develop the solution first and then test it for defects.</li><li><strong>Analytical Tests:</strong> Test each feature based on the analysis of some factor. I.e. risk based.</li><li><strong>Model based: </strong>test based on models. Such as based on statistical information about the failure rates of a feature, or usage model (what feature is used the most).</li><li><strong>Process-compliance: </strong>Testing for compliance to international, national, or industry standards IEEE, MISRA, ISO<strong> </strong>standards.</li><li><strong>Heuristic: </strong>Exploratory testing, execute a test and evaluate it.</li></ol><h3>Test Planning and Estimation</h3><p>Test planning ensures that there are a list of measured tasks and milestones to track progress against. The main document out of this stage is a project test plan. The project has a high level plan for test-related activities. The details of test-level activities are documented in the test-level plans. It is developed in the beginning of the project and updated via change control throughout the life of the project.</p><p>Factors to consider in the test planning process are: <strong>risks, constraints, resources, criticality, test policy, scope of testing, test objectives, and testability etc.</strong></p><p><strong>The ISO 20119–3 Software Testing Standard</strong> outlines that there should be a minimum of 15 sections present in a test plan.</p><h4>Check 1: What information goes into the test plan?</h4><ol><li><strong>Overview: </strong>Introduction and a birds eye view of the document.</li><li><strong>Unique Identification Number</strong>: Test plan is a formal document, it needs a unique identification number and proper versioning.</li><li><strong>Issuing Organization: </strong>Who is the owner of this document.</li><li><strong>Approval Authority:</strong> Whose approval and final review makes this an official document.</li><li><strong>Change History: </strong>The whens, whys, and whats of the changes brought to this document.</li><li><strong>Introduction: </strong>Introduction to the content of the document.</li><li><strong>Scope: </strong>Defines the areas of coverage.</li><li><strong>Reference: </strong>Lists referenced documents and software &amp; test information etc.</li><li><strong>Glossary: </strong>Defining terms, abbreviations, jargon etc.</li><li><strong>Context of testing: </strong>includes: Details of the sub-processes covered by the plan, test items, test scope, assumptions and constraints, stakeholders, communication lines inside and outside the test team</li><li><strong>Risk register: </strong>List of the known risks.</li><li><strong>Test Strategy: </strong>includes: what test process and sub-process will be conducted, test deliverables, test design techniques, test completion criteria, metrics to be collected, test data requirements, test environment requirements, retesting and regression testing approach, suspension criteria, deviation from the organisational test strategy</li><li><strong>Test Activities and Estimates: </strong>Documenting the activities to be completed and and time required to complete those activities.</li><li><strong>Staffing: </strong>Details of the staffing requirement, roles and responsibilities, and training requirements.</li><li><strong>Schedule: </strong>Milestones on a timeline.</li></ol><h4>Check 2: How do you develop the plan?</h4><ol><li>Sit with the project manager and subject matter expert to determine the scope and the risks that need to be tested.</li><li>Understand the delivery model (waterfall, Agile, etc.)</li><li>Make sure your testing activities adhere to the delivery model.</li><li>Design: the development of testing software (framework).</li><li>Development: coding.</li><li>Implementation: bringing the test framework into live environment.</li><li>Identify responsibilities and distribute them to resources.</li><li>Deciding what needs to be documented, which plans, how the test cases will be documented and so on. Ensuring the test documentation generates repeatable test assets.</li><li>Defining the management information, metrics, processes for monitoring and controlling test processes.</li></ol><h4>Check 3: What is your entry criteria and exit criteria (Define “ready” and “done” — Agile terminology).</h4><p>Determine when a test activity can start. This could include test activity planning and when test design and when test execution for each level of testing is ready to start.</p><p><strong>Ready: </strong>A test could be ready if:</p><ol><li>Testable requirements, user stories, or models are available.</li><li>Test tools, environment, code, and data are ready for use.</li><li>Previous tests have completed and met their exit criteria.</li></ol><p><strong>Done: </strong>A test is done if:</p><ol><li>All planned tests have been executed.</li><li>A certain level of coverage has been achieved.</li><li>The number of unresolved defects are within threshold.</li><li>All high-risk areas have been fully tested.</li></ol><h4>Check 4: What does your schedule look like?</h4><p>All test cases, both manual and automated could be organized into test suites and their execution scheduled. The schedule could take into consideration prioritizations and dependencies.</p><p><strong>Factors that could influence the test effort include: product characteristics, development process, personnel and staff, results of the tests</strong></p><h4>Check 5: How do you estimate your tests (time and effort)?</h4><p>Two of the most common estimation techniques are metrics-based and expert based.</p><p><strong>Metrics-based</strong> looks at data, i.e the number of: test conditions, test cases written, test cases executed, defects found and environment outages.</p><p><strong>Expert-based</strong> approach is the subjective decision of an expert. They could be business experts, test process consultants, developers, etc.</p><h3>Test Monitoring and Control</h3><h4>Check 1: Monitoring</h4><p>After the test plan is complete, all activities are plotted over a timeline, it is time to closely monitor your progress against your goals. You monitor your progress based on the metrics and estimations you have already developed.</p><p><strong>Metrics could include:</strong> progress against the plan, current quality, effectiveness of the test activities, percentage of planned work done, number of tests executed, defects found, subjective confidence of testers, milestones met, costs.</p><h4>Check 2: Control</h4><p>For the control part, you can tweak priorities, minor schedule re-adjustments, re-evaluating “ready” and “done” criteria, and altering the scope of test activities. Even delaying release into the production environment.</p><h3>Check 3: Reporting</h3><p>At this stage you can prepare a concise report showing your test metrics, tests undertaken, a test progress if the tests spread over multiple reporting periods, a test summary if tests meet their “done” criteria.</p><h4>Test Progress Report:</h4><ol><li><strong>Overview: </strong>Introduction and a birds eye view of the document.</li><li><strong>Unique Identification Number</strong>: a unique identification number and versioning system.</li><li><strong>Issuing Organization: </strong>Who is the owner of this document.</li><li><strong>Approval Authority:</strong> Whose approval and final review makes this a complete document.</li><li><strong>Change History: </strong>When, why, and what of the changes brought to this document.</li><li><strong>Introduction: </strong>Introduction to the content of the document.</li><li><strong>Scope: </strong>Defines the areas of coverage.</li><li><strong>Reference: </strong>Lists referenced documents and software and test information etc.</li><li><strong>Glossary: </strong>Defining terms, abbreviations, jargons etc.</li><li><strong>Test Status: </strong>includes: reporting period, progress against the plan, factors blocking the progress, test measures, new and changed test risks, testing planned in the next period</li></ol><h4>Test Summary Report:</h4><ol><li><strong>Overview: </strong>Introduction and a birds eye view of the document.</li><li><strong>Unique Identification Number</strong>: a unique identification number and versioning system.</li><li><strong>Issuing Organization: </strong>Who is the owner of this document.</li><li><strong>Approval Authority:</strong> Whose approval and final review makes this a complete document.</li><li><strong>Change History: </strong>When, why, and what of the changes brought to this document.</li><li><strong>Introduction: </strong>Introduction to the content of the document.</li><li><strong>Scope: </strong>Defines the areas of coverage.</li><li><strong>Reference: </strong>Lists referenced documents and software and test information etc.</li><li><strong>Glossary: </strong>Defining terms, abbreviations, jargons etc.</li><li><strong>Testing performed: </strong>includes: summary of performed tests, deviations from plan — if any, completion evaluation — were all tests performed, if not why not?, factors that blocked progress, residual risks, deliverables, reusable test assets, lessons learnt</li></ol><h3>Check 3: Defect Management</h3><p><strong>If your actual results don’t match the expected results — it is a defect.</strong> There needs to be a process that tracks all the defects through closure. The purpose of tracking defects is to provide clear feedback and reproduction steps for a defect and ideas for its improvement.</p><p>ISO 29119–3 defines a <strong>test defect report.</strong> A defect report could include:</p><ol><li>A unique ID</li><li>Title of the defect</li><li>Date of its report, issuing author</li><li>Environment specification</li><li>The development phase it was identified in</li><li>Reproduction steps</li><li>Expected and actual results</li><li>Urgency</li><li>State of the defect report: is it open, closed, deferred, etc.</li></ol><h3>Configuration Management</h3><p>Configuration management involves managing products, facilities, and processes. If a change is needed in any of these, it has to have a proper change management pipeline. It ensures that a stable environment is maintained throughout the lifecycle of a project. If to smoothen the side-effects of any change that has to happen.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92f184dacbb4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Anatomy of a Java `class`]]></title>
            <link>https://samimyaquby.medium.com/anatomy-of-a-java-class-889e4ce8624a?source=rss-e943b57ad9b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/889e4ce8624a</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[java-class]]></category>
            <category><![CDATA[object-oriented]]></category>
            <dc:creator><![CDATA[Samim Yaquby]]></dc:creator>
            <pubDate>Fri, 17 Apr 2020 21:43:28 GMT</pubDate>
            <atom:updated>2020-04-18T16:28:29.791Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hcmipMwoWHU289AMjqqXTg.png" /></figure><h3>Anatomy of a Java class</h3><h3>Part I — Declaration</h3><h3>What is a class in Java?</h3><p>Java code exists inside classes and interfaces, nowhere else. Between classes and interfaces, classes do most of the work when it comes to Java programs. Interfaces are there to outline behaviors for one or more sub-classes. Interfaces can’t create objects since they don’t contain any implementation.</p><p>For start, I would like to analogize classes to paper forms, like the ones that are filled out and have a separate section titled “for official use only”. A form neatly portrays the concept of a class.</p><p>Let’s picture a driving licence application form, it has named fields, which an applicant has to fill. i.e. Name, Address, Date of birth, etc. In a class such the equivalent of named spaces are the <em>instance variables</em>.</p><p>Likewise, in our paper application form, the “official use” section may contain other named spaces whose values might be derived from a series of operations. For example, deriving a person’s age from their date of birth, recording their name in the organ donors database, or assessing their driving record for DUI and points. Therefore, even though in the application form the “official use” section may look similar to the “non-official use” section, they could be different in a sense. The values in the “official use” section are the output of some sort of an operation.</p><p>In a Java class such operations are performed by its member methods. With one type of a form we can serve thousands of driving licence applicants. Each filled-out paper form records some type of coherent data at a given time. In Java an <em>object </em>is the equivalent of a filled-out form, we also call it an <em>instance </em>of a <em>class</em>.</p><p>An <em>object </em>is a state-ful entity that is created off of a class’s blueprint and it occupies its own memory space. Meaning, it was created from a class template.</p><p>A class in programming defines a new abstract data type. Just like an int variable stores integers, an instance of an Employee class stores <em>objects</em> of type employee. Java allows us to declare classes, methods, and variables in several ways. And how we declare them significantly affects the code’s behavior.</p><p>Since we are on the topic of classes, following are some rules associated with declaring classes:</p><ol><li>There can only be one public class per source code file.</li><li>If there is a public class in a file, the class name and filename must match.</li><li>A source file can have more than one non-public class.</li><li>A source file with no public class can have a name that does not match any of the classes inside.</li><li>Comments are independent of any of the positioning rules.</li><li>If the class is part of a package, the package statement should be the <strong>first </strong>line in the source code file.</li><li>import statements go after the package statement and before the class declaration.</li></ol><h3>Declaring a class and setting up its access level</h3><p>The bare bone class declaration looks like this: class <strong>Foo</strong> {}. A keyword, an identifier, and a pair of braces. Technically all classes have access modifiers. class <strong>Foo</strong> {} has an invisible one, which we call the <em>default </em>modifier.</p><p>Generally there are four types of access modifiers, three of them are explicitly declared using keywords: public, protected, and private. Plus the <em>default </em>modifier which fires up when we don’t explicitly mention any access modifier.</p><p><strong>It is important to note that classes can only have one of the two access modifiers, </strong><strong>public and <em>default</em></strong>. Other modifiers are used for the class <em>members</em>, they are not <em>class-level modifiers</em>.</p><h3>Accessing a class</h3><p>We can do three things with a class:</p><p><strong>1. Make objects with it.</strong> A class is a blueprint and we utilize that feature and create objects off of that blueprint. Or in technical terms, we create an <em>instance </em>of a class.</p><p><strong>2. Extend it.</strong> Meaning we can take a class and add to or redefine its features.</p><p><strong>3. Access certain members of it.</strong> We can access members of a class by whichever method their modifiers allow us to do so, remember those members have their own access and non-access modifiers.</p><p>All in all, an access modifier determines from how far out can a class be reachable. The table below is the summary of it:</p><figure><img alt="public and default level accessibilty of a class." src="https://cdn-images-1.medium.com/max/772/1*OfCJbsNlHaFcqNNk_GTocg.png" /><figcaption>public and default accessibility level of a class</figcaption></figure><p><strong>Note:</strong> these declarations are only for top-level classes. Read on <em>nested classes</em> or <em>inner classes</em> over <a href="https://docs.oracle.com/javase/tutorial/java/javaOO/nested.html">here</a>.</p><h3>Other class modifiers (Non-access)</h3><p>You can modify a class declaration by using the keyword final, abstract, and strictfp. These modifiers are in addition to the access modifiers. strictfp has a very particular and specialized use, it makes sure that any method inside that class strictly conforms to the IEEE 754 standard rules for floating points. Without this modifier the floating point accuracy will be dependent on the platform the Java code runs on. If you work with a lot of floating point numbers, it is very important that you understand why this feature exists. <a href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html">Read more here</a>. But, for our purpose, we will only discuss final and abstract classes.</p><h3>final class</h3><p>When used in a class declaration, the final key word means the class cannot be sub classed. Note that, <strong>it doesn’t mean that it cannot be instantiated</strong>, it only means that <em>“this blueprint cannot be edited!”</em>. If you really are certain that a class is in its final form and no one should edit its implementation — declare it final. Imagine if we could change the implementation of some of the Java API classes. A developer down the chain would be using Arrays class thinking it is still zero-indexed, without knowing that for some unknown reason you had decided to change it to one-indexed.</p><p>In contrast it is useful to let other classes inherit from a given class. It helps maintain a clean code base and avoid unnecessary redundancy. Imagine an HR application having an overarching Employee class and then all the sub classes of Executive, Auxiliary, and Contractor extending from it, and then each of these having their own sub classes of Manager, President, Carpenter etc. They all fit in a tree but they don’t have to repeat the implementation of the same fields and methods over and over.</p><h3>abstract class</h3><p>An abstract class, just like an interface, can never be instantiated, its sole purpose is to set a guideline for what its sub classes should do. It sounds a lot like an interface, but they are not the same. Why do we need abstract classes? Because, sometimes if we arrange our applications in a pure hierarchical way, it gets hard to create objects off of some classes, yet they are important to maintain their position in a chain of inheritance in order to separate its sub classes. For example, in a construction company’s application, it is hard to directly create an <em>object </em>of a class named Building, however it is crucial for this class to exist in order to separate its non-abstract sub classes: School, Hospital, and Apartment from other classes of the same application like: Road, Airport, and ParkingLot etc.</p><pre>abstract class <strong>Building</strong> {<br>  public abstract <strong>floors</strong>();<br>  public abstract <strong>rooms</strong>();<br>  public abstract <strong>bathrooms</strong>();<br>}</pre><p>The code above defines a ground rule for all sub classes, “if you can implement these methods, then you are a building type”.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=889e4ce8624a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Closure]]></title>
            <link>https://samimyaquby.medium.com/closure-9333648fbbcd?source=rss-e943b57ad9b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/9333648fbbcd</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programing]]></category>
            <category><![CDATA[first-class-function]]></category>
            <category><![CDATA[closure]]></category>
            <category><![CDATA[closures-functions]]></category>
            <dc:creator><![CDATA[Samim Yaquby]]></dc:creator>
            <pubDate>Sun, 10 Mar 2019 18:21:07 GMT</pubDate>
            <atom:updated>2019-03-10T18:21:43.933Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LU7mhTpZdOS8zIpvWRyC3g.png" /></figure><h3>Closure in JavaScript</h3><h4>Mastering JavaScript Series</h4><p>In programing languages, a closure, is a way of name binding. Name binding is simply binding some code or data with identifiers.</p><p>JavaScript functions are first-class objects. Meaning they contain more than just the code that the programer types. Among the extra stuff, it contains a <em>closure</em>. It is a record that stores variables available in a function’s environment at the time they are defined. This way, we don’t have to worry about the function breaking down on us when we call it later in the code. This binding mechanism allows the function to operate just fine no matter how many times you call it or when you call it, essentially making the function a standalone, robust, and reusable piece of a program. Lets look at the following example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/126b7c2134438147a6830b1db5301819/href">https://medium.com/media/126b7c2134438147a6830b1db5301819/href</a></iframe><p>In the example above we have a function named outie that has one variable inside and returns a function named innie. This innie function in turn has a job of its own, which is to return outiesVar every time innie is run.</p><p>Pick a sheet of JavaScript code, you can read it line by line until you get to a point where a function is recalled. You may stop there and go all the way up to where the function is defined and read what that function does and resume your reading afterward.</p><p>JavaScript achieves this task similarly by binding the function to the data it needs to run. This way, every time the function is called it has the necessary data to perform its duty.</p><p>Every time you run JavaScript code, it runs inside a default global execution context. Context is important, much like natural language, context helps us understand what our syntax can actually achieve.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bNkn_8K9Vt_c6q_ul9vrNQ.png" /><figcaption>results of console.dir(outie()) from the code above in chrome browser</figcaption></figure><p>Beside the global execution context, our code has the ability to create several local execution contexts. Each having their own scope. Most of the time these scopes are generated and determined by functions. In the code above when our outie function returns innie function, you can see that innie comes with some extra stuff. Among them is an array of scopes. In that array you have a record called Closure that binds the innie function to the outiesVar . With this feature, innie can always be called from any point in the code and it will still run as if it was inside the outie function.</p><p>Let’s use closures in another example with a little more common sense real-world scenario.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e50b3e25b317c993d7c5ff691268fc5d/href">https://medium.com/media/e50b3e25b317c993d7c5ff691268fc5d/href</a></iframe><p>In the code above we have a function that takes arguments like rent, car payment, and car insurance. It returns a reusable anonymous function that takes an arbitrary number for salary as an input and subtracts the total of expenses from the salary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I0auoVTqs5BIB7jffOriNQ.png" /><figcaption>results of console.dir(joesExpenses) and console.dir(janesExpenses)</figcaption></figure><p>This time under the hood, we see two copies of the anonymous function, each with their own closure objects. And as you can notice they both have different values attached to their Closure record.</p><p>Both anonymous functions are ready to fire once we provide them the salary amount.</p><p>Developing programs this way takes some practice. You have to know functions intimately, know what first-class functions are and develop a clear mental picture of what functions look like under the hood.</p><h3>Takeaways:</h3><ol><li>Outside variables are available inside the function, made possible by the <em>Closure</em> record.</li><li>JavaScript functions contain more information than just the visible typed code. Functions that are bound to variables of their containing scopes are the functions with closures.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9333648fbbcd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scope]]></title>
            <link>https://samimyaquby.medium.com/scope-608b4924c1c0?source=rss-e943b57ad9b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/608b4924c1c0</guid>
            <category><![CDATA[scopes]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[local-variable]]></category>
            <category><![CDATA[global-variable]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Samim Yaquby]]></dc:creator>
            <pubDate>Sat, 09 Mar 2019 22:45:57 GMT</pubDate>
            <atom:updated>2019-03-09T22:48:38.310Z</atom:updated>
            <content:encoded><![CDATA[<h3>Scope in JavaScript</h3><h4>Mastering JavaScript Series</h4><p>Scope is a vantage point inside code. Pick a sheet of JavaScript code and put your finger at any spot. If you were an interpreter, there would be a specific amount of code and data visible and accessible to you from that specific point.</p><h4>Why do we need scope?</h4><p>Imagine you have a printer in a small office of 5 employees. The employees share that printer and on rare occasions it happens that two people print something at the same time. It is not a big deal. They carefully separate their sheets and both parties get their print jobs. But as this office keeps getting bigger and bigger. This turns into a huge problem. Sometimes the same printer gets 10 different print jobs at the same time and now the employees have to separate all those sheets and figure who owns what. As you can see, after a certain point in the employee increase the printing process gets too complicated to manage. One solution is to divide the employees to departments, and each department gets their own printer. Once the lines between departments and ownerships of printers are demarcated, things go back to normal.</p><p>In the early days of computer programing, computer memories were small. The amount of data and code that a computer could run was small. As a programmer, it was manageable to keep track of your variables and data flow in a computer program. But, as the computers became stronger and memories grew larger, more complex programs were possible. Soon, managing data and code became an issue. It became far too easy for one part of a program to mess up data needed by other parts of a program. And just like each department should have their own printer, each part of a program having their own scope became a necessary thing.</p><p>Scope defines the visibility and accessibility of variables and methods of one part of a program to another. Scope is managed differently by different programing languages, but in general many languages including JavaScript share the concept of local and global scopes.</p><p>In JavaScript, anything available outside a function is part of the global scope and things available inside a function are part of the local scope. JavaScript didn’t use to have block level scope, but now with let we can declare variables that are limited to the scope of a statement, a block, or an expression.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a75b17342ef53833260b808c5ee3ae0/href">https://medium.com/media/8a75b17342ef53833260b808c5ee3ae0/href</a></iframe><p>In the code above two global variables are declared in line 1 and 2. The code declares a third variable as a local variable on line 5. On line 6 the code changes the global variable from the inside of a function. On line 8, if that variable was declared with var keyword it would overwrite insideVariable, but is not doing so now, because modern JavaScript allows you to declare block-scoped variables with let.</p><h4>Avoid declaring global variables (a.k.a polluting the global scope)</h4><p>The global namespace is shared by all your code. Declaring a variable in the global name space is like sharing a printer with everyone in the firm. This opens up the possibility of accidental alteration of values and data.</p><p>This doesn’t mean that declaring global variables can always be avoided. Not only it can’t always be avoided, but in some cases it might even make more architectural sense to define some of your variables globally. Like importing outside modules that all your code shares. Like having a shared dining hall for your firm.</p><h4>Know your functions and their scope</h4><p>In JavaScript local scopes are created by functions, you might see local scope often called as function scopes. Variables declared inside a function are available only inside that function and available to the functions declared inside that function. Being able to access variables present in their immediate outside environment is made possible because of a built-in JavaScript technique/functionality called <em>closure</em>. When resolving a variable, JavaScript starts at the innermost scope and searches outward.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/16d5576d4ccc505381bbe4e143824cd2/href">https://medium.com/media/16d5576d4ccc505381bbe4e143824cd2/href</a></iframe><h3>Takeaways:</h3><ol><li>Scope defines the visibility and accessibility of variables and methods of one part of a program to another</li><li>Avoid declaring global variables when they go against the concepts of modularity.</li><li>Functions create local scopes where variables declared inside are only available inside.</li><li>let creates block-scoped variables, variables declared with let stay inside their blocks, statements, or expressions.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=608b4924c1c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Higher-Order Functions]]></title>
            <link>https://samimyaquby.medium.com/higher-order-functions-68d908595309?source=rss-e943b57ad9b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/68d908595309</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[first-class-function]]></category>
            <category><![CDATA[higher-order-function]]></category>
            <category><![CDATA[abstraction]]></category>
            <dc:creator><![CDATA[Samim Yaquby]]></dc:creator>
            <pubDate>Wed, 06 Mar 2019 18:06:11 GMT</pubDate>
            <atom:updated>2019-03-06T18:06:11.796Z</atom:updated>
            <content:encoded><![CDATA[<h4>Mastering JavaScript Series</h4><p>Higher order functions can take other functions as arguments or return functions as their result.</p><p>In JavaScript higher order functions are possible because in this language functions are first-class objects. What that means is that the language treats functions as it would treat values. Seeing functions as values, just like a number or string may take away the charm of higher-order functions. Because, now they are just functions that can take values and return values. Well Duh!</p><p>In the context of programing, the function that takes another function as an argument is of course a “higher in order” function. What about the function that is passed as value, what is that called? The “functionee”? The “Lower-ordered” function? Well it is famously called a callback function, because it is “called back” by the function higher in order — rocket science!</p><p>Lets look at this example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8ccbb726ad4873f829a4d28c08c3774d/href">https://medium.com/media/8ccbb726ad4873f829a4d28c08c3774d/href</a></iframe><p>As you can see here, the sort function is taking another function that returns either 1, -1, or 0. Those three values are the criteria sort needs to figure how to sort something. Here, the programmer is utilizing descendingly()function’s first-class-object quality by passing it into .sort()function as a value. It should be noted that all functions in JavaScript are high-order functions and all of them are first-class objects. Their properties are always there regardless of how they are used.</p><p>Higher-order functions are powerful and they could simplify our code immensely. They give us higher abstraction when dealing with problems. <em>Abstraction </em>in programing means going farther away from the details — the step by step commands that make up a feature or an algorithm.</p><p>Consider the following example. We are given the task of taking all the elements of stingsArr and transforming them to upper case.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c4889210a15d96f38913c56d2c26285/href">https://medium.com/media/2c4889210a15d96f38913c56d2c26285/href</a></iframe><p>In the first example, we create an empty array named resultArr, we loop through stringAr, take every item there and transform them to uppercase and then push them into our resultArr. Once we have gone trough all the items and created a completely new resultArr. We return that array as result.</p><p>The rest of examples do the same thing. Except that they read more like a clear answer to a clear question we were asked in the beginning.</p><h3><strong>Takeaways</strong>:</h3><ul><li>Higher-order functions are functions that operate on other functions.</li><li>It is possible to have Higher-order functions in JavaScript because here functions are considered first-class objects or values.</li><li>Higher-order functions give us a higher <em>abstraction</em> view of our code and that allows us to focus on the problem our code is trying to solve as compared to looking at all the side processes like how a function loops through an array.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68d908595309" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How can JavaScript be asynchronous and single-threaded at the same time?]]></title>
            <link>https://samimyaquby.medium.com/how-can-javascript-be-asynchronous-and-single-threaded-at-the-same-time-c13c99bb4703?source=rss-e943b57ad9b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/c13c99bb4703</guid>
            <category><![CDATA[single-threaded-execution]]></category>
            <category><![CDATA[funny]]></category>
            <category><![CDATA[asynchronous]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Samim Yaquby]]></dc:creator>
            <pubDate>Mon, 04 Mar 2019 00:00:01 GMT</pubDate>
            <atom:updated>2020-11-09T18:23:42.096Z</atom:updated>
            <content:encoded><![CDATA[<h4>Mastering JavaScript Series</h4><p>So if you are completely new to this question, in computer science, thread of execution is the sequence or amount of programmed instructions that can be processed independently at a given time. There are two types types of threading, single threading and multi-threading. JavaScript is a single threaded programming language, Java or C# are multi-threaded programming languages.</p><p>What this means is that JavaScript can only run one instruction at a time while Java could run multiple instructions concurrently.</p><p>A side note here, for those who would argue that programming languages themselves aren&#39;t usually classified based on threads, well I agree, but if a programing language can support for running code in parallel they are multi-threaded, otherwise we can call them single-threaded. You can always run a multithreaded programming language in single thread, but you cant do the opposite. In the end they are practically two different types of programing languages.</p><p>Back to topic. So the question is: if JavaScript can run only one instruction at a time, it should be synchronous? Not asynchronous. Because synchronous means a bunch of commands in sequence, right? How can JavaScript be asynchronous and single-threaded at the same time?</p><p>Let’s understand this.</p><h3>Event Loop:</h3><p>Most of the websites work this way, or at least should be programmed to work this way: Once the user visits a page, they should readily see a user interface. Then they can interact with the interface, by clicking on something, typing something, or just by simply moving their mouse, and the website has to respond accordingly. Also, it is not just the user generated events, the programer could also target some other events to provide customized user experience, like:</p><ul><li>Browser events, such as when a page is finished loading</li><li>Network events, response on HTTP request</li><li>Timer events, timeouts and intervals</li></ul><p>These events are at our disposal to target as a programer. We can develop handlers for them and specify what happens on each of these events. The JavaScript engine then takes our handlers and automatically manages them with the help of a callback queue, which practically works like a loop. New things go to the end of the queue and older things are at the head of the queue — FIFO. This circulating process is metaphorically called the event loop. The loop keeps rotating through the tasks in a queue, and performs a task whenever the criteria for it is met. It removes that particular task and continues with what remains in the queue. Lets look at this example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb1487513c022058410497e3e2e06715/href">https://medium.com/media/cb1487513c022058410497e3e2e06715/href</a></iframe><p>Here we created two handlers:</p><p>The first one will print into console a message that reads clicked, <strong>if </strong>we click the button.</p><p>The second one is for when the page loads. Every time the page is loaded, right after, the console prints thanks for waiting for this page to load. But, it will only print clicked if we click the button. Notice, in the code, the function is written and assigned a handler before the onload event. But, it will only execute its handler when the criteria is met. Asynchronicity doesn’t necessarily mean multi-threadedness. Since these events can happen at unpredictable times and in unpredictable order, we say that the invocation of their handling functions are asynchronous.</p><p>Let’s understand this further with a very English example.</p><p>Think of a Starbucks in a very English suburb, where people are notorious for forming lines. The Starbucks is small just like the village. There is only one person at the counter and one person behind her preparing the orders. The lady goes through a queue of 10 people one morning. She takes the customers’ orders. Some of their orders doesn’t need preparation, like people ordering the over-the-counter almond snacks. Every time a customers asks for those almonds, the barista gives it to them right away and says “have a good day” to them as they leave. Then, as she takes the rest of the orders some of which need to be prepared.</p><p>The customers whose orders need to be prepared form a separate line the already-ordered. And then each of those customers comes forward and sees if their drink is prepared, if they had ordered a regular coffee, chances are it is already prepared, the barista hands it to them and they leave. If it is some other complicated drink, the customer goes to the back of the line and lets the next person check if his drink is ready, by this time a moderately complicated drink is ready and the next customer happens to be to owner, he grabs his drink and leaves. But, the rest of the line keeps rotating. This is a very English place so they love making queues and they don’t mind rotating. Gradually the least complicated orders gets finished first, and the ones that take a little longer go next, and the most complicated ones go last. Once the final guy who had ordered Triple, Venti, Half Sweet, Non-Fat, Caramel Macchiato gets his drink, the queue is over (the event loop ends).</p><blockquote>“an Englishman, even if he is alone, forms an orderly queue of one”, Hungarian-born British author George Mikes.</blockquote><p>Notice what happened here. The person at the counter served one person at all times. They never served two people at the same time. So at the end of the day the whole process was asynchronous and single-threaded at the same time. Just like our JavaScript processing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c13c99bb4703" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>