<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Zakaria EL AISSAOUI</title>
    <description>The latest articles on DEV Community by Zakaria EL AISSAOUI (@zakariaels).</description>
    <link>https://dev.to/zakariaels</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F590650%2F91307ab5-f97c-4a97-b8bb-b1ebbf7aef89.jpeg</url>
      <title>DEV Community: Zakaria EL AISSAOUI</title>
      <link>https://dev.to/zakariaels</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zakariaels"/>
    <language>en</language>
    <item>
      <title>JavaScript Closures</title>
      <dc:creator>Zakaria EL AISSAOUI</dc:creator>
      <pubDate>Mon, 23 Jan 2023 17:16:39 +0000</pubDate>
      <link>https://dev.to/zakariaels/javascript-closures-3h7m</link>
      <guid>https://dev.to/zakariaels/javascript-closures-3h7m</guid>
      <description>&lt;p&gt;JavaScript function closures are a powerful feature that allows you to create private variables and methods within a function.&lt;/p&gt;

&lt;p&gt;This can be useful for encapsulating logic, data, and behavior, and preventing them from being accessed or modified by external code.&lt;/p&gt;

&lt;p&gt;A closure is created when a function is defined inside another function. The inner function has access to the variables and parameters of the outer function, even after the outer function has returned.&lt;/p&gt;

&lt;p&gt;Here is an example of a closure in JavaScript:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kHf1Xt-U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/adu7ty114vtf20m10nrl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kHf1Xt-U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/adu7ty114vtf20m10nrl.png" alt="an example of a closure in JavaScript" width="307" height="254"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example, the &lt;em&gt;outerFunction&lt;/em&gt; takes a single parameter &lt;strong&gt;x&lt;/strong&gt; and assigns it to a variable &lt;em&gt;privateVariable&lt;/em&gt;. It then returns the &lt;em&gt;innerFunction&lt;/em&gt;, which has access to &lt;em&gt;privateVariable&lt;/em&gt; and can return its value.&lt;/p&gt;

&lt;p&gt;When we call &lt;em&gt;outerFunction(&lt;strong&gt;10&lt;/strong&gt;)&lt;/em&gt;, it returns the &lt;em&gt;innerFunction&lt;/em&gt; with &lt;em&gt;privateVariable&lt;/em&gt; set to &lt;strong&gt;10&lt;/strong&gt;. We assign the returned function to a variable &lt;em&gt;closure&lt;/em&gt;. Then we call the closure function which will give us the output &lt;strong&gt;10&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Closures can also be used to create private methods. For example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4EMvEbYh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ig16t6izt8tny9nhox1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4EMvEbYh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ig16t6izt8tny9nhox1.png" alt="Closures can also be used to create private methods" width="364" height="558"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example, &lt;em&gt;increment&lt;/em&gt; and &lt;em&gt;getValue&lt;/em&gt; are private methods that can only be accessed via the returned object. This allows you to hide implementation details and control how the data and methods are used.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Closures&lt;/strong&gt; are a powerful feature in JavaScript, and are often used in object-oriented programming, functional programming, and other design patterns. &lt;/p&gt;

&lt;p&gt;They allow you to create encapsulated and reusable code, and can help to improve the structure and maintainability of your application.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>closure</category>
    </item>
    <item>
      <title>𝗔𝗯𝗼𝗿𝘁𝗶𝗻𝗴 𝗼𝗻𝗴𝗼𝗶𝗻𝗴 𝗮𝗰𝘁𝗶𝘃𝗶𝘁𝗶𝗲𝘀 𝘂𝘀𝗶𝗻𝗴 𝘁𝗵𝗲 𝗔𝗯𝗼𝗿𝘁𝗖𝗼𝗻𝘁𝗿𝗼𝗹𝗹𝗲𝗿 𝗶𝗻𝘁𝗲𝗿𝗳𝗮𝗰𝗲.</title>
      <dc:creator>Zakaria EL AISSAOUI</dc:creator>
      <pubDate>Mon, 23 Jan 2023 13:12:58 +0000</pubDate>
      <link>https://dev.to/zakariaels/-60k</link>
      <guid>https://dev.to/zakariaels/-60k</guid>
      <description>&lt;p&gt;𝗔𝗯𝗼𝗿𝘁𝗶𝗻𝗴 𝗼𝗻𝗴𝗼𝗶𝗻𝗴 𝗮𝗰𝘁𝗶𝘃𝗶𝘁𝗶𝗲𝘀 𝘂𝘀𝗶𝗻𝗴 𝘁𝗵𝗲 𝗔𝗯𝗼𝗿𝘁𝗖𝗼𝗻𝘁𝗿𝗼𝗹𝗹𝗲𝗿 𝗶𝗻𝘁𝗲𝗿𝗳𝗮𝗰𝗲.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://mzl.la/3zPY59F" rel="noopener noreferrer"&gt;AbortSignal &lt;/a&gt;interface represents a signal object that allows you to communicate with a DOM request (such as a fetch request) and abort it if required via an AbortController object.&lt;/p&gt;

