<?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 Michaelyoussef on Medium]]></title>
        <description><![CDATA[Stories by Michaelyoussef on Medium]]></description>
        <link>https://medium.com/@michaelyoussef396?source=rss-76e87916a18a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3jrY1G1QbQkL9ZLsaAg9dw.png</url>
            <title>Stories by Michaelyoussef on Medium</title>
            <link>https://medium.com/@michaelyoussef396?source=rss-76e87916a18a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 21:17:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@michaelyoussef396/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[Java Programming: A Complete Beginner’s Guide]]></title>
            <link>https://medium.com/@michaelyoussef396/java-programming-a-complete-beginners-guide-04fdae103ad2?source=rss-76e87916a18a------2</link>
            <guid isPermaLink="false">https://medium.com/p/04fdae103ad2</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[information-technology]]></category>
            <category><![CDATA[university]]></category>
            <dc:creator><![CDATA[Michaelyoussef]]></dc:creator>
            <pubDate>Wed, 19 Mar 2025 06:02:53 GMT</pubDate>
            <atom:updated>2025-03-19T06:02:53.569Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mZVOXouTzjQVC7NrR7lv1A.png" /></figure><p>Java serves as one of the most popular programming languages worldwide that maintains widespread adoption. Java serves developers as an accountable framework that includes scale capabilities and security frameworks enabling creation of all applications ranging from web interfaces to mobile software to enterprise applications.</p><h3><strong>What is Java?</strong></h3><p>Java functions as an object-oriented programming language which operates independently across different platforms. Java applications execute seamlessly on all connected systems which support the Java Virtual Machine (JVM) because of its platform-independent nature. Sun Microsystems published Java through its creator James Gosling during 1995. Java has evolved since its release to control applications across multiple platforms including web and mobile software and enterprise tools as well as big data operations.</p><h3><strong>Key Features of Java</strong></h3><p>Java shines because it includes multiple robust features which enhance its functionality.</p><ul><li>Every part of Java operates as an object through its object-oriented design which enables reusable and modular programming.</li><li>The bytecode compilation process from Java takes code that works equally well on any system equipped with a JVM.</li><li>Java provides secure and reliable development features through its automatic exception management combined with its built-in error handling mechanisms.</li><li>Java executes at high speed because it applies Just-In-Time (JIT) Compiler technology.</li><li>The application benefits from multitasking capabilities through Java multithreading which leads to enhanced efficiency.</li><li>Java includes an integration of Garbage Collector that performs both memory allocation and deallocation tasks automatically thus preventing memory leaks.</li></ul><h3><strong>Java Syntax Basics</strong></h3><p>Every Java application needs at least one class and at least one method for operation. The principal method constitutes the program entry point for every Java application.</p><pre>public class HelloWorld {<br>    public static void main(String[] args) {<br>        System.out.println(&quot;Hello, World!&quot;);<br>    }<br>}</pre><p>Java enables variable storage of data types such as int as well as float and String and boolean which makes it suitable for multiple application needs.</p><h3><strong>Object-Oriented Concepts in Java</strong></h3><p>The programming language Java maintains complete object-oriented characteristics through these basic design rules:</p><ul><li>A blueprint functions as a <strong>class</strong> definition and each <strong>instance</strong> of this definition represents an <strong>object</strong>.</li><li><strong>Inheritance</strong>: Allows one class to inherit the properties and behaviors of another class.</li><li>The concept of <strong>polymorphism</strong> enables methods to adopt diverse structures depending on the parameters received</li><li>Objects protect their contents by sealing their data behind private fields which users reach through public getters &amp; setters.</li><li>Through abstraction the system prevents users from seeing detailed implementation aspects and shows only essential object features.</li></ul><h3><strong>Java Libraries &amp; Frameworks</strong></h3><p>Java provides a diverse set of libraries together with frameworks which ease the development process.</p><h4><strong>Core Java Libraries:</strong></h4><ul><li><strong>java.util</strong> (Collections, Lists, Maps)</li><li><strong>java.io</strong> (File Handling)</li><li><strong>java.nio</strong> (Efficient I/O Operations)</li><li><strong>java.net</strong> (Networking)</li></ul><h4><strong>Popular Java Frameworks:</strong></h4><ul><li>The <strong>Spring</strong> framework serves as the main choice for building web applications together with enterprise software systems.</li><li><strong>Hibernate</strong> functions as a well-known framework for ORM-based database administration.</li><li><strong>Apache Struts</strong> — Used for building large-scale Java-based web applications.</li></ul><h3><strong>Java Use Cases</strong></h3><p>Business operators use Java across many industrial sectors due to its broad versatility.</p><ul><li>Java enables Eclipse and IntelliJ and multiple development environments to operate as desktop applications.</li><li>The dynamic web content production for applications requires implementation of Java Server Pages (JSP) and Servlets.</li><li>Mobile Applications operate mostly because of Java development for Android platforms.</li><li>Enterprise Applications utilize Java EE (Enterprise Edition) for their development within distributed systems of large scale.</li><li>Big Data — Frameworks like Hadoop leverage Java for processing massive datasets.</li><li>Embedded systems utilize Java ME (Micro Edition) on devices which have small memory capacity.</li></ul><h4><strong>Java in Industry</strong></h4><p>The fundamental structure of major technology companies depends on Java as their main operational system.</p><ul><li>Google — Uses Java extensively in Android development.</li><li>Netflix — Relies on Java for building scalable microservices architecture.</li><li>The cloud computing and enterprise solutions of Amazon (AWS) operate using Java programming language.</li></ul><h3><strong>Why Learn Java?</strong></h3><p>Novice software developers should begin learning Java to build their programming fundamentals. Java receives extensive community backing because it offers many libraries combined with strong employment market demand.</p><p>The modern technology depends heavily on Java because developers use this language to create applications for web systems and mobile platforms as well as AI and machine learning projects. Java has proven its power and popularity by becoming one of the leading programming languages which continue to thrive.</p><p>Learning Java basics through syntax combined with object-oriented programming and frameworks will position you successfully as a new Java developer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=04fdae103ad2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with Cisco Packet Tracer: A Beginner’s Guide]]></title>
            <link>https://medium.com/@michaelyoussef396/getting-started-with-cisco-packet-tracer-a-beginners-guide-b7b15de3ef85?source=rss-76e87916a18a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7b15de3ef85</guid>
            <category><![CDATA[it]]></category>
            <category><![CDATA[cisco-packet-tracer]]></category>
            <category><![CDATA[network-tool]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[networking]]></category>
            <dc:creator><![CDATA[Michaelyoussef]]></dc:creator>
            <pubDate>Tue, 11 Mar 2025 05:40:54 GMT</pubDate>
            <atom:updated>2025-03-11T05:40:54.747Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SBwt_c4_QPbccaHiOdV8JQ.png" /></figure><p>Without requiring actual hardware, students and IT professionals may design, construct, and troubleshoot networks using Cisco Packet Tracer, an effective network simulation program. Packet Tracer is a crucial tool for gaining practical experience if you’re new to networking or IT. This guide will teach you:</p><p>✅ The purpose of Cisco Packet Tracer and its benefits</p><p>✅ The main elements of the user interface</p><h3>What is Cisco Packet Tracer?</h3><p>Cisco Packet Tracer is network simulation software created by Cisco. It enables users to create and test network topologies in a virtual environment and practise networking concepts without physical devices. Whether you’re an IT student, cybersecurity professional, or network engineer, this application allows you to visualise and simulate how networks work.</p><h3>Exploring the Packet Tracer User Interface</h3><p>Packet Tracer’s user interface is straightforward and effective for network management and analysis.</p><h3>Main Features of the Interface include:</h3><p><strong>1. Device management:</strong></p><ul><li>Include equipment like as routers, switches, and PCs.</li><li>Connect them via wired (Ethernet, Fibre) or wireless connections.</li></ul><p><strong>2. Use Network Editing Tools</strong></p><ul><li>to select, remove, examine, label, and organise components</li><li>Modify network settings and configurations</li></ul><p><strong>3. Network Management Menu:</strong></p><ul><li>Open an network from sample files</li><li><strong>Save your network</strong> for future testing</li></ul><p>Change user preferences for an improved experience.</p><h3>Understanding the Configuration Tabs</h3><p>In Packet Tracer, clicking on a device opens numerous settings tabs:</p><p><strong>1. Physical Tab</strong> — Displays the <strong>hardware components</strong> of a device<br><strong>2. Config Tab</strong> — Allows for <strong>basic settings adjustments<br>3. CLI (Command Line Interface) Tab</strong> — Lets you configure devices using <strong>Cisco commands<br>4. Desktop Tab</strong> — Simulates <strong>PC settings like IP configuration and terminal access<br></strong> <strong>5. Services Tab</strong> — Provides tools like <strong>DHCP, DNS, and HTTP server settings</strong></p><h3>Why use Cisco Packet Tracer?</h3><p>Cisco Packet Tracer is a free, lightweight tool for studying networking.Here are a few reasons why it is useful:</p><p>✅ Simulate networks before dealing with real hardware.</p><p>✅ Prepare for CCNA and networking certifications.</p><p>✅ Free to use for students and IT professionals.</p><h3>final thoughts</h3><p>Cisco Packet Tracer is an indispensable tool for studying and practicing networking. Mastering Packet Tracer will provide a solid basis for any aspiring network engineer or cybersecurity professional.</p><p>Have any questions regarding Packet Tracer? Leave them in the comments!</p><p>Are you ready to start your own network? Stay tuned for the next guide!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7b15de3ef85" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Craft Stunning Loading/Error Pages in Next.js: A Developer’s Guide]]></title>
            <link>https://medium.com/@michaelyoussef396/craft-stunning-loading-error-pages-in-next-js-a-developers-guide-6493dd9e3479?source=rss-76e87916a18a------2</link>
            <guid isPermaLink="false">https://medium.com/p/6493dd9e3479</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[error-handling]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[Michaelyoussef]]></dc:creator>
            <pubDate>Sat, 17 Aug 2024 06:08:51 GMT</pubDate>
            <atom:updated>2024-08-17T06:08:51.954Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UFuGqA5LDV61EvpawHBqlw.png" /></figure><p>Let us be reasonable, no one would like it if he first of all watched a blank screen during the downloading of a site and secondly met an undefined error message. The developer’s job is to make user interfaces have as much smoothness as informative bumps no matter if is it an option for them or not. In aurgula, we enter the realm of power armour where super-abilities crystallize and assorted explosives prevail; next comes the chapter titled “Weapons”, where we get a glimpse at organic and unnatural weapons, the uses of melee physics, the system of aim and expected results for each gun. Let’s dive in!</p><h3>Why Bother with Custom Loading/Error Pages?</h3><p>Consider, that you’re swamped and, sometime in the morning you remember that you must buy the flight ticket from your phone. Clac, you click the “search” button and… no result. An empty TV screen is the only thing that I see as I stare into it. Did you give it a click? Is the app frozen? The internet has gone bust? Frustrating, right? The attention of the user here might be won back by a cleverly designed loading page. This prevents panicking customers when something doesn’t work as expected or jumps to them as a prize.</p><p>While 404 pages are another opportunity to improve the user’s experience, 500 pages are the doorway to making the negative experience a positive one. Instead of a regular “404 Not Found,” provide the user with specific content, and imagine possible alternative courses of action. And for goodness’ sake add some humour, it could improve the mood.</p><h3>Key Strategies for Loading/Error Pages in Next.js</h3><p>There are a few key ways to handle loading and error states in Next.js:</p><ul><li>Using Next.js built-in features: Furthermore, Next.js contains the ready-made components that help to perform operations with loading and error states as functions. This homogenous aspect of the project breaks down into a loading property for route transitions and an Error component for the handling of errors during rendering.</li><li>Customizing error pages: You may utilize custom error pages for different types of HTTP status codes, for instance, 404 (Not Found) and 500 internal server errors. This leads to the possibility of being more targeted at the customer, thus providing detailed instructions and advice on functionality.</li><li>Implementing global loading indicators: Ensure consistency by using the same global loading indicator within all fetching and routing actions.</li></ul><h3>Supporting Arguments and Code Snippets</h3><p>Let’s look at some code examples to illustrate these points.</p><p>1. Using the loading property:</p><pre>// pages/index.js<br><br>function HomePage() {<br>  const [isLoading, setIsLoading] = useState(false);<br>  useEffect(() =&gt; {<br>    setIsLoading(true);<br>    // Simulate data fetching<br>    setTimeout(() =&gt; {<br>      setIsLoading(false);<br>    }, 2000);<br>  }, []);<br>  return (<br>    &lt;div&gt;<br>      {isLoading &amp;&amp; &lt;p&gt;Loading...&lt;/p&gt;}<br>      {!isLoading &amp;&amp; &lt;p&gt;Welcome to the home page!&lt;/p&gt;}<br>    &lt;/div&gt;<br>  );<br>}<br>export default HomePage;</pre><p>In the given case, we implement the loading state by the use of the useState hook. During the while the data is fetching we set the “Loading…” status as true, and we show it. Next, the machine-translatable data is ready, where the actual content will be substituted with the message.</p><p>2. Custom Error Page:</p><pre>// pages/404.js<br><br>function Custom404() {<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Oops! Page not found.&lt;/h1&gt;<br>      &lt;p&gt;The page you were looking for doesn&#39;t exist.&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>}<br>export default Custom404;</pre><p>As the 404.js file already included in your pages directory, this makes it the default error page that will load for any page not found. One of the many interoperability advantages is the ability to customize it to your brand and offer your consumers an easy-to-operate menu.</p><p>3. Global Loading Indicator:</p><pre>// components/LoadingIndicator.js<br>function LoadingIndicator() {<br>  return &lt;div&gt;Loading...&lt;/div&gt;;<br>}<br>export default LoadingIndicator;</pre><p>For example, you can create code that provides functions of a LoadingIndicator component which can then be used within the main layout or a custom App component to provide the displaying-during-loading globally.</p><h3>Beyond the Basics</h3><p>There are many ways to enhance your loading and error pages further:</p><ul><li>Animated loading indicators: Use libraries like Framer Motion or React Spring to create visually appealing loading animations.</li><li>Themed error pages: Match your error pages to your website’s design for a consistent look and feel.</li><li>Humour and personality: Injecting some humour into your error messages can make a frustrating situation more bearable.</li></ul><p>I remember once working on a project where we added a playful illustration of a cat chasing a laser pointer to our 404 page. It was a small touch, but it definitely brought a smile to users’ faces.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6493dd9e3479" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlock the Power of TypeScript: A Beginner’s Guide to Functions]]></title>
            <link>https://medium.com/@michaelyoussef396/unlock-the-power-of-typescript-a-beginners-guide-to-functions-61278861a850?source=rss-76e87916a18a------2</link>
            <guid isPermaLink="false">https://medium.com/p/61278861a850</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Michaelyoussef]]></dc:creator>
            <pubDate>Fri, 16 Aug 2024 07:00:09 GMT</pubDate>
            <atom:updated>2024-08-16T07:00:09.335Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G9WZYHXEU1Q1jvl4lT0rnw.png" /></figure><p>Functions are the building blocks of any programming language, and TypeScript is no exception. As a superset of JavaScript, TypeScript offers all the functionality of JavaScript with the added bonus of static typing. This means that you can define the types of data that your functions expect and return, making your code more predictable, maintainable, and less prone to errors.</p><h3>Key Points: Building with TypeScript Functions</h3><ul><li>Defining Functions: In TypeScript, you define a function using the function keyword, followed by the function name, parameters in parentheses, and the function body enclosed in curly braces.</li><li>Specifying Types: The real power of TypeScript comes from its type annotations. You can specify the types of your function parameters and return value, ensuring type safety and clarity.</li><li>Optional Parameters: Not all parameters are mandatory! You can make parameters optional by adding a question mark ? after the parameter name.</li><li>Default Parameters: Provide default values for parameters, making your functions more flexible and adaptable to different use cases.</li><li>Arrow Functions: Embrace the modern syntax! Arrow functions provide a concise way to write functions, especially for short, single-line functions.</li></ul><h3>Supporting Arguments: Why Use TypeScript Functions?</h3><p>Let’s dive deeper into the advantages of using TypeScript functions:</p><ul><li>Early Error Detection: Remember those frustrating moments chasing down runtime type errors in JavaScript? With TypeScript, you catch type-related errors during development, saving you time and headaches.</li><li>Improved Code Readability: Type annotations act as documentation, making your code easier to understand for both you and your collaborators.</li><li>Enhanced Maintainability: As your project grows, type safety ensures that changes in one part of the codebase don’t inadvertently break functionality elsewhere.</li><li>Better IDE Support: Modern IDEs like Visual Studio Code offer intelligent code completion and refactoring tools that work seamlessly with TypeScript’s type system.</li></ul><h3>Code Snippets: Putting Theory into Practice</h3><p>Here’s how you define a simple function with type annotations in TypeScript:</p><pre>function addNumbers(a: number, b: number): number {<br>  return a + b;<br>}<br><br>let result = addNumbers(5, 10); // result is inferred as a number</pre><p>This code defines a function named addNumbers that takes two parameters, a and b, both of type number. The function also explicitly specifies that it returns a value of type number.</p><p>Now, let’s look at optional parameters and default values:</p><pre>function greet(name: string, greeting?: string = &quot;Hello&quot;) {<br>  console.log(`${greeting}, ${name}!`);<br>}<br><br>greet(&quot;Alice&quot;); // Output: Hello, Alice!<br>greet(&quot;Bob&quot;, &quot;Hi&quot;); // Output: Hi, Bob!</pre><p>In this example, the greeting parameter is optional due to the ?. If no greeting is provided, it defaults to &quot;Hello&quot;.</p><h3>Conclusion: Embrace the Power of TypeScript</h3><p>TypeScript functions elevate your JavaScript development experience. By embracing type safety, you gain numerous benefits: code clarity, early error detection, and improved maintainability. As you delve deeper into TypeScript, you’ll discover even more features that enhance your productivity and code quality.</p><h3>Call to Action: Take the Next Step!</h3><p>Start incorporating TypeScript functions into your projects today! Explore the official TypeScript documentation and experiment with different types and function features. Remember, the key to mastering any new skill is practice and exploration. So, get coding and unlock the full potential of TypeScript!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61278861a850" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlock the Secrets of Browser Storage: A Javascript Developer’s Guide]]></title>
            <link>https://medium.com/@michaelyoussef396/unlock-the-secrets-of-browser-storage-a-javascript-developers-guide-89049028ae01?source=rss-76e87916a18a------2</link>
            <guid isPermaLink="false">https://medium.com/p/89049028ae01</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Michaelyoussef]]></dc:creator>
            <pubDate>Fri, 09 Aug 2024 13:40:41 GMT</pubDate>
            <atom:updated>2024-08-09T13:40:41.359Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TEu_zcPEG589e9bykzTOFw.jpeg" /></figure><p>Ah, browser storage. It is almost like a secret treasure chest of the web that keeps out of sight but hides lots of cookies for your web applications. The moment we as web developers need to store data on the client side, these essential tools are pretty much all you need. Hence, shall we begin on a quest to peek into the world of storage in web browsers using Javascript, and disclose the mysteries so you can master these abilities?</p><h3>Key Players in the Browser Storage Game:</h3><p>There are several key players when it comes to storing data in the browser, each with its own strengths and ideal use cases:</p><ul><li>Local Storage: Take this for the storage as follows one and all. It is worth mentioning that the data is saved into the memory and it is readable even after the browser is closed and reopened. It aims at providing a mechanism for keeping data that last or likes user preferences, or application’s state.</li><li>Session Storage: This one is kind of a memory board, it is like your temporary scratchpad. Here information is stored but once the browser tab or window is closed the data is cleared. Use it for temporary data that can be found in a shopping cart or what page the user is in a long form.</li><li>Cookies: These are vets of the storage world for browsers. The cookies are the small text files on the user’s computer that may help track the session, personalize it, and authenticate the visitor. On the one hand, they introduce new issues, such as privacy considerations and how to deal with these properly and cautiously.</li></ul><h3>Supporting Arguments: Why Choose Browser Storage?</h3><p>Why bother with browser storage when you have server-side options? Well, there are several compelling reasons:</p><ul><li>Offline Functionality: Remind of the instance you realized you won’t be connected to the internet for a while. Through browser storage, an app can still do minor functions that will give even the user who is offline a smoother experience of the web.</li><li>Reduced Server Load: This feature enables you to store particular data on the client side, thereby unburdening your servers to enhance underperformance and scalability.</li><li>Faster Loading Times: The retrieval of local storage data is normally much faster compared to making several server trips. Such as, load times are speedier and the user is happier.</li></ul><h3>Code Snippets: Putting Theory into Practice</h3><p>Let’s get our hands dirty with some code examples to illustrate how to work with local and session storage:</p><p>Local Storage:</p><pre>// Store an item<br>localStorage.setItem(&#39;username&#39;, &#39;JohnDoe&#39;);<br><br>// Retrieve an item<br>let username = localStorage.getItem(&#39;username&#39;);<br><br>// Remove an item<br>localStorage.removeItem(&#39;username&#39;);<br><br>// Clear all items<br>localStorage.clear();</pre><p>Session Storage:</p><pre>// Store an item<br>sessionStorage.setItem(&#39;cartCount&#39;, &#39;3&#39;);<br><br>// Retrieve an item<br>let cartCount = sessionStorage.getItem(&#39;cartCount&#39;);<br><br>// Remove an item<br>sessionStorage.removeItem(&#39;cartCount&#39;);<br><br>// Clear all items<br>sessionStorage.clear();</pre><p>Cookies: (Setting a cookie requires using document.cookie)</p><pre>// Setting a cookie<br>document.cookie = &quot;userId=12345; expires=Thu, 18 Dec 2024 12:00:00 UTC; path=/&quot;;<br><br>// Accessing cookies<br>let allCookies = document.cookie;</pre><h3>Diving Deeper: Advanced Techniques and Considerations</h3><ul><li>Storage Limits: However, it may not be limitless to fill the browser storage as it is. Set the limit of storage if it is there (around 5MB) and the size should not cause an overload to the system with unnecessary extra data.</li><li>Data Security: Just be noted that client-side storage can be reached through Javascript, consequently data like passwords or credit card details must not be stored here.</li><li>JSON for Complex Data: When dealing with complex data structures in this case, it is important you will store and retrieve the data with JSON.stringify() and JSON.parse() respectively.</li></ul><h3>Conclusion</h3><p>Browser storage might be the best companion with Javascript as it provides developers with the possibility to create more enriched, responsive, and user-friendly web applications. By comprehending the varying storage resorting and their specific use cases, one can form a rational selection between data management on the client side and the refining user experience.</p><h3>Call to Action</h3><p>So from the browser storage decoding you have now, next is going to the practical section. Try a different kind of storage when doing your projects, realize that there exist more complex solutions, and feel the strength of local data management with a client side. Keep in mind that the internet is your workspace, and it is browser storage is the paintbrush that you would skillfully bring life into your masterpiece!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89049028ae01" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Deep Dive into Building a Restaurant Management System with SQLAlchemy]]></title>
            <link>https://medium.com/@michaelyoussef396/a-deep-dive-into-building-a-restaurant-management-system-with-sqlalchemy-f0c51e231c15?source=rss-76e87916a18a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0c51e231c15</guid>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Michaelyoussef]]></dc:creator>
            <pubDate>Sat, 27 Jul 2024 04:13:06 GMT</pubDate>
            <atom:updated>2024-07-27T04:13:06.362Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c9OcM8zcamdsXdTbwcvulw.png" /></figure><p>Creating a comprehensive restaurant management system involves managing multiple aspects of restaurant operations, from reservations and orders to feedback and employee management. In this blog post, we’ll explore the process of building such a system using Python and SQLAlchemy, a powerful ORM (Object-Relational Mapping) tool.</p><h4>Overview</h4><p>The project is a restaurant management system designed to streamline the operations of a restaurant. The system handles various components such as:</p><ul><li><strong>Reservations</strong></li><li><strong>Orders (food, drinks, shisha)</strong></li><li><strong>Employee Management</strong></li><li><strong>Table Management</strong></li><li><strong>Waiting List</strong></li><li><strong>Customer Feedback</strong></li></ul><p>We will use SQLAlchemy to define the database schema and manage data interactions.</p><h4>Project Structure</h4><p>The project structure includes the following major components:</p><ol><li><strong>Models</strong>: Defines the database schema.</li><li><strong>Seeding Functions</strong>: Adds initial data to the database.</li><li><strong>CLI Interface</strong>: Manages user interactions and operations.</li><li><strong>Helper Functions</strong>: Facilitates various operations like adding items, processing payments, and managing reservations.</li></ol><p>Let’s break down each component.</p><h3>Models</h3><p>The core of the application is the database schema defined using SQLAlchemy models. Here’s a brief look at some key models:</p><h4>Drink Model</h4><pre>class Drink(Base):<br>    __tablename__ = &#39;drinks&#39;<br>    <br>    id = Column(Integer, primary_key=True)<br>    name = Column(String, nullable=False)<br>    main_category = Column(String, nullable=False)<br>    sub_category = Column(String, nullable=True)<br>    description = Column(String, nullable=True)<br>    price_glass = Column(Float, nullable=True)<br>    price_bottle = Column(Float, nullable=True)</pre><p>This model defines the drinks available in the restaurant, categorized by main and subcategories, with optional pricing for glass and bottle.</p><h4>Food Model</h4><pre>class Food(Base):<br>    __tablename__ = &#39;foods&#39;<br>    <br>    id = Column(Integer, primary_key=True)<br>    name = Column(String, nullable=False)<br>    main_category = Column(String, nullable=False)<br>    sub_category = Column(String, nullable=True)<br>    description = Column(String, nullable=True)<br>    price = Column(Float, nullable=False)</pre><p>Similar to the Drink model, the Food model defines the food items available, including their categories and pricing.</p><h4>Reservation Model</h4><pre>class Reservation(Base):<br>    __tablename__ = &#39;reservations&#39;<br>    <br>    id = Column(Integer, primary_key=True)<br>    customer_name = Column(String, nullable=False)<br>    table_number = Column(Integer, ForeignKey(&#39;restaurant_tables.id&#39;), nullable=False)<br>    table = relationship(&quot;RestaurantTable&quot;, back_populates=&quot;reservations&quot;)</pre><p>This model manages customer reservations, linking each reservation to a specific table.</p><h4>RestaurantTable Model</h4><pre>class RestaurantTable(Base):<br>    __tablename__ = &#39;restaurant_tables&#39;<br>    <br>    id = Column(Integer, primary_key=True)<br>    location = Column(String, nullable=False)<br>    table_number = Column(Integer, nullable=False)<br>    capacity = Column(Integer, nullable=False)<br>    is_available = Column(Boolean, default=True)<br>    <br>    orders = relationship(&quot;Order&quot;, back_populates=&quot;table&quot;)<br>    reservations = relationship(&quot;Reservation&quot;, back_populates=&quot;table&quot;)</pre><p>The RestaurantTable model defines the tables in the restaurant, including their location, capacity, and availability status.</p><h3>Seeding Functions</h3><p>To populate the database with initial data, we create seeding functions. Here are examples of seeding functions for drinks and food:</p><h4>Seeding Cold Drinks</h4><pre>def seed_cold_drinks():<br>    add_drink(&quot;Mango Juice&quot;, &quot;Cold Drinks&quot;, &quot;Juices&quot;, &quot;A refreshing tropical drink made from ripe mangoes.&quot;, 10.0)<br>    add_drink(&quot;Pineapple Juice&quot;, &quot;Cold Drinks&quot;, &quot;Juices&quot;, &quot;A sweet and tangy juice made from fresh pineapples.&quot;, 8.0)<br>    # Additional drinks...</pre><p>Seeding Hot Drinks</p><pre>def seed_hot_drinks():<br>    add_drink(&quot;Egyptian Sahlab&quot;, &quot;Hot Drinks&quot;, &quot;Sweet Drink&quot;, &quot;A traditional Egyptian sweet drink made from milk and flavored with rose water and nuts.&quot;, 8.0)<br>    add_drink(&quot;Hot Chocolate&quot;, &quot;Hot Drinks&quot;, None, &quot;A rich and creamy hot chocolate drink.&quot;, 7.0)<br>    # Additional drinks...</pre><h3>CLI Interface</h3><p>The CLI interface, built using the click library, provides a user-friendly way to interact with the system. Here&#39;s a snippet of the main CLI function:</p><pre>@click.command()<br>def cli():<br>    while True:<br>        print_menu()<br>        choice = input(&quot;Enter your choice: &quot;)<br>        handle_user_choice(choice)<br><br>if __name__ == &#39;__main__&#39;:<br>    cli()</pre><p>The CLI offers options for management, employees, and customers, guiding them through various operations such as viewing the menu, making reservations, and ordering items.</p><h3>Helper Functions</h3><p>Helper functions are essential for various operations. Here are some examples:</p><h4>Adding a Drink</h4><pre>def add_drink(name, main_category, sub_category=None, description=None, price_glass=None, price_bottle=None):<br>    existing_drink = session.query(Drink).filter_by(name=name).first()<br>    if existing_drink is None:<br>        drink = Drink(<br>            name=name, <br>            main_category=main_category, <br>            sub_category=sub_category, <br>            description=description, <br>            price_glass=price_glass, <br>            price_bottle=price_bottle<br>        )<br>        session.add(drink)<br>        session.commit()<br>    else:<br>        print(f&quot;Drink {name} already exists. Skipping.&quot;)</pre><p><strong>Processing Payment</strong></p><pre>def process_payment():<br>    payment_requests = session.query(WaitingList).filter_by(reason=&#39;Payment&#39;, status=&#39;Waiting&#39;).all()<br>    if not payment_requests:<br>        click.echo(&quot;No tables waiting for payment.&quot;)<br>        return<br><br>    for payment in payment_requests:<br>        click.echo(f&quot;Table {payment.customer_name}&quot;)<br>        response = input(f&quot;Do you want to process payment for {payment.customer_name}? (yes/no): &quot;)<br>        if response.lower() == &#39;yes&#39;:<br>            table_number = int(payment.customer_name.split()[-1])<br>            table = session.query(RestaurantTable).filter_by(table_number=table_number).first()<br>            if table:<br>                table.is_available = True<br>                payment.status = &#39;Completed&#39;<br>                session.commit()<br>                click.echo(f&quot;Payment processed and table number {table.table_number} is now available.&quot;)<br>            else:<br>                click.echo(&quot;Table not found.&quot;)<br>    session.close()</pre><h3>Conclusion</h3><p>Building a restaurant management system with SQLAlchemy involves defining a robust database schema, creating seeding functions to populate the database with initial data, and developing a CLI interface for user interactions. This system can be further extended and customized to meet specific needs, ensuring efficient and smooth restaurant operations.</p><p>By leveraging SQLAlchemy and Python, we can create scalable and maintainable solutions that streamline the management of restaurant activities, enhancing the overall dining experience for customers and operational efficiency for staff.</p><p><a href="https://github.com/michaelyoussef396/CarioNights">https://github.com/michaelyoussef396/CarioNights</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0c51e231c15" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TypeScript’s Secret Weapon: Mastering the Any/Unknown Types]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@michaelyoussef396/typescripts-secret-weapon-mastering-the-any-unknown-types-3e5845aaef86?source=rss-76e87916a18a------2"><img src="https://cdn-images-1.medium.com/max/1792/1*BBL6XMf3x66F9YNsuaLeHQ.png" width="1792"></a></p><p class="medium-feed-snippet">Wonder when TypeScript&#x2019;s strict checking gets too tough for you? Let&#x2019;s be honest life needs a bit of slippage if you want to cope with a&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@michaelyoussef396/typescripts-secret-weapon-mastering-the-any-unknown-types-3e5845aaef86?source=rss-76e87916a18a------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@michaelyoussef396/typescripts-secret-weapon-mastering-the-any-unknown-types-3e5845aaef86?source=rss-76e87916a18a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e5845aaef86</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Michaelyoussef]]></dc:creator>
            <pubDate>Mon, 22 Jul 2024 10:56:23 GMT</pubDate>
            <atom:updated>2024-07-22T10:56:23.399Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[TypeScript’s Secret Weapon: How Type Inference Makes Your Code Smarter (and You Look Like a Genius)]]></title>
            <link>https://medium.com/@michaelyoussef396/typescripts-secret-weapon-how-type-inference-makes-your-code-smarter-and-you-look-like-a-genius-e91393a6732b?source=rss-76e87916a18a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e91393a6732b</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Michaelyoussef]]></dc:creator>
            <pubDate>Sat, 01 Jun 2024 12:16:50 GMT</pubDate>
            <atom:updated>2024-06-01T12:16:50.009Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NTU42_dC4Q2MghL76iFpzw.jpeg" /></figure><p>Sometimes, you find yourself over and over-specifying types in TypeScript code, does this sound familiar? Worry no more, because TypeScript has a secret weapon: type inference. It feels as if you are working with a mind reader that somehow can tell your code its types, without the need to explicitly state them. “Let’s begin,” we say, as we dive into the way it works and why it makes coding far more efficient!</p><h3>Type Inference: The Basics</h3><p>Type inference is one of TypeScript’s characteristics which allows it to determine the type of the variable or expression by data context. This so implies that you can write a cleaner code with fewer type annotations but still enjoy the extra benefits of static typing. It’s similar to a situation where someone has it all and gets to have it both ways.</p><p>There are several ways type inference works its magic:</p><ul><li>From the value assigned: When you directly assign a value to a variable, TypeScript infers the type based on that value. For example:</li></ul><pre>let message = &quot;Hello, world!&quot;; // TypeScript infers &#39;message&#39; as a string</pre><ul><li>From the return value of a function: TypeScript analyzes the function’s body and determines the return type based on the return statements.</li></ul><pre>function add(x: number, y: number) {<br>    return x + y;<br>}<br>let result = add(5, 3); // TypeScript infers &#39;result&#39; as a number</pre><ul><li>From the context of usage: In some cases, TypeScript uses how a variable is used to infer its type.</li></ul><pre>let myArray = [1, 2, 3]; // TypeScript infers &#39;myArray&#39; as a number[]<br>myArray.push(4);</pre><h3>Why Type Inference is Awesome</h3><ul><li>Less code, more efficiency: Type inference will save you the time and effort savings by decreasing the need to specify type annotations, leading to concise and convenient code reading.</li><li>Improved readability: A decrease in code clutter results in more targeted logic and this makes it apparent for you, as well as the others, to comprehend the code more self-evidently.</li><li>Reduced errors: Yet, type inference remains a source of type safety, thus preventing the case of unforeseen errors from being revealed at the development time and cancelling the case of runtime surprises.</li></ul><h3>Taking it Further: Advanced Type Inference</h3><p>TypeScript’s type inference capabilities go beyond the basics. It can handle complex scenarios like:</p><ul><li>Inferring from function arguments:</li></ul><pre>function greet(name: string) {<br>    return `Hello, ${name}!`; <br>}<br>let greeting = greet(&quot;Alice&quot;); // TypeScript infers &#39;greeting&#39; as a string</pre><ul><li>Inferring from object literals:</li></ul><pre>let person = {<br>    name: &quot;Bob&quot;,<br>    age: 30<br>}; // TypeScript infers &#39;person&#39; as { name: string, age: number }</pre><ul><li>Inferring from array literals:</li></ul><pre>let numbers = [1, 2, 3]; // TypeScript infers &#39;numbers&#39; as number[]</pre><p>Pro Tip: Although type inference is flexible, however, there are occasions when outlining types explicitly is preferable, for example, with complicated objects or if you need clarity in your code.</p><h3>Code Snippet Examples</h3><p>Here’s a closer look at how type inference works in different situations:</p><pre>// Example 1: Basic Type Inference<br>let age = 25; // Inferred as number<br>// Example 2: Inference from Function Return Value<br>function multiply(x: number, y: number) {<br>  return x * y;<br>}<br>let product = multiply(5, 10); // Inferred as number<br>// Example 3: Inference with Arrays<br>let colors = [&quot;red&quot;, &quot;green&quot;, &quot;blue&quot;]; // Inferred as string[]<br>// Example 4: Inference with Objects<br>let employee = {<br>  name: &quot;John&quot;,<br>  id: 123,<br>}; // Inferred as { name: string, id: number }</pre><h3>Conclusion</h3><p>Type inference in TypeScript, a useful tool, can add thrill to your programming. It enhances productivity in that it reduces code verbosity, keeps up readability, and type safety is 100% guaranteed. Embrace type inference and watch your code being typed, and you will see your code will become cleaner, smarter, and more effective.</p><h3>Call to Action</h3><p>Time to witness the spell of type inference? Implement TypeScript right away and enjoy its influence on the development. Check the excellent TypeScript documentation and resources in the community for more information and improvement of your skills.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e91393a6732b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlock TypeScript’s Power: Mastering tsconfig.json for Cleaner Code]]></title>
            <link>https://medium.com/@michaelyoussef396/unlock-typescripts-power-mastering-tsconfig-json-for-cleaner-code-ef145b019d70?source=rss-76e87916a18a------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef145b019d70</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Michaelyoussef]]></dc:creator>
            <pubDate>Sat, 01 Jun 2024 08:14:11 GMT</pubDate>
            <atom:updated>2024-06-01T08:14:11.796Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JUYBDOq_B4z93m_3UGOk9w.jpeg" /></figure><p>Ah, TypeScript! You can think of it like a long-established, older sibling with a much more mature, sensible, and secure side that JavaScript probably won’t ever match because TypeScript offers all that and much more! However, on the other hand, there is this thing called… what shall we call them?… Configuration files. Step in and those are the commands you’ll see in your TypeScript projects.</p><h3>Why Should You Care About tsconfig.json?</h3><p>In a nutshell, tsconfig.json lets you:</p><ul><li>Control TypeScript behaviour: Narrow down the strictness of the compiler or make the compiler lenient. Include files or exclude files where necessary.</li><li>Boost code quality: Make the early mistake detection, keep your code more maintainable, and get better at collaborating.</li><li>Tailor the development experience: Get to know the details of the car and set it up according to your workflow and choices.</li></ul><p>Think of it like setting the rules for a game. Clear rules lead to a smoother, more enjoyable experience for everyone involved.</p><h3>Key tsconfig Options You Should Know</h3><p>There are tons of options in tsconfig.json, but let’s focus on a few key ones:</p><ul><li>compilerOptions: This is the most crucial part of the file where the settings are stored affecting how typescript compiles your code.</li><li>target: Narrow the ECMAScript version you use (e.g., ES5, ES6). Decide according to the area you implement within and the features you are aiming at.</li><li>module: Makes the decision of what modules generators are used in applications (e.g., CommonJS, AMD, System) This causes you to know how your code is designed and how it is loaded.</li><li>strict: Increases the effectiveness of typecasting greatly, thus identifying more bugs. It gives me that sense of power similar to the “Lint-Master”</li><li>outDir: It indicates the file location where the JavaScript files compiled get stored directory for JavaScript files compiled. Keep your project organized!</li><li>include: An array of file globs that contains directory paths with a corresponding flag to tell the compiler whether it is part of the project. The application of this technique in managing large projects can be considered as successful.</li><li>exclude: Here is an example opposite to this meaning, that is, to omit those which are to be excluded from a compilation. Let’s say you want to run tests for your code, but you don’t want those test files to affect the final result.</li></ul><h3>Bringing it All Together: A Real-World Example</h3><p>Imagine you’re building a web app with TypeScript. Here’s a basic tsconfig.json to get you started:</p><pre>{<br>  &quot;compilerOptions&quot;: {<br>    &quot;target&quot;: &quot;es5&quot;,<br>    &quot;module&quot;: &quot;commonjs&quot;,<br>    &quot;strict&quot;: true,<br>    &quot;outDir&quot;: &quot;./dist&quot; <br>  },<br>  &quot;include&quot;: [<br>    &quot;./src/**/*.ts&quot; <br>  ]<br>}</pre><p>This configuration tells TypeScript to:</p><ul><li>Convert to ES5 to maintain a high level of all-browser compatibility.</li><li>Experiment with using CommonJS modules, one of the most popular formats that are supported by most of the environments.</li><li>Enable type checking to pinpoint any possible malfunctions as the code is developing.</li><li>Output all Js files you have compiled to the ‘./dist’ directory.</li><li>Put all TypeScript files in the src folder and all the subfolders of it.</li></ul><h3>Additional Tips for tsconfig Masters</h3><ul><li>Start with a base configuration: The TypeScript website suggests configurations for different project types, including an internal folder structure, test directory, type definitions directory, utilities and helper scripts folder, and style sheets directory.</li><li>Use comments: Inform on the selection of the tsconfig.json file, as the more others know the project’s setup, the better.</li><li>Extend configurations: in case of big configuration files divide them into sections and apply the option “extends” to inherit configuration settings.</li></ul><h3>Conclusion</h3><p>Gaining the skill of functioning of tsconfig.json gives you with the opportunity to bring out the best in TypeScript. Through the knowledge of and the settings configurations, you will form neat clean and easily maintainable code and will also bring about an equally efficient development process. Remember, you look at your websites as your friend, not your enemy. TSCONFIG.JSON helps in the presentation of your website and decides how your website visitors will interact with your website.</p><h3>Take Action!</h3><ul><li>Dive into the <a href="https://www.typescriptlang.org/docs/">official TypeScript documentation</a> to explore all the available options in tsconfig.json.</li><li>Experiment with different settings to find what works best for your projects.</li><li>Share your knowledge and help others in the TypeScript community!</li></ul><p>Remember, with great tsconfig power comes great coding responsibility!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef145b019d70" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlock Async Await Mastery: Your Guide to JavaScript Promises]]></title>
            <link>https://medium.com/@michaelyoussef396/unlock-async-await-mastery-your-guide-to-javascript-promises-81885e7931bb?source=rss-76e87916a18a------2</link>
            <guid isPermaLink="false">https://medium.com/p/81885e7931bb</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Michaelyoussef]]></dc:creator>
            <pubDate>Wed, 15 May 2024 02:57:46 GMT</pubDate>
            <atom:updated>2024-05-15T02:57:46.867Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yG4RNyZFVM8QnxNMO3Ty9A.jpeg" /></figure><p>To untie the knots that can be created by the asynchronous nature of JavaScript is a challenge, and often exacerbated for those who are not familiar with the language. Promises, I am the beautiful antidote to callbacks’ messy code and I will make your async processes flow like a river. The most important piece of knowledge required as a web developer for building responsive and fast applications is to understand and use Promises. We will start the campaign and try to figure out the spells!</p><h3>Demystifying Promises: Key Concepts</h3><p>You may imagine the place to be a restaurant. Subsequently, you place your order (a request) which could be served immediately (response) so you may continue chatting with your friends or you can still enjoy the whole ambience of the place. In JavaScript, the promises as well are made to develop the same way. They are the final results (or negation) of a thread which gets executed in non-blocking mode, letting the program proceed further without getting halted.</p><ul><li>States of a Promise: ‘A Promise can be in one of three states: granted, denied, or enqueued.’</li><li>Pending: At the first stage of the crisis where the process is underway and urgent action is needed.</li><li>Fulfilled: The operation was done and a value of the Promise has been set.</li><li>Rejected: The operation was unsuccessful, and the Promise has as a reason for the failure (a vivid picture of the error object).</li><li>Chaining Promises: This is where too Promises are applied. Using .then() and .catch() chain the returned value from the resolved action to the next instruction or capture the unhandled risk, and so on to get a sequence of asynchronous instructions.</li><li>Error Handling: Implementing error handling becomes much easier with the help of .catch() method. Rain no longer experiences the depth of the extended nesting structure.</li></ul><h3>Why Promises Matter: Supporting Arguments</h3><p>Promises offer several advantages over traditional callback-based approaches: Promises offer several advantages over traditional callback-based approaches:</p><ul><li>Improved Readability: Chaining promises with .then() and .catch() creates better readability and the process becomes more straightforward compared to the complex code with all the deep callbacks.</li><li>Error Handling: Distributed error approach with .catch() not only simplifies error handling but also prevents spontaneous freezing which may lead to a total collapse of your web app.</li><li>Composability: Unlike threads, which lead to parallel processes and require complex locks to coordinate, Promises can be more easily composed and chained, paving the way for asynchronous workflows with step-by-step processing.</li></ul><p>Anecdote: I recall the days when I was studying for my final exam the very first time and Promises was not even in the picture. To serve multiple concurrent and asynchronous requests and their callbacks was a sadistic duty. Lastly, the Employee faces the problem of loss of personality and impartial decisions as CB also has theirs.</p><h3>Promise Examples: From Theory to Code</h3><p>Let’s solidify our understanding with some code examples:</p><h4>Creating a Promise</h4><pre>const myPromise = new Promise((resolve, reject) =&gt; {<br>    // An asynchronous operation, like fetching data from an API<br>    const result = performAsyncOperation();<br>    if (result.success) {<br>        resolve(result.data); // Operation succeeded, resolve with data<br>    } else {<br>        reject(result.error); // Operation failed, reject with error<br>    }<br>});</pre><h4>Consuming a Promise</h4><pre>myPromise<br>    .then(data =&gt; {<br>        console.log(&quot;Promise fulfilled!&quot;, data);<br>        // Do something with the resolved data<br>    })<br>    .catch(error =&gt; {<br>        console.error(&quot;Promise rejected:&quot;, error);<br>        // Handle the error<br>    });</pre><h4>Chaining Promises</h4><pre>fetch(&quot;https://api.example.com/data&quot;)<br>    .then(response =&gt; response.json()) // Parse response as JSON<br>    .then(data =&gt; {<br>        // Process the data<br>        return processData(data);<br>    })<br>    .then(processedData =&gt; {<br>        // Do something with the processed data<br>        console.log(&quot;Processed data:&quot;, processedData);<br>    })<br>    .catch(error =&gt; {<br>        console.error(&quot;Error fetching or processing data:&quot;, error);<br>    });</pre><h3>Beyond the Basics: Async/Await</h3><p>On the other hand, Promises are mighty helpful, and the combination of them with the async/await syntax makes asynchronous code even more powerful. It makes writing asynchronous code syntactically look synchronous, while also increasing readability.</p><pre>async function fetchData() {<br>    try {<br>        const response = await fetch(&quot;https://api.example.com/data&quot;);<br>        const data = await response.json();<br>        const processedData = await processData(data);<br>        console.log(&quot;Processed data:&quot;, processedData);<br>    } catch (error) {<br>        console.error(&quot;Error fetching or processing data:&quot;, error);<br>    }<br>}</pre><h3>Embrace the Async Future</h3><p>Asynchronous operations are an inherent part of JavaScript development. Promises are of great value for this purpose since they help developers process their JS code in a logical sequence. They can be used to get rid of any messy, unstructured, and inefficient code regarding async execution, which will make your applications more solid and maintainable. Thus, immerse yourself, try out, and discover all the benefits of asynchronous Kockabyt!</p><h3>Level Up Your Skills</h3><p>Lastly, now that you have been introduced to Promises, it is time to start using them. Start your exercise by visiting the Promise object in the JavaScript documentation and try to develop some asynchronous functions using Promises and async/await. Please do not forget that practice is the key to success!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81885e7931bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>