<?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: Thabang Ndlovu</title>
    <description>The latest articles on DEV Community by Thabang Ndlovu (@cyannrogue).</description>
    <link>https://dev.to/cyannrogue</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%2F420113%2Fddaaa4a3-a8bd-4601-acf8-f896d8f0fc7d.jpg</url>
      <title>DEV Community: Thabang Ndlovu</title>
      <link>https://dev.to/cyannrogue</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cyannrogue"/>
    <language>en</language>
    <item>
      <title>SOLID PRINCIPLES IN JAVASCRIPT: WHAT THEY ARE, WHY YOU SHOULD USE THEM, AND HOW TO IMPLEMENT THEM</title>
      <dc:creator>Thabang Ndlovu</dc:creator>
      <pubDate>Sat, 23 Jul 2022 19:52:07 +0000</pubDate>
      <link>https://dev.to/cyannrogue/solid-principles-in-javascript-what-they-are-why-you-should-use-them-and-how-to-implement-them-216j</link>
      <guid>https://dev.to/cyannrogue/solid-principles-in-javascript-what-they-are-why-you-should-use-them-and-how-to-implement-them-216j</guid>
      <description>&lt;p&gt;Software development has evolved rapidly in the past few years, and with it comes new paradigms for writing code. These principles are not just useful for making software easier to read and understand; they also make it more maintainable and extendable. If you’re a developer working on JavaScript projects, you’ve probably heard about the importance of following the SOLID principles. These principles not only help to organize your code appropriately, but also reduce coupling between classes and unwanted dependencies. In this blog post, we’ll look at what each of these principles is, why you should use them, and how you can implement them in your programming projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are SOLID principles?
&lt;/h2&gt;

&lt;p&gt;SOLID stands for “solid” principles. These are five principles of software design that help to organize your code in a more maintainable and extensible way, as well as facilitate unit testing. The five SOLID principles are: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Single responsibility principle (SRP)&lt;/li&gt;
&lt;li&gt;Open-Closed Principle (OCP)&lt;/li&gt;
&lt;li&gt;Liskov substitution principle (LSP)&lt;/li&gt;
&lt;li&gt;Interface segregation principle (IP)&lt;/li&gt;
&lt;li&gt;Dependency inversion (DIP) &amp;amp; don’t break the chain (DBTC)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Single responsibility principle (SRP)
&lt;/h3&gt;

&lt;p&gt;The single responsibility principle states that every module or class should have one and only one purpose, and that responsibility should be entirely encapsulated inside of the module. The SRP is one of the most important SOLID principles, since breaking it often leads to software with higher coupling. The most important thing about this principle is to ask yourself, "What is the one and only thing this module or class is responsible for?" To break the single responsibility principle, a class or module would have to have more than one responsibility. For example, let’s say that we have a module that handles all our data. This module has functions that both query and store data. By following the SRP, we would create two modules: one that handles data input and another that handles data output.&lt;/p&gt;

&lt;h3&gt;
  
  
  SRP in JavaScript: Why and how to use it
&lt;/h3&gt;

&lt;p&gt;The SRP is a principle that many people struggle with when first implementing it. However, breaking the SRP can create issues in your code that might seem difficult to track down. As mentioned above, the SRP states that every module or class should have one and only one purpose. This means that each module or class should only be responsible for doing one thing, and nothing else. This helps to decrease coupling, which allows for easier extensibility and maintainability. If you’re working with a large team, it can be difficult to ensure that each module or class follows the SRP. If one person follows the principle and another doesn’t, it can create confusion and make it difficult to follow the code. However, there are a few things that you can do to help keep your code organized and adhere to this principle. The first thing would be to always ask yourself, "Is this module or class doing one thing?" If you find that it’s doing more than one, you can break it into smaller and more manageable pieces. Another thing you can do if you’re working with a team is to sit down with your teammates from time to time and ask them if their modules or classes follow the SRP. It’s also important to keep in mind that different programming languages, frameworks, and libraries have different conventions for naming classes and modules. You may find that your code breaks the SRP simply because of the way you’ve named your modules and classes.&lt;/p&gt;

&lt;h4&gt;
  
  
  SRP with react: Why and how to use it
&lt;/h4&gt;

&lt;p&gt;React is a popular front-end development framework that uses components as building blocks for creating applications. Components function as modules and are used to create modular and reusable chunks of code that can be combined in different ways. This makes it easier to break down the code into modules that follow the single responsibility principle. If you decide to follow the SRP when creating your react components, you will create components whose only responsibility is to display some information. You wouldn’t have a single component that handles both the display of information and data fetching. This would help to break down the code into smaller and more manageable pieces, which would help to follow the SRP.&lt;/p&gt;