&lt;p&gt;𝗔. 𝗔𝘀𝘆𝗻𝗰 𝘄𝗼𝗿𝗸 𝗶𝗻 𝗥𝗲𝗮𝗰𝘁:&lt;br&gt;
Let's take the example of data fetching placed inside a useEffect hook.&lt;br&gt;
If this effect doesn't finish before it's fired again (re-render), we may have two requests running in parallel.&lt;br&gt;
To make things better, we can create an AbortController instance that will be aborted whenever the next effect runs.&lt;br&gt;
𝘞𝘩𝘦𝘯 𝘢𝘣𝘰𝘳𝘵() 𝘪𝘴 𝘤𝘢𝘭𝘭𝘦𝘥, 𝘵𝘩𝘦 𝘧𝘦𝘵𝘤𝘩() 𝘱𝘳𝘰𝘮𝘪𝘴𝘦 𝘳𝘦𝘫𝘦𝘤𝘵𝘴 𝘸𝘪𝘵𝘩 𝘋𝘖𝘔𝘌𝘹𝘤𝘦𝘱𝘵𝘪𝘰𝘯 𝘯𝘢𝘮𝘦𝘥 𝘈𝘣𝘰𝘳𝘵𝘌𝘳𝘳𝘰𝘳.&lt;/p&gt;

&lt;p&gt;𝗕. 𝗥𝗲𝗺𝗼𝘃𝗶𝗻𝗴 𝗘𝘃𝗲𝗻𝘁 𝗛𝗮𝗻𝗱𝗹𝗲𝗿𝘀:&lt;br&gt;
To remove an event handler, you have to keep hold of the original reference.&lt;br&gt;
Using AbortSignal, you can get the signal to remove it for you.&lt;/p&gt;