&lt;h4&gt;
  
  
  SRP with react and Redux : Why and how to use it
&lt;/h4&gt;

&lt;p&gt;If you’re using a state management library such as Redux, you may be tempted to store all your data in the store. However, the store should only contain data that can be retrieved and displayed. This means that you shouldn’t store information that is only used to update the state of the application. Instead, you would create action creators that are responsible for transforming data from one state to another. This helps to follow the single responsibility principle since action creators have only one purpose; transform data from one state to another.&lt;/p&gt;

&lt;h3&gt;
  
  
  Open-Closed Principle
&lt;/h3&gt;

&lt;p&gt;The Open-Closed Principle is a design principle that states that software should be open for extension and closed for modification. The principle was popularized by Eric Meyer in his book, Object-Oriented Design: A Systems Approach. In short, the goal of the Open-Closed Principle is to ensure that software is extensible but not modifiable. This means that an application should be able to expose functionality through its API (Application Programming Interface), but it should not be possible for users to change or modify the code behind that functionality. By adhering to this principle, you can ensure that your applications are easy to maintain over time and are well-suited for integration with other applications or services. One of the main benefits of adhering to the Open-Closed Principle is that it can help prevent bugs from creeping into your system. If you tightly guard your APIs, users will be unable to add their own features or customizations without causing problems for you.&lt;/p&gt;

&lt;h3&gt;
  
  
  Liskov Substitution Principle (LSP)
&lt;/h3&gt;

&lt;p&gt;The Liskov Substitution Principle (LSP) is a principle of object-oriented programming that states, “Any object that can be used in place of any other object should be assignable to the other object.” This means if you want to change the content of an object, it must be possible to do so without breaking the behavior of any other object. If an author wants to change the content of one of their objects, they first need to make sure that it is possible to do so without breaking the behavior of any other objects. If this cannot be guaranteed, then they should consider whether it is worth changing the content at all and instead refactor the code.&lt;/p&gt;

&lt;p&gt;In JavaScript, this principle can be stated as: “You should not assume that any JavaScript object is interchangeable with any other JavaScript object.”&lt;/p&gt;

&lt;h3&gt;
  
  
  Interface segregation principle (IP)
&lt;/h3&gt;

&lt;p&gt;The interface segregation principle states that unrelated modules and classes should be kept separate from each other. This means that each module or class should only have access to the pieces of data that it needs in order to do its job. This helps to avoid coupling, which is especially important when working with third-party libraries. For example, if you have a third-party library that helps you with data visualization, you wouldn’t want to have that library’s code imported into your data retrieval module. This would cause a coupling between the two modules, which would make it difficult to make changes to both modules since they would rely on each other. By following the IP, you would keep the two modules separate, which would make it easier to make changes and break the coupling between the two modules.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dependency inversion (DIP)
&lt;/h3&gt;

&lt;p&gt;The dependency inversion principle states that the code should depend on abstractions instead of concrete implementations. This means that a module or class should use a function or an interface that returns an instance of that function or interface. An example of this would be a module that retrieves and stores data from a database. That module should only use an interface such as an ORM module to retrieve data from the database. This would allow that module to be used with any database because it doesn’t depend on a concrete implementation.&lt;/p&gt;

&lt;h4&gt;
  
  
  DIP with ES6 Classes
&lt;/h4&gt;

&lt;p&gt;JavaScript uses the class keyword to define classes and the new keyword to create instances from those classes. Classes are used to create objects that can be customized. Following the DIP with ES6 classes would mean that each class only uses the class keyword and doesn’t use the new keyword. This would allow each class to be used independently as an abstraction.&lt;/p&gt;

&lt;h3&gt;
  
  
  Don’t break the chain (DBTC)
&lt;/h3&gt;

&lt;p&gt;The DBTC principle is the last of the SOLID principles. This principle states that every link in a chain should be strong enough to sustain the weight of the chain. This means that every single link in your code should be well-written and adhere to the SOLID principles. This would ensure that the entire codebase follows the SOLID principles and would be easy to read and maintain.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>V8 Engine and How it Optimizes Your JavaScript Code</title>
      <dc:creator>Thabang Ndlovu</dc:creator>
      <pubDate>Tue, 05 Jul 2022 14:26:45 +0000</pubDate>
      <link>https://dev.to/cyannrogue/v8-engine-and-how-it-optimizes-your-javascript-code-cgm</link>
      <guid>https://dev.to/cyannrogue/v8-engine-and-how-it-optimizes-your-javascript-code-cgm</guid>
      <description>&lt;p&gt;Today’s digital world is all about speed and performance. The moment users land on your webpage, you have less than 1 second to impress them. If the site takes more than 3 seconds to load, they will abandon it and look for an alternative that loads faster. The V8 engine is an essential part of Google Chrome because it optimizes your JavaScript code and makes it run faster. But what exactly is the V8 engine and how does it optimize your code? Keep reading to find out!&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a V8 Engine?