&lt;p&gt;Promise-based APIs wishing to support aborting can accept an AbortSignal object, and use its state to determine how to proceed (&lt;a href="https://bit.ly/3HB3hjQ" rel="noopener noreferrer"&gt;https://bit.ly/3HB3hjQ&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgfogjqh9jlh5dlafwryf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgfogjqh9jlh5dlafwryf.png" alt="code snippet" width="800" height="693"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>software</category>
      <category>webdev</category>
      <category>development</category>
      <category>showdev</category>
    </item>
    <item>
      <title>React's Fiber Reconciliation Algorithm</title>
      <dc:creator>Zakaria EL AISSAOUI</dc:creator>
      <pubDate>Mon, 23 Jan 2023 13:05:05 +0000</pubDate>
      <link>https://dev.to/zakariaels/reacts-fiber-reconciliation-algorithm-1ci6</link>
      <guid>https://dev.to/zakariaels/reacts-fiber-reconciliation-algorithm-1ci6</guid>
      <description>&lt;p&gt;Fiber is the name given to the new reconciliation algorithm introduced in React 16. &lt;/p&gt;

&lt;p&gt;It was a major rewrite of React's core algorithm, and it was designed to improve the performance of the library, especially when dealing with large lists of elements or complex user interactions.&lt;/p&gt;

&lt;p&gt;The main concept behind Fiber is the ability to split the work of reconciliation into smaller chunks, which can be spread out over multiple frames. This allows React to better utilize the browser's main thread, and also to more efficiently manage and prioritize the different updates that need to be made to the UI.&lt;/p&gt;

&lt;p&gt;Fiber also introduced new concepts such as "priority" and "expiration times" that allow React to control the order and timing of updates, so that critical updates can be processed first and less critical updates can be delayed or batched together to improve performance.&lt;/p&gt;

&lt;p&gt;Fiber also introduced the concept of "Suspense" which allows developers to write code that can "suspend" the rendering of a component until certain data is available, this improves the user experience in case of slow network, by showing loading spinner or fallback content.&lt;/p&gt;

&lt;p&gt;Overall, the Fiber algorithm provides a more efficient and flexible way for React to update the UI and should lead to better performance and a more responsive user experience.&lt;/p&gt;

</description>
      <category>java</category>
      <category>discuss</category>
      <category>programming</category>
    </item>
    <item>
      <title>JavaScript: First-class Functions</title>
      <dc:creator>Zakaria EL AISSAOUI</dc:creator>
      <pubDate>Thu, 19 Jan 2023 16:25:42 +0000</pubDate>
      <link>https://dev.to/zakariaels/javascript-first-class-functions-4hp2</link>
      <guid>https://dev.to/zakariaels/javascript-first-class-functions-4hp2</guid>
      <description>&lt;p&gt;Javascript is a programming language that allows functions to be treated as variables, known as First-class functions. This means that a function can be passed as an argument to other functions, returned by another function, and assigned as a value to a variable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Passing a function as an argument
&lt;/h2&gt;

&lt;p&gt;One example of passing a function as an argument is seen in the function &lt;strong&gt;executeOperation&lt;/strong&gt;, which takes in a &lt;strong&gt;handler function&lt;/strong&gt;, and &lt;strong&gt;a&lt;/strong&gt; and &lt;strong&gt;b&lt;/strong&gt; as arguments. The handler function (in this case sum) is then executed with &lt;strong&gt;a&lt;/strong&gt; and &lt;strong&gt;b&lt;/strong&gt; as its arguments and the result is logged.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frd926xussusw72ax9btm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frd926xussusw72ax9btm.png" alt="Passing a function as an argument" width="583" height="329"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Returning a function
&lt;/h2&gt;

&lt;p&gt;Another example is seen in the function &lt;strong&gt;addToValue&lt;/strong&gt;, which returns a new function that takes in another value and adds it to the original value passed in. This returned function is then assigned to a variable addTo3 and can be called with a new value.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F19bwoe18bvuvsa6nnl6v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F19bwoe18bvuvsa6nnl6v.png" alt="Returning a function" width="476" height="223"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Assigning a function to a variable
&lt;/h2&gt;

&lt;p&gt;Lastly, a function can also be assigned to a variable as seen in the example of predicate, which takes in a value and returns a boolean based on whether the value is equal to 3.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftagm6m1py38k4bllrkdo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftagm6m1py38k4bllrkdo.png" alt="Assigning a function to a variable" width="335" height="127"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's worth noting that functions that take other functions as arguments or return functions are known as higher-order functions.&lt;/p&gt;

</description>
      <category>security</category>
      <category>cybersecurity</category>
      <category>gratitude</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>React: best practices and design patterns</title>
      <dc:creator>Zakaria EL AISSAOUI</dc:creator>
      <pubDate>Thu, 19 Jan 2023 15:25:20 +0000</pubDate>
      <link>https://dev.to/zakariaels/react-best-practices-and-design-patterns-j81</link>
      <guid>https://dev.to/zakariaels/react-best-practices-and-design-patterns-j81</guid>
      <description>&lt;p&gt;React is a popular JavaScript library for building user interfaces, and it's become one of the most widely-used tools for building web and mobile apps.&lt;/p&gt;

&lt;p&gt;However, building a large, complex React application can be challenging, especially when it comes to architecture.&lt;br&gt;
There are a number of best practices and design patterns that can help to ensure that your code is &lt;strong&gt;maintainable&lt;/strong&gt;, &lt;strong&gt;scalable&lt;/strong&gt;, and &lt;strong&gt;easy to understand&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In this article, we'll take a look at some of the key considerations for building a &lt;strong&gt;well-architected&lt;/strong&gt; React application.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Use a component-based architecture: React is built around the idea of reusable components, and using a component-based architecture is a natural fit for building React applications. This architecture makes it easy to create reusable, modular code that can be easily tested and maintained.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use a state management library: Managing state can be one of the most challenging aspects of building a React application. Using a state management library like Redux or MobX can help to simplify state management and make it easier to keep your application state consistent and predictable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Divide your application into smaller modules: Dividing your application into smaller modules makes it easier to maintain and scale. By breaking your application into smaller, self-contained modules, you can make it easier to test, debug, and refactor your code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use a routing library: A routing library like React Router can help to manage the different routes within your application. This can make it easier to navigate between different sections of your application and make it more user-friendly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use a style library: A style library like Styled Components can help to make your application more consistent and maintainable. By using a style library, you can create reusable styles that can be easily shared across different components in your application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use a linter: A linter can help to enforce best practices for coding style and avoid common mistakes. This can make your code more readable and maintainable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Test your application: Writing tests for your application can help to ensure that it's working correctly and make it easier to catch bugs and errors.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Monitor your application's performance: Monitoring your application's performance can help to identify any issues that may be causing it to slow down. This can help you to make performance improvements and keep your application running smoothly.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By following these best practices and design patterns, you'll be well on your way.&lt;/p&gt;

</description>
      <category>php</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