&lt;/h2&gt;

&lt;p&gt;The V8 engine is the open-source JavaScript engine that powers Chrome and Node.js. What this means is that V8 takes the human readable code written in JavaScript and compiles it into machine code that the computer can understand and execute. To understand this better, let’s take the example of Java. When Java is running on your machine, you can see the actual code that’s running on your system. This is not the case with JavaScript. Even though we can see the code on the screen, it’s not the actual code that’s running. The code that we see is a human-readable representation of the actual code that’s running on our system. This is because JavaScript is an interpreted language, which means a program called a “compiler” translates the code from human-readable form to actual machine code.&lt;/p&gt;

&lt;h2&gt;
  
  
  3 Reasons Why You Should Care About V8 Engine
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Fast Loading Times
&lt;/h3&gt;

&lt;p&gt;The first reason you should care about V8 Engine is that it makes your site load faster. V8 engine compiles the human-readable code into an actual machine-readable code. This means that the browser can read and process the code much quicker than it would if it were in a human-readable form. So, if your site is built on JavaScript, you can rest assured that your site will load much faster than it would with a different language. &lt;/p&gt;

&lt;h3&gt;
  
  
  Improved Performance
&lt;/h3&gt;

&lt;p&gt;The second reason you should care about the V8 Engine is that it can improve your site’s performance. This means that your site will run smoothly, without any hiccups. V8 Engine does this by optimizing your code so that there is less lag and fewer errors. The fewer lag and errors your site have, the smoother and more enjoyable it will be for your visitors. &lt;/p&gt;

&lt;h3&gt;
  
  
  Optimized
&lt;/h3&gt;

&lt;p&gt;for Modern Apps - The third reason you should care about the V8 Engine is that it was developed with modern apps in mind. This means that it is equipped with features that will allow you to build more sophisticated and powerful apps than you could with other languages. With a powerful language like JavaScript, your app will be more useful and engaging for your users.&lt;br&gt;
Detecting and Optimizing Runtime Variables and Functions&lt;br&gt;
Another way the V8 optimizes your code is by detecting and optimizing runtime variables and functions. It can find which variables and functions are used during runtime and compile only those needed. This means that it compiles only what you need and nothing more, which means that your code will run faster. This works by using a two-step process. First, it loads the code and marks all the runtime variables as “unused”. Once the code is finished loading, it goes through the code again and marks all the variables that are being used. This way, it knows which variables and functions to compile and which ones to discard.&lt;/p&gt;

&lt;h2&gt;
  
  
  Garbage Collection in v8
&lt;/h2&gt;

&lt;p&gt;Another important function of the V8 engine is garbage collection. This is how the V8 engine keeps the memory free from unused data. This is important because if there is a piece of data in the memory that your application does not need, then it is taking up space that could be used by something else. So, the V8 engine cleans up this unused data so that more data can be stored in the memory and your application can run smoothly. There are separate ways in which garbage collection can be conducted, but one of the most popular methods is reference counting. This means that the computer keeps track of how many places the data is being used, and once no places are using it, the computer removes it. This is important because your computer’s resources are finite, and you don’t want it to store data that it doesn’t need.&lt;/p&gt;

&lt;h2&gt;
  
  
  JavaScript Compiler in V8
&lt;/h2&gt;

&lt;p&gt;Another important function of the V8 engine is the JavaScript compiler. This is the part of the engine that compiles your human-readable code into actual machine code. The compiler handles turning your code into something that the computer can understand and execute. V8 engine’s compiler has been open source from the very beginning, which means that anyone can look at the code and learn from it. This makes it easier for developers to understand and control the compilation process, which means that they have more power over their code and can use it more efficiently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The V8 engine is an important part of Google Chrome because it optimizes your JavaScript code and makes it run faster. This is important for a couple of reasons. First, it means that your site will load faster, which is important because people are less likely to visit a site that takes a long time to load. Second, it means that your site will run more smoothly, which is important because no one likes to visit a site that freezes or lags. If your site is built on JavaScript, you can rest assured that it will be optimized by the V8 engine and run smoothly and quickly.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Understanding JavaScript Engines as a Web Developer</title>
      <dc:creator>Thabang Ndlovu</dc:creator>
      <pubDate>Sun, 26 Jun 2022 22:34:00 +0000</pubDate>
      <link>https://dev.to/cyannrogue/understanding-javascript-engines-as-a-web-developer-3eaj</link>
      <guid>https://dev.to/cyannrogue/understanding-javascript-engines-as-a-web-developer-3eaj</guid>
      <description>&lt;p&gt;An engine is a software component that interprets and executes code. When it comes to programming languages, there are specific types of engines that are responsible for the execution process. This article covers everything you need to know about JavaScript engines as a web developer. You will learn about the different JavaScript engines and their roles as well as when and where you can use them. Keep reading to discover more!&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a JavaScript Engine?
&lt;/h2&gt;

&lt;p&gt;Simply put, a JavaScript engine is a piece of software that interprets the code written in JavaScript programming language and executes those instructions on a computer system. A JavaScript engine is the heart of a browser. It’s responsible for running JavaScript code seamlessly. The code you write in a JavaScript file gets parsed, then interpreted, and finally executed. In addition to running JavaScript code, JavaScript engines also provide the functionality to create and manipulate HTML elements. They also support functions such as CSS and other web standards.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of JavaScript Engines
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Client-side JavaScript Engines
&lt;/h3&gt;

&lt;p&gt;The client-side JavaScript engine is responsible for the execution, parsing, and compilation of the JavaScript code that runs in the web browser. The client-side JavaScript engine is also responsible for the execution of the code that runs when a user requests the server. This is code that is executed on the client-side but does not create or change any user interface elements. &lt;/p&gt;

&lt;h3&gt;
  
  
  Server-side JavaScript Engines
&lt;/h3&gt;

&lt;p&gt;Server-side JavaScript engines are responsible for the execution of the JavaScript code on the server. This code is executed before the server sends the response back to the user. The code runs on the server to generate HTML that is then sent to the user. &lt;/p&gt;

&lt;h3&gt;
  
  
  Hybrid JavaScript Engines
&lt;/h3&gt;

&lt;p&gt;A hybrid engine is a combination of client-side and server-side engines. In most cases, hybrid engines use a language that compiles to both JavaScript and another language such as Java or C#.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to find out which engine your browser uses?
&lt;/h2&gt;

&lt;p&gt;To find out which engine your browser uses, you can use the following function: console.log(navigator.userAgent); You can also use a tool like WhatEngine to find out which engine your browser is using.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why are JavaScript Engines important for web developers?
&lt;/h2&gt;

&lt;p&gt;JavaScript engines are important for web developers because they make the development process much easier and faster. The job of a JavaScript engine is to execute the code written in JavaScript. JavaScript engines can work either on the browser or on the server. The most important thing is that they produce the same result. Modern JavaScript engines are fast and can handle large amounts of code because of their parallelism.&lt;/p&gt;

&lt;h2&gt;
  
  
  V8
&lt;/h2&gt;

&lt;p&gt;A high-performance, open-source, JavaScript engine by Google&lt;br&gt;
Google created its open-source JavaScript engine called V8 which is used in the Chrome web browser. V8 is the main JavaScript engine that runs in the Chrome browser. This JavaScript engine is written in C++. V8 is one of the most popular JavaScript engines used by developers. It is used in more than just Chrome. Other browsers like Safari, Opera, and Firefox use V8 as well. V8 is a high-performance JavaScript engine. It can execute 2 billion JavaScript instructions per second on a user’s computer. V8 is one of the most feature-rich JavaScript engines available. It has a rich set of APIs, a built-in debugger, and a runtime environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  SpiderMonkey
&lt;/h2&gt;

&lt;p&gt;An open source interpreter by Mozilla&lt;br&gt;
SpiderMonkey is an open-source interpreter written by Mozilla. It is used as the default JavaScript engine in Firefox. It is also used in other products like Firefox Developer Tools and the Rust code editor. SpiderMonkey is designed to execute JavaScript code quickly. It can execute approximately one million JavaScript instructions per second on a user’s computer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;JavaScript engines are crucial for the functionality of the web. Modern browsers use highly optimized JavaScript engines that can execute millions of instructions per second. These engines make it possible for web developers to create complex applications that run in the browser. JavaScript engines are responsible for executing the code written in JavaScript. They can also execute code that does not create or change any user interface element. JavaScript engines are important for web developers because they make the development process easier and faster.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
