<?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>Forem: Rowan Ibrahem</title>
    <description>The latest articles on Forem by Rowan Ibrahem (@rowan_ibrahim).</description>
    <link>https://forem.com/rowan_ibrahim</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%2F1504710%2Fdca5f3b7-dc18-4318-bb08-0dbf22b22232.png</url>
      <title>Forem: Rowan Ibrahem</title>
      <link>https://forem.com/rowan_ibrahim</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/rowan_ibrahim"/>
    <language>en</language>
    <item>
      <title>From Manual to Automatic: The Magic of CI/CD Pipelines! 🤯</title>
      <dc:creator>Rowan Ibrahem</dc:creator>
      <pubDate>Sat, 12 Oct 2024 21:37:33 +0000</pubDate>
      <link>https://forem.com/rowan_ibrahim/from-manual-to-automatic-the-magic-of-cicd-pipelines-21hb</link>
      <guid>https://forem.com/rowan_ibrahim/from-manual-to-automatic-the-magic-of-cicd-pipelines-21hb</guid>
      <description>&lt;p&gt;🔴&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Imagine deploying new features without breaking a sweat no more late nights or frantic bug fixes. That's the magic of CI/CD! Ready to learn how this powerful process can turn chaos into seamless, stress-free releases?&lt;/p&gt;

&lt;p&gt;Today we will talk about an important and interesting topic every developer should know, Let’s Discover CI/CD World!&lt;/p&gt;

&lt;p&gt;🟢&lt;strong&gt;Table of contents&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What is CI/CD? &lt;/li&gt;
&lt;li&gt;What is a pipeline?&lt;/li&gt;
&lt;li&gt;Benefits of CI/CD &lt;/li&gt;
&lt;li&gt;CI/CD Tools &lt;/li&gt;
&lt;li&gt;Firebase App Distribution &lt;/li&gt;
&lt;li&gt;Fastlane &lt;/li&gt;
&lt;li&gt;Upload the first APK&lt;/li&gt;
&lt;li&gt;Conclusion &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;CI/CD&lt;/strong&gt; stands for Continuous Integration and Continuous Delivery. But what does all that mean? Let's break it down:&lt;/p&gt;

&lt;p&gt;📌 &lt;strong&gt;CI (Continuous Integration)&lt;/strong&gt;: This process starts with building your code and pushing it to a platform like GitHub. From there, automated tests and deployments are triggered to ensure everything is working smoothly.&lt;/p&gt;

&lt;p&gt;📌 &lt;strong&gt;CD (Continuous Delivery)&lt;/strong&gt;: The DevOps engineer takes over here. They handle deploying the tested code to the server, making it accessible to the client. They also monitor the deployment closely, so if any issues pop up, they can quickly notify the developers to address them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fg3ajfwehnb1jtnca4o0j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fg3ajfwehnb1jtnca4o0j.png" alt="Image description" width="318" height="159"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;📌&lt;strong&gt;Let's see the flow that used to happen without CI/CD&lt;/strong&gt;&lt;br&gt;
The developer finishes the code and informs the tester that the code has been pushed to GitHub. The tester then checks it and performs tests. After that, the tester reports any issues to the developer or informs the DevOps (responsible for deploying the project to the server) that the code is fine. The DevOps then takes the code for deployment. This happens manually, increasing the time and effort required as each person waits for the other to complete their task.&lt;br&gt;
CI/CD transformed the integration and deployment process into an automatic one by building a pipeline containing all the required commands. These commands are automatically executed upon being triggered.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So, What is a pipeline?&lt;/strong&gt;👀&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fcgjywye75m65qk0oc6bi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fcgjywye75m65qk0oc6bi.png" alt="Image description" width="800" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As the name suggests, a pipeline is like a tube through which code flows in a specific sequence that we define. The flow goes as follows: After creating the project, we push it to GitHub. As soon as this push happens, a tool takes the code and builds it. Then it moves to another tool for testing. If the code passes the tests, it continues to the deployment stage and gets deployed to the server or Google Play. If there is an issue, the pipeline stops, and the developer is informed about the issue that must be fixed before continuing the deployment and build process.&lt;/p&gt;

&lt;p&gt;✅&lt;strong&gt;To create this pipeline, we have several tools&lt;/strong&gt; like Jenkins, GitHub Actions, GitLab, Fastlane, and Circle CI. These are tools where you write a file in your project specifying the commands you want to be executed when a push occurs. &lt;br&gt;
These tools then automatically execute the pipeline and the commands written in it. The following image illustrates different tools used at each stage. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F9dhc3jywe8d825y9ncez.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F9dhc3jywe8d825y9ncez.png" alt="Image description" width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🟢&lt;strong&gt;Benefits of using CI/CD tools&lt;/strong&gt;&lt;br&gt;
When I want to add a new feature, I won’t have to build and upload it manually every time. If I make any changes, it will automatically run tests, and if it fails, it won’t be deployed at all. Instead, it’ll notify the developer about the issue so they can fix it—rather than discovering the problem later with the client. This process improves the product's quality in the long run and reduces the time and effort needed for building, testing, and deployment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fw5uurvdbceiiul2lgfx6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fw5uurvdbceiiul2lgfx6.jpg" alt="Image description" width="700" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So, all of this mostly involves DevOps work. How does it benefit me as a mobile developer?&lt;/strong&gt;📍&lt;br&gt;
When we build our application, we need to send an APK to the tester to test the features built, show a demo to the client, or even upload to Google Play and update the existing version. All of this is done manually, but we can do it automatically with a single command line without needing to build the APK every time or even upload it ourselves. Let’s explore how we can do this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For Flutter, the tools that help us with this are:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Firebase Distribution&lt;/li&gt;
&lt;li&gt;Fastlane&lt;/li&gt;
&lt;li&gt;GitHub Actions&lt;/li&gt;
&lt;li&gt;Code Magic
We will learn about them in detail and see how to integrate them into our project.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;📌 &lt;strong&gt;So, imagine we're working on our project, and it's time to send the APK to the tester. Of course, we won’t be sending it over WhatsApp or uploading it to Google Drive every time, right? We’ve got a much better solution! We’ll put the APK in a dedicated space, and this place will automatically send an email to the tester with a direct download link for the new version of the app. It’s like having your own private distribution channel where you store all the releases, and the system takes care of the rest. But what is this magical place? Let’s find out!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now we will know what is Firebase App Distribution&lt;/strong&gt; 🤔&lt;br&gt;
It’s a service in Firebase that allows you to send the APK to testers, making the testing process easier before the release stage. Plus, it’s cross-platform, so you can use it on both Android and iOS.&lt;br&gt;
On Google Play, you have tracks, and on the App Store, there’s TestFlight both are services designed to simplify the testing process before release and to manage different versions smoothly.&lt;/p&gt;

&lt;p&gt;📌 The first step to use this service is, as the name suggests, it’s part of Firebase services, so you need to link your project to Firebase. Here’s the documentation to guide you through connecting your project to Firebase in just a few simple steps: Firebase Documentation.&lt;/p&gt;

&lt;p&gt;After that, head over to your project in Firebase, and go to App Distribution.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F4u6zwjmc6iudyydi5a3n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F4u6zwjmc6iudyydi5a3n.png" alt="Image description" width="800" height="235"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the UI : &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fuhbsdptyppchneq9y6qo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fuhbsdptyppchneq9y6qo.png" alt="Image description" width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;📌 First, we'll generate the APK manually. Navigate to your project and enter this command in the Terminal:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F3ej4ooinc0osx03bb1w4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F3ej4ooinc0osx03bb1w4.png" alt="Image description" width="800" height="124"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And if you're using flavors (which we’ll cover in another article), use this command:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Faecqx7fz3rz62nvdb8bi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Faecqx7fz3rz62nvdb8bi.png" alt="Image description" width="800" height="61"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;📌 Once the APK is ready, locate it in your project folder and drag and drop it into App Distribution (as shown in image #1 above). That’s it the APK is now uploaded!&lt;/p&gt;

&lt;p&gt;📌 To add testers, go to the Testers and Groups tab (marked as #2). Here, you can add multiple testers by entering their emails and even organizing them into groups. An email will then be sent to each tester, prompting them to download the App Tester application, where they can access the uploaded APK.&lt;/p&gt;

&lt;p&gt;📌 You can also add Release Notes, and testers can send you their feedback or comments directly through the app.&lt;/p&gt;

&lt;p&gt;📌 In case there's an issue with the email, you can use Invite Links in tab #3 to share a direct link with testers.&lt;/p&gt;

&lt;p&gt;📌 One of the advantages of Firebase App Distribution is that it can easily integrate with other tools, offers a user-friendly interface, and ensures security for your application.&lt;br&gt;
However, each time you make changes or add a new feature, you’ll still need to manually generate and upload the APK, which means we haven't fully embraced automation yet.&lt;/p&gt;

&lt;p&gt;To automate this process, we’ll integrate it with a tool called Fastlane.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is FastLane?&lt;/strong&gt;🔎&lt;br&gt;
Fastlane is an open-source tool that automates the process of building, testing, and deploying apps. Instead of manually creating an APK each time, you can run a single command in the command line, and Fastlane takes care of the rest! Plus, it can automatically upload your app to Google Play or the App Store.&lt;/p&gt;

&lt;p&gt;For example, you can use the scan action to run tests on your app before uploading it to Google Play or the App Store, and it even connects directly with these platforms. You can explore more actions in the documentation here:&lt;br&gt;
 &lt;a href="https://docs.fastlane.tools/" rel="noopener noreferrer"&gt;https://docs.fastlane.tools/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;📌 While Fastlane is easy to use, the installation can be a bit tricky at first. But after that, it’s smooth sailing, and you can use it for both Android &amp;amp; iOS.&lt;/p&gt;

&lt;p&gt;📌 Fastlane is built on Ruby, so the first step is to install Ruby on your machine, along with Bundler, which is a package manager for Ruby. We’ll start by installing rbenv, which allows you to use different Ruby versions for each project.&lt;/p&gt;

&lt;p&gt;You can follow the setup instructions here based on your OS (macOS or Windows):&lt;br&gt;
 &lt;a href="https://www.ruby-lang.org/en/documentation/installation/#manager" rel="noopener noreferrer"&gt;https://www.ruby-lang.org/en/documentation/installation/#manager&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;📌 To confirm Ruby is installed, open the terminal and run:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fsrusy1as9f4ekwhwr477.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fsrusy1as9f4ekwhwr477.png" alt="Image description" width="800" height="54"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you see the version number, you're good to go. If you get a "command not found" error, there might be an issue with your path variables that needs adjusting. If you encounter this problem, feel free to ask for help.&lt;/p&gt;

&lt;p&gt;📌 Since I faced some challenges with this method, I downloaded Ruby directly from the official site: &lt;a href="https://rubyinstaller.org/" rel="noopener noreferrer"&gt;https://rubyinstaller.org/&lt;/a&gt;&lt;br&gt;
Install it as you would any other software, and to verify, run:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F5u0vjcqznnwj07zw72ca.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F5u0vjcqznnwj07zw72ca.png" alt="Image description" width="800" height="61"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If the version number appears, Ruby is installed, and you can skip using rbenv.&lt;/p&gt;

&lt;p&gt;📌 Next, install Bundler with this command:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fmwdxygpyldg8lpjci1cw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fmwdxygpyldg8lpjci1cw.png" alt="Image description" width="800" height="65"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;📌 The gem command helps install any Ruby-related packages. Go to your Android project and create a Gemfile where you define the dependencies, like Fastlane. Add this to the Gemfile:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fsbodmdz7dws8hxd6ldrq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fsbodmdz7dws8hxd6ldrq.png" alt="Image description" width="800" height="85"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, run in the terminal:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F132jpc1mse9mvemba3a8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F132jpc1mse9mvemba3a8.png" alt="Image description" width="800" height="85"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will generate a Gemfile.lock file and complete the installation.&lt;/p&gt;

&lt;p&gt;📌 &lt;strong&gt;To install Fastlane, use:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F1kyphuplrsue1q19s0bt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F1kyphuplrsue1q19s0bt.png" alt="Image description" width="800" height="65"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;📌** It will ask for the package name, which you can find in:**&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fmwi5z5hymz1sb3dueyyj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fmwi5z5hymz1sb3dueyyj.png" alt="Image description" width="800" height="58"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;📌 *&lt;em&gt;You’ll get a series of prompts choose *&lt;/em&gt;"no" and press enter for the rest until it finishes. This will generate two files: Appfile and Fastfile. &lt;br&gt;
The Appfile contains configurations, while the Fastfile is where we define actions, like generating an APK, deploying to Google Play, or even printing something. It’s like defining functions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To execute the commands in the Fastfile, use:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fut6z46dlmt6edq6qcq24.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fut6z46dlmt6edq6qcq24.png" alt="Image description" width="800" height="60"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you see "Fastlane worked successfully," then it’s all setup! Now, we have Firebase App Distribution and Fastlane installed separately, but we need to link them to automate the process.&lt;/p&gt;

&lt;p&gt;📌 &lt;strong&gt;To integrate Firebase App Distribution with Fastlane, go to the "Beta Deployment" section in the Fastlane documentation and search for Firebase App Distribution. Then, run:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F6a19g81g2oprjcn74t47.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F6a19g81g2oprjcn74t47.png" alt="Image description" width="800" height="67"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next, Fastlane needs to know which project to work on. Make sure you’ve set up Firebase authentication and installed the Firebase CLI by running:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F66dx96y6qyw6i0m83106.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F66dx96y6qyw6i0m83106.png" alt="Image description" width="800" height="63"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will open a browser for you to log in to Firebase. Once successful, you’ll receive a token in the terminal to keep it safe for later.&lt;br&gt;
Now, you’re ready to write the actions you want directly in the Fastfile! 🥳&lt;/p&gt;

&lt;p&gt;Now, Let’s see the Syntaxs : &lt;br&gt;
📌** What is a lane?**&lt;br&gt;
Lanes in Fastlane are similar to functions, each serving a specific purpose, such as building an APK, deploying an app to Firebase, and other development-related tasks.&lt;/p&gt;

&lt;p&gt;Let’s take a look at an example for clarification:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fdklaf8t95il0fhmbr5az.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fdklaf8t95il0fhmbr5az.png" alt="Image description" width="800" height="530"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;📌 Do:&lt;br&gt;
This indicates that the specified lane should be executed.&lt;br&gt;
📌 Desc:&lt;br&gt;
This is a description of what the lane does, written to explain its functionality.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here’s how it works:&lt;/strong&gt;&lt;br&gt;
The first part after the "lane" keyword is the name of the lane, which you can name as you like. Then, I instruct it to execute the tasks written under "do."&lt;/p&gt;

&lt;p&gt;Next, the section related to Firebase App Distribution is taken directly from the documentation, along with some required data.&lt;/p&gt;

&lt;p&gt;Important Note: Make sure to check the documentation for both Firebase App Distribution and Fastlane together, as there may be missing information in one or more documents, including additional attributes and detailed explanations.&lt;/p&gt;

&lt;p&gt;App ID: This is retrieved from your Firebase project, and I will provide a screenshot from the site.&lt;/p&gt;

&lt;p&gt;Firebase CLI Token:&lt;br&gt;
This token is used to refresh the authorization periodically to avoid errors like "unauthorized" or not being able to access the server. When it refreshes automatically, it works fine. This is the token we saved earlier in our notes.&lt;/p&gt;

&lt;p&gt;Next, we have:&lt;br&gt;
android_artifact_type:&lt;br&gt;
This indicates whether you are uploading an APK or an app. You need to specify the path where the file will be located.&lt;/p&gt;

&lt;p&gt;Go to:&lt;br&gt;
Build -&amp;gt; app -&amp;gt; outputs -&amp;gt; flutter-apk -&amp;gt; app-release.apk&lt;br&gt;
Take the path of the file and place it. It should look like this in the end:&lt;br&gt;
../build/app/outputs/flutter-apk/app-release.apk&lt;/p&gt;

&lt;p&gt;Testers: Add the email address of the tester to whom you want to send the email or the client.&lt;/p&gt;

&lt;p&gt;Release Notes: If you want to add notes for the testers.&lt;br&gt;
Now, Fastlane is supposed to take the APK that I generate manually, find the file at the specified path, and upload it to Firebase App Distribution, sending it to the testers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What if I don't want to manually generate the APK and want Fastlane to do it for me?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We can add two lines at the beginning of the Fastfile, right after the do keyword:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F1mzyvaftutpuq1fmumlj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F1mzyvaftutpuq1fmumlj.png" alt="Image description" width="800" height="89"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, sh indicates that these commands should be executed in the terminal. Every time I upload the APK, I will change the version number to ensure each new release is distinct from the previous one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To run this and execute the workflow, I will write in the terminal:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fq3q2qrujsb0fj71qbl3n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fq3q2qrujsb0fj71qbl3n.png" alt="Image description" width="800" height="63"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This will start the build process with the steps I specified until it indicates a successful build! 🎊&lt;/strong&gt;&lt;br&gt;
It’s common to encounter issues during this setup; it's generally the most challenging part, but once done, the building process becomes easy every time.&lt;br&gt;
This applies to Android.&lt;/p&gt;

&lt;p&gt;📌 If you want to connect with Google Play, you can check this article:&lt;br&gt;
Automating the Flutter App Play Store Release Process Using Fastlane&lt;br&gt;
Next time, we will learn how to create a workflow using GitHub Actions! 🌟&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt; ✅&lt;br&gt;
The concept of Continuous Integration and Continuous Deployment (CI/CD) plays a pivotal role in modern software development, making the process faster and more efficient. It begins with writing code, followed by automated testing, and culminates in seamless deployment. Tools like Jenkins, GitHub Actions, and SonarQube facilitate this process, ensuring that the code is thoroughly tested, properly integrated, and secure during deployment.&lt;br&gt;
By implementing CI/CD practices, developers can significantly reduce potential issues in the code, enhance the user experience, and bolster security measures. This streamlined approach not only minimizes the time spent on deployment but also mitigates the risks associated with software releases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;That's it! Start to write your first pipeline! Connect with me on LinkedIn and GitHub for more articles and insights. If you have questions, contact me.&lt;br&gt;
&lt;a href="https://linktr.ee/rowan_ibrahim" rel="noopener noreferrer"&gt;https://linktr.ee/rowan_ibrahim&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Happy coding and happy deploying!🌟&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fznaecz2lnafhs6inlcfa.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fznaecz2lnafhs6inlcfa.jpg" alt="Image description" width="629" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>firebase</category>
      <category>fastlane</category>
      <category>cicd</category>
    </item>
    <item>
      <title>Beyond Bugs: The Hidden Impact of Code Quality (Part 2) 🌟</title>
      <dc:creator>Rowan Ibrahem</dc:creator>
      <pubDate>Fri, 30 Aug 2024 18:01:46 +0000</pubDate>
      <link>https://forem.com/rowan_ibrahim/beyond-bugs-the-hidden-impact-of-code-quality-part-2-3340</link>
      <guid>https://forem.com/rowan_ibrahim/beyond-bugs-the-hidden-impact-of-code-quality-part-2-3340</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
As we mentioned in the last part about the importance of code quality and standards, today we will talk about tools to help in measuring it and visualize detailed reports about your code. Finally, we will know some tips to improve our code. Let’s Start 🌟&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F22sfq7i4bv4vmhp7gtmr.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F22sfq7i4bv4vmhp7gtmr.jpg" alt="Image description" width="481" height="610"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🟢Table of contents&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tools to measure Code Quality.&lt;/li&gt;
&lt;li&gt;Tips for Improving Code Quality.&lt;/li&gt;
&lt;li&gt;Conclusion.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Tools Used to Measure Code Quality 🔏&lt;/strong&gt;&lt;br&gt;
In a world overflowing with data, numbers often speak louder than words. That’s why some tools can analyze your code for you, using proven methods and techniques to offer suggestions for edits and improvements. &lt;br&gt;
These tools also provide visualized reports and charts about your code.&lt;br&gt;
They can integrate with version control systems like GitHub to access repositories directly or operate locally on your machine.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Sonarqube&lt;/strong&gt;
It’s an open-source quality management tool that detects various types of issues such as bugs, vulnerabilities, code smells, and security hotspots
It comes with built-in quality profiles designed for each supported language. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;SonarQube includes a feature called SonarLint, and you can add it to your code to analyze it locally. You can integrate SonarLint as a plugin within your IDE for real-time feedback.&lt;/p&gt;

&lt;p&gt;How does it work?&lt;br&gt;
Sonar Qube has some rules that are based on code quality standards. When you configure your project and download the sonar scanner, it starts to analyze your code, and then it takes roles from the Sonarqube server.&lt;br&gt;
Roles are based on software quality and clean code attributes that measure how your code is quality.&lt;/p&gt;

&lt;p&gt;It applies for these roles in the scanned code, then it generates reports and shows them in your dashboard like this &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faitr21crg8q3ng48eipu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faitr21crg8q3ng48eipu.png" alt="Image description" width="800" height="304"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, he passed the code, but there are some issues that he needs to fix.&lt;br&gt;
It produces details of each issue, where is it in your code and how to fix it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffcakvw0dlfhfrilp3h6l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffcakvw0dlfhfrilp3h6l.png" alt="Image description" width="800" height="272"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Additionally, the CI/CD Pipeline can accommodate its implementation. If you are unfamiliar with what it is, that’s alright - you can utilize it independently.&lt;/p&gt;

&lt;p&gt;To be honest, not all issues are true all the time, you just will read it and see what needs to be fixed.&lt;br&gt;
&lt;strong&gt;You can install it on Windows, Linux,macOS, or with Docker, see the full documentation here&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://docs.sonarsource.com/sonarqube/latest/" rel="noopener noreferrer"&gt;https://docs.sonarsource.com/sonarqube/latest/&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;This excellent resource for understanding it&lt;/strong&gt; &lt;br&gt;
&lt;a href="https://youtube.com/playlistlist=PLDhScTEBdP8ym3PaMkkTVuaaVHV2ktI0j&amp;amp;si=6Sg8nAukTWyXWbk2" rel="noopener noreferrer"&gt;https://youtube.com/playlistlist=PLDhScTEBdP8ym3PaMkkTVuaaVHV2ktI0j&amp;amp;si=6Sg8nAukTWyXWbk2&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;- code climate&lt;/strong&gt; &lt;br&gt;
It’s like Sonarqube but doesn’t offer detailed reports and doesn’t support all languages, you can see it from here &lt;br&gt;
&lt;a href="https://codeclimate.com/" rel="noopener noreferrer"&gt;https://codeclimate.com/&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CodeScene:&lt;/strong&gt; 
This tool builds on the open-source project Code Maat to analyze every file and every commit in the repo and identify hotspots and churns.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It generates visualized metrics, making it easier to decide where to focus on your quality improvement efforts. &lt;br&gt;
You can install the code scene IDE extension.&lt;/p&gt;

&lt;p&gt;The dashboard generates visual reports about code health and identifies areas that require improvement.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsvp8b296kq3szei6iq3w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsvp8b296kq3szei6iq3w.png" alt="Image description" width="800" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It also provides an analysis summary for the repo number of commits, authors, code health, etc…..&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwjs2qkri16db8nbv83s4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwjs2qkri16db8nbv83s4.png" alt="Image description" width="800" height="612"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will find more data if you discover it, not all features are free, but you still can try some of them. &lt;br&gt;
&lt;strong&gt;Discover from here:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://codescene.com/" rel="noopener noreferrer"&gt;https://codescene.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;- SNYK&lt;/strong&gt;&lt;br&gt;
It’s a security platform that focuses on helping developers find and fix vulnerabilities in their code, dependencies, containers, and infrastructure as code (IaC).&lt;br&gt;
It scans code and makes reports of weak parts and how to fix it &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbs8mxvb3jwl8jhkq621f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbs8mxvb3jwl8jhkq621f.png" alt="Image description" width="800" height="558"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You can log in to the dashboard from here:&lt;/strong&gt; &lt;br&gt;
&lt;a href="https://snyk.io/" rel="noopener noreferrer"&gt;https://snyk.io/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6gya221k63a3ah14e82s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6gya221k63a3ah14e82s.png" alt="Image description" width="800" height="399"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When you run it in the terminal, it will be like this:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1c99spvultji3dx4fiin.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1c99spvultji3dx4fiin.png" alt="Image description" width="800" height="207"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;As we say, it checks for code dependencies and containers but don’t make a full check for the security of the code, you should still review it manually.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;See full documentation and how to set up&lt;/strong&gt; &lt;br&gt;
&lt;a href="https://docs.snyk.io/" rel="noopener noreferrer"&gt;https://docs.snyk.io/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We don’t rely on these tools as a main source. You should make a code review manual continuously for your project and enhance the code as you can.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tips to improve 📍&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dev tools are wonderful for debugging your code and improving it continuously. It helps to see how the code takes from memory, CPU, and performance of your app.&lt;/li&gt;
&lt;li&gt;Following the best practice in the language you write, it’s a set of methods and techniques that produce optimal results for your code.
You can learn more about this from here👇🏻 
&lt;a href="https://www.indeed.com/career-advice/career-development/what-are-best-practices" rel="noopener noreferrer"&gt;https://www.indeed.com/career-advice/career-development/what-are-best-practices&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Try to remove unnecessary libraries, packages, or images that aren’t used.&lt;/li&gt;
&lt;li&gt;Ensure that you implement error handling and logging in your code.&lt;/li&gt;
&lt;li&gt;Use images as SVG as possible to reduce the size of the app or the loading time of images.&lt;/li&gt;
&lt;li&gt;Create CI/CD (continuous integration Continuous delivery) pipelines to ensure that we test every push or edit in a feature before starting a new feature. &lt;/li&gt;
&lt;li&gt;Cache your data that is frequently accessed from memory as much as possible to improve performance. &lt;/li&gt;
&lt;li&gt;Loading data asynchronously means loading it in the background without blocking the user interface, so it will enhance the end-user experience. &lt;/li&gt;
&lt;li&gt;Always read the code and refactor it as you can.&lt;/li&gt;
&lt;li&gt;Don’t forget to document your code to express itself. &lt;/li&gt;
&lt;li&gt;Use version control as GitHub to collaborate with the team to make code reviews and track changes in the code over time, it makes it easy to return to any change if there are any errors or bugs.&lt;/li&gt;
&lt;li&gt;Use a linter. It helps in code formatting by checking code syntax errors, style violations, and possible bugs for static analysis. You can use a language linter or write your lines (rules). &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;I recommend reading this book. You will find more details and you will enjoy it:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://people.engr.tamu.edu/slupoli/notes/ProgrammingStudio/supplements/Code%20Complete%202nd.pdf" rel="noopener noreferrer"&gt;https://people.engr.tamu.edu/slupoli/notes/ProgrammingStudio/supplements/Code%20Complete%202nd.pdf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frahyngwcw41cr2qnu5f4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frahyngwcw41cr2qnu5f4.png" alt="Image description" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion ✅&lt;/strong&gt;&lt;br&gt;
The responsibility of measuring code quality is standing for each developer in the project from the team lead, developer, and tester.&lt;br&gt;
This will come from practice and experience. You can go to open-source projects, try to contribute to them, and see how can you maintain the code quality. &lt;/p&gt;

&lt;p&gt;Try to learn OOP, and SOLID Principles and read the clean code book. This will help you to enhance your code quality.&lt;br&gt;
Remember, being a good software engineer isn’t just about delivering products, it’s about delivering high-quality software that stands the test of time.&lt;/p&gt;

&lt;p&gt;This test Cases template sheet, you can use it in your project : &lt;br&gt;
&lt;a href="https://docs.google.com/spreadsheets/d/11nAISjsWE7yVCiL-ihEp4rQ42-7-LeX9TsK03ofO4Z8/edit?usp=sharing" rel="noopener noreferrer"&gt;https://docs.google.com/spreadsheets/d/11nAISjsWE7yVCiL-ihEp4rQ42-7-LeX9TsK03ofO4Z8/edit?usp=sharing&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it! Start to check your Code Quality with these tools! Connect with me on LinkedIn and GitHub for more articles and insights. If you have questions, contact me.&lt;br&gt;
&lt;a href="https://linktr.ee/rowan_ibrahim" rel="noopener noreferrer"&gt;https://linktr.ee/rowan_ibrahim&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Remember, "Later Equals Never." 😉&lt;/p&gt;

</description>
      <category>codequality</category>
      <category>programming</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Beyond Bugs: The Hidden Impact of Code Quality (Part 1) 🌟</title>
      <dc:creator>Rowan Ibrahem</dc:creator>
      <pubDate>Fri, 30 Aug 2024 16:57:46 +0000</pubDate>
      <link>https://forem.com/rowan_ibrahim/beyond-bugs-the-hidden-impact-of-code-quality-3j8l</link>
      <guid>https://forem.com/rowan_ibrahim/beyond-bugs-the-hidden-impact-of-code-quality-3j8l</guid>
      <description>&lt;p&gt;🔴 &lt;strong&gt;Introduction&lt;/strong&gt; &lt;br&gt;
As software engineers, we often encounter unexpected bugs or delays when adding or modifying features that should not occur. Most software engineers focus on finishing the product to deliver it, but did you think about your code quality? Imagine constructing a building on a weak foundation. Adding just one more floor could cause the entire structure to collapse.&lt;/p&gt;

&lt;p&gt;Similarly, poor code quality can lead to software instability and make adding features easier.  Today we will see the hidden importance of code quality and how we develop good software.🧐&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw8ttl5n1sovtp479c9kl.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw8ttl5n1sovtp479c9kl.jpg" alt="Image description" width="500" height="612"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🟢 &lt;strong&gt;Table of contents&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What is Code quality?&lt;/li&gt;
&lt;li&gt;Why it’s important?&lt;/li&gt;
&lt;li&gt;Code Quality standards.&lt;/li&gt;
&lt;li&gt;Factors of Code Quality. &lt;/li&gt;
&lt;li&gt;Tools to measure Code Quality.&lt;/li&gt;
&lt;li&gt;Tips for Improving Code Quality.&lt;/li&gt;
&lt;li&gt;Conclusion.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What is code quality?🤔&lt;/strong&gt;&lt;br&gt;
There is Lehaman’s low say:&lt;br&gt;
“Any system that’s used will need to change”.&lt;br&gt;
That means that you will need to change and update your code every time. &lt;/p&gt;

&lt;p&gt;Imagine that you don’t care about your code quality, so you won’t be able to change your systems without difficulty or many bugs.&lt;/p&gt;

&lt;p&gt;So Code Quality is the desire to create code that is easy to understand and maintain.&lt;/p&gt;

&lt;p&gt;We can say that is a way to measure the efficiency, readability, and usability of the code. We can know the quality by measuring the accuracy and reliability of code and how can it be easy to maintain and read by other developers. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it’s important? 👀&lt;/strong&gt;&lt;br&gt;
There are a few things you shouldn’t rely on:&lt;br&gt;
Future availability - Future memory &lt;/p&gt;

&lt;p&gt;Imagine this scenario: You start a project and say that you will enhance it later but then you get busy and another team will complete the project, so you should ask yourself, Are they will be able to read and maintain it easily? What happens when they add more features? How will that impact the performance and bugs?&lt;br&gt;
Code quality helps the developer re-read and redesign the code.&lt;/p&gt;

&lt;p&gt;By Measuring the Quality of the code we become sure that the end-user will have an enjoyable experience.&lt;/p&gt;

&lt;p&gt;It helps in Reducing future errors, producing good performance, easy to maintain in the future, easy to know the bugs early, and having good security.&lt;/p&gt;

&lt;p&gt;It’s important to remember that every time someone changes the code, there’s a risk of it becoming less organized.&lt;br&gt;
When software lasts for a long time with few errors, it can save a &lt;br&gt;
company money. Instead of paying for additional time to rewrite.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzur275w4z1cgfcujx9zy.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzur275w4z1cgfcujx9zy.jpg" alt="Image description" width="735" height="684"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;✅What are code quality standards?&lt;/strong&gt;&lt;br&gt;
There are many factors called standards to ensure code quality.&lt;br&gt;
The main roles of Code Quality are readability, clarity, reliability, security, modularity, etc... &lt;br&gt;
These qualities make the code easy to understand, change, operate, and debug. Let’s take a thorough analysis of them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Factors of Code Quality ⁉️&lt;/strong&gt;&lt;br&gt;
Maintaining high code quality is essential for developing software that is efficient, maintainable, and scalable. To achieve this, there are several standards and tools available to measure and improve code quality. Let's dive into these standards🤩&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1-Complexity&lt;/strong&gt;&lt;br&gt;
Complexity measures the difficulty of the program or code as we know in the algorithm with Big O, so it’s a measurement of how code is easy to understand and maintain. &lt;br&gt;
Some factors affect the complexity such as lines of code, loops, and conditions.&lt;br&gt;
The recursion function is a simple example of how the code is complex to understand and affect the memory.&lt;/p&gt;

&lt;p&gt;So, Why we should enhance it? 🤔&lt;br&gt;
If the code is less complex, it makes high-quality performance &lt;br&gt;
rather than it affects the resources such as the memory or CPU, and becomes difficult to add new features without negative performance to the project, maybe it will increase the cost of the project. &lt;br&gt;
We have types to measure complexity: &lt;br&gt;
Cyclomatic Complexity - Structural Complexity- Algorithmic Complexity - Cognitive Complexity.🌟&lt;/p&gt;

&lt;p&gt;Let’s take a Simple example &lt;br&gt;
Cyclomatic Complexity: &lt;br&gt;
It is like counting the number of different routes you can take through a city to get from one point to another.&lt;br&gt;
So, in a piece of code, these "routes" are determined by decisions or branches, such as if statements, loops (for, while), and switch cases. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fceqyxhngmsqfkbhkb4gj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fceqyxhngmsqfkbhkb4gj.png" alt="Image description" width="800" height="698"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The complexity here is 3 as we have 3 routes : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The order is paid. &lt;/li&gt;
&lt;li&gt;Order in stock. &lt;/li&gt;
&lt;li&gt;The order isn’t paid.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cognitive Complexity:&lt;/strong&gt; &lt;br&gt;
means that humans can understand and read it easily. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fivz8977pz1e1awymwfb0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fivz8977pz1e1awymwfb0.png" alt="Image description" width="800" height="542"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here you will find it difficult to understand it from the first time&lt;/p&gt;

&lt;p&gt;We can refactor it to make it more readable with the least nested loops and easy to understand like this : &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy5rlauto7t8afrhkex9g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy5rlauto7t8afrhkex9g.png" alt="Image description" width="800" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are other ways to measure complexity, you can take a look here for more details : &lt;br&gt;
&lt;a href="https://blog.codacy.com/code-complexity" rel="noopener noreferrer"&gt;https://blog.codacy.com/code-complexity&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2- Hotspots and churns&lt;/strong&gt;&lt;br&gt;
It’s like, What’s your coding hiding?🕵🏻‍♀️&lt;br&gt;
Hotspots are parts of the file or the code that are frequently modified to update, add features, or fix bugs.&lt;/p&gt;

&lt;p&gt;They may contain complex code and may cause bugs or require maintenance. &lt;br&gt;
They consume the most resources, like CPU or memory, this is why we need to optimize hotspots to improve performance.&lt;br&gt;
We prioritize them to know which parts need to be maintained. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Churns&lt;/strong&gt;count the number of times a file changes, including code that developers added, modified, or deleted within a codebase over a specific period.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So, how can we know these files?&lt;/strong&gt;&lt;br&gt;
Version system controls like Git&amp;amp;GitHub track every change in all files they produce a history of file changes so you can know which files changed frequently.&lt;br&gt;
You can find it in the GitHub Repo and see the history of commits.&lt;br&gt;
The file that changes a lot has high churns and will be hotspots that need to improve.&lt;br&gt;
We should care about it as if the file knows that it is file changed a lot and has a high complex, it may cause big errors when trying to maintain it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6jv19vjp70f5emjxbs1u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6jv19vjp70f5emjxbs1u.png" alt="Image description" width="800" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3- Reliability&lt;/strong&gt; &lt;br&gt;
This ensures that every function efficiently does its job and if there are unexpected errors, the system will deal with it sufficiently without any crashes. That is why we make error handling. &lt;br&gt;
To ensure that our system is reliable, we can make unit tests for our function to ensure that everything works well.&lt;/p&gt;

&lt;p&gt;We can use debugging and profiling to ensure that our code is efficient.&lt;/p&gt;

&lt;p&gt;At the end of the project, the tester makes an automation test to be sure that the system can deal with any crashes and will not affect the user experience.&lt;/p&gt;

&lt;p&gt;If we know how many times the system fails in some period, we will know the reliability of it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4- Code coverage&lt;/strong&gt;&lt;br&gt;
How good is your test suite?&lt;br&gt;
Code Coverage is a metric to measure the percentage of automated tests to execute how much of your codebase.&lt;br&gt;
It indicates the test cases you’ve written have tested how much of your code, helping you understand which parts of your code are well-tested and which parts may need more testing.&lt;/p&gt;

&lt;p&gt;It produces a percentage of acceptance of the project that we can deliver software or it still needs maintenance based on these tests (unit test -integration test - acceptance test ).&lt;/p&gt;

&lt;p&gt;There are many types of code coverage you can see in more detail here : &lt;br&gt;
&lt;a href="https://www.browserstack.com/guide/code-coverage-vs-test-coverage" rel="noopener noreferrer"&gt;https://www.browserstack.com/guide/code-coverage-vs-test-coverage&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5- Maintainability&lt;/strong&gt;&lt;br&gt;
Sometimes we need to modify, update, or extend the system over time to meet new requirements, so the system should be flexible and able to expand without causing any problems. &lt;/p&gt;

&lt;p&gt;We can make it maintainable in many ways :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Code refactoring to eliminate any duplications and make it clear.&lt;/li&gt;
&lt;li&gt;Documentation: Good documentation provides an overview of the system, how it’s structured, and how different parts interact. It includes code comments, design documents, API documentation, and user manuals. Documentation helps developers quickly get up to speed with the system and understand the implications of their changes.&lt;/li&gt;
&lt;li&gt;Encapsulation and Abstraction: we can make Encapsulation (hiding implementation details) and abstraction (focusing on high-level operations)these concepts in OOP keep changes localized. This minimizes the risk of unintended side effects when the software is modified.&lt;/li&gt;
&lt;li&gt;Modularity divides the software into distinct, independent modules or components. Developers can develop, test, and modify each module separately, reducing the impact of changes on the entire system.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Let’s see an example:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp3waheii5ps02832yq9n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp3waheii5ps02832yq9n.png" alt="Image description" width="800" height="490"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here the function is made more than one job if I want to add or remove an update it will crash&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr7mvuni0oretgchjndcg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr7mvuni0oretgchjndcg.png" alt="Image description" width="800" height="666"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, if I want to add or remove an update, the function performs more than one job and it will crash.&lt;br&gt;
Here is a modular code that separates the different tasks (validation, payment processing, inventory update) into distinct methods. This separation makes the code easier to maintain because each method is responsible for a single task. If you need to change the payment process, for example, you only need to update the process payment method.&lt;br&gt;
This makes the software easy to maintain and makes developers contribute easily and improve the performance of the software.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6- Testability&lt;/strong&gt;&lt;br&gt;
As we mentioned, there are 3 levels of testing (unit test - integration test - Acceptance test) so testability means how easily and effectively you can test a piece of code or a system to ensure it works as expected.&lt;br&gt;
We should ensure that we test our code thoroughly to verify the proper functioning of every function, eliminating any potential errors or bugs in the future, thereby enhancing the user experience and facilitating ease of maintenance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7- Readability&lt;/strong&gt; &lt;br&gt;
As your handwriting should be clear so that people can read it, your code also should be clear and readable for any developer who reads it.&lt;/p&gt;

&lt;p&gt;How can we make our code readable? &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clear naming conventions: you should write descriptive names for classes, variables, and functions that express their objectives.&lt;/li&gt;
&lt;li&gt;Modularity: make code smaller and modular in functions and classes. This will make code easy to maintain and debug.&lt;/li&gt;
&lt;li&gt;Coding style: follow code style in indentation and formatting, make comments to be more easy.&lt;/li&gt;
&lt;li&gt;Code structure: follow clear architecture and pattern in your files &lt;/li&gt;
&lt;li&gt;Avoid any hard coding and don’t forget to make error handling.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiijqzrjdj7opnilykpq0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiijqzrjdj7opnilykpq0.png" alt="Image description" width="800" height="571"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you look here, you will not be able to understand what a or s &lt;br&gt;
You don’t know what is the purpose of function and it’s one method in the main.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fylr1dawpixl68k7ujlh0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fylr1dawpixl68k7ujlh0.png" alt="Image description" width="800" height="677"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here you can find it named more descriptive. We break the method into small methods.&lt;br&gt;
Also, we add comments that make the code easier and formatted well.&lt;br&gt;
So you should make your code self-documented and refactor it as you can.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8- Reusability&lt;/strong&gt; &lt;br&gt;
Like a sault in our food, we can put it on different types of food, Our code should be reusable so that we can reuse it in another component or another project without causing errors.&lt;/p&gt;

&lt;p&gt;How can we ensure from that? &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make your functions and classes into small blocks to be sure that they are reliable and not dependent on another component.
&lt;/li&gt;
&lt;li&gt;Avoid repetition: if you find that you write the same code twice, you should reuse it to make it once and use it anywhere.&lt;/li&gt;
&lt;li&gt;Following SOLID principles will help you.&lt;/li&gt;
&lt;li&gt;Encapsulation and abstraction make reading easier as they make the modules independent.&lt;/li&gt;
&lt;li&gt;Use the Loose Coupling principle that minimizes dependencies between modules.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
Imagine you need to create three different buttons on your project, one on the login page, one on the signup page, and one on the contact page. You might write something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fldw1bhze2l3xbeb964ns.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fldw1bhze2l3xbeb964ns.png" alt="Image description" width="800" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, you've repeated the button code three times, just changing the text and color. If you later decide to change the padding or font size, you'd have to find and update every button manually.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;With Reusability:&lt;/strong&gt;&lt;br&gt;
Instead, you can create a reusable button component in your code&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frg5dun2qhq9nvsaeqs7m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frg5dun2qhq9nvsaeqs7m.png" alt="Image description" width="800" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, use this component in different places with different colors and text:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvkauwv2n99dfhnrtnk7t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvkauwv2n99dfhnrtnk7t.png" alt="Image description" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;See, that saves time and effort when we want to change something, we will change it once.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9- Portability&lt;/strong&gt; &lt;br&gt;
Software can run on different platforms, operating systems, or environments with minimal or no modification.&lt;br&gt;
The system should work in different OS like Windows, Linux, and macOS. &lt;/p&gt;

&lt;p&gt;It should run on different browsers without any bugs or crashes.&lt;br&gt;
If we make an application, it should be flexible to run on different versions of Android or iOS.&lt;br&gt;
The product enhances efficiency and is compatible with a wide range of customers; otherwise, you will have to create different codes for each specific environment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10- Performance&lt;/strong&gt;&lt;br&gt;
The most important factor in code quality is performance.&lt;br&gt;
We do all maintenance and code quality to measure our software's performance because if our software's performance is high, we can say that we make good software and products.&lt;/p&gt;

&lt;p&gt;So performance is how efficiently our code is organized and optimized.&lt;br&gt;
We can measure it from speed, responsiveness, and resource usage.&lt;br&gt;
High performance means that the software operates quickly and effectively, using minimal resources like CPU, memory, and network bandwidth.&lt;/p&gt;

&lt;p&gt;Examples of bad practices that lead to low performance:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Uncompressed images, wrong sizes of images, wrong format of images.&lt;/li&gt;
&lt;li&gt;Including whole libraries when they can be tree-shaken to a fraction of the size.&lt;/li&gt;
&lt;li&gt;Loading everything synchronously when it isn’t needed on a page.&lt;/li&gt;
&lt;li&gt;Not utilizing browser cache.&lt;/li&gt;
&lt;li&gt;Unused packages or images.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every technology and framework has its ways of improving performance you just need to search with “How to improve Performance in …”.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;11- Duplication&lt;/strong&gt; &lt;br&gt;
How much do you repeat yourself?&lt;br&gt;
There is a DRY Principle that says you shouldn’t repeat yourself. Some developers take the code copy and paste if there are two components with the same code, but this very bad practice leads to many problems: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It reduces the performance of the product &lt;/li&gt;
&lt;li&gt;Will cause a big maintenance effort&lt;/li&gt;
&lt;li&gt;When you don’t update the duplicated code consistently, it may lead to 
great risk errors, causing different parts of your application to behave differently even though they were intended to be the same. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;12- Security and dependencies&lt;/strong&gt; &lt;br&gt;
The most important part of releasing your product is to ensure that it is secure from attacks, so security is to follow guidelines and principles to protect your code and data from any attack or unauthorized access.&lt;br&gt;
Dependencies Management Security: dependencies should update every time to prevent attacks.&lt;br&gt;
Your system can face problems if you don’t use a reliable library or framework.&lt;/p&gt;

&lt;p&gt;To ensure that your application is secure, you should take care of these things : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Input validation: you should ensure that input data is valid to prevent SQL injection or cross-site scripting &lt;/li&gt;
&lt;li&gt;Authentication and authorization: you should implement a strong mechanism to control access. I recommend using Key cloak technology as it has high security in authentication &lt;/li&gt;
&lt;li&gt;Data Protection: you should encrypt sensitive data by using techniques such as encryption and secure storage &lt;/li&gt;
&lt;li&gt;Secure coding practices: follow secure coding guidelines and standards (e.g., OWASP, SEI CERT) to prevent common security flaws.&lt;/li&gt;
&lt;li&gt;Security Testing: Conduct regular security testing, including static code analysis, dynamic analysis, penetration testing, and vulnerability scanning, to identify and fix security issues.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Security is important because if happens any attack it will lead to a loss of importance and loss of trust in a client, which will cause financial problems for the company.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;13- Code Style&lt;/strong&gt; &lt;br&gt;
How clean is your code?&lt;br&gt;
A coding style is a set of guidelines on how to format code. For instance, what do you call your variables? Do you use spaces or tabs for indentation? Where do you put comments? It gives your code the same style and is enjoyable to read, especially when working in a team.&lt;/p&gt;

&lt;p&gt;There are style guidelines for each language, but overall, most languages use liners and most Ides support auto-formatting. &lt;br&gt;
For commonly used style guides for various programming languages, see the Language Guides. Google also has a style guide for many languages that are used in open-source projects originating out of Google.&lt;/p&gt;

&lt;p&gt;The coding style is made up of numerous small decisions based on the language:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How and when to use comments,&lt;/li&gt;
&lt;li&gt;Tabs or spaces for indentation (and how many spaces),&lt;/li&gt;
&lt;li&gt;Appropriate use of white space,&lt;/li&gt;
&lt;li&gt;Proper naming of variables and functions&lt;/li&gt;
&lt;li&gt;Code grouping an organization&lt;/li&gt;
&lt;li&gt;Patterns to be used,&lt;/li&gt;
&lt;li&gt;Patterns to be avoided.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3jomazn0mc5gsutr9iem.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3jomazn0mc5gsutr9iem.png" alt="Image description" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Good Version&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftqf18ejibvnx6d1efs2m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftqf18ejibvnx6d1efs2m.png" alt="Image description" width="800" height="769"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Indentation ensures a clear structure by properly indenting each block of code.&lt;br&gt;
Spacing: There should be spaces around operators (+, =) and between method parameters for better readability.&lt;br&gt;
Line Breaks: Each statement is on its line, making the code easier to follow.&lt;br&gt;
Method Naming: Using more descriptive method names (such as addNumbers, printResult) is a good start, but you can further improve them by being more specific (for example, by using calculateSum and displayResult).&lt;br&gt;
Comments: Added comments describing each method, helping others understand the code more easily.&lt;br&gt;
In variable naming, num1, num2, and number are more descriptive than a and b, although there is potential for improvement in all cases.&lt;/p&gt;

&lt;p&gt;See the difference! It’s amazing🤯&lt;/p&gt;

&lt;p&gt;Conclusion ✅&lt;br&gt;
The responsibility of measuring code quality is standing for each developer in the project from the team lead, developer, and tester.&lt;br&gt;
You should always make code reviews to check your code quality and enhance it. &lt;br&gt;
Applying code quality standards ensures your code readability and maintainability of all time, making it easier for developers to collaborate and understand each other’s code. &lt;br&gt;
See you in the next part where we will learn more about tools to measure code quality and tips to improve our code &lt;/p&gt;

&lt;p&gt;I hope that I can help you to understand this topic well. This checklist you can go back to it at any time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv03yei4og14seo22utci.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv03yei4og14seo22utci.jpg" alt="Image description" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it! Start to check your Code Quality! Connect with me on LinkedIn and GitHub for more articles and insights. If you have questions, contact me.&lt;br&gt;
&lt;a href="https://linktr.ee/rowan_ibrahim" rel="noopener noreferrer"&gt;https://linktr.ee/rowan_ibrahim&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Remember, "Later Equals Never." 😉&lt;/p&gt;

</description>
      <category>codequality</category>
      <category>cleancode</category>
      <category>softwaredevelopment</category>
      <category>programming</category>
    </item>
    <item>
      <title>Flutter Overflow Fixes: Simple guide to overflow🚀</title>
      <dc:creator>Rowan Ibrahem</dc:creator>
      <pubDate>Thu, 04 Jul 2024 19:05:43 +0000</pubDate>
      <link>https://forem.com/rowan_ibrahim/flutter-overflow-fixes-simple-guide-to-overflow-2c09</link>
      <guid>https://forem.com/rowan_ibrahim/flutter-overflow-fixes-simple-guide-to-overflow-2c09</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt; ✍🏻&lt;/p&gt;

&lt;p&gt;The distribution of elements on the screen makes the application look consistent. Today, we will focus on the topic of handling overflow errors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Table of contents&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;1- What is overflow?&lt;/p&gt;

&lt;p&gt;2- Types of overflow in flutter.&lt;/p&gt;

&lt;p&gt;3- Text Overflow.&lt;/p&gt;

&lt;p&gt;4- Conclusion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is overflow?&lt;/strong&gt; 🤔&lt;/p&gt;

&lt;p&gt;Knowing that there are different sizes of phones, we should ensure our application is responsive. Consequently, when the content exceeds the space on the page, it leads to overflow. This can lead to content being cut off or extending beyond its container, making the shape inaccurate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;There are several types of overflow in Flutter&lt;/strong&gt; 📝&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Text overflow.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;widget overflow.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Flex overflow.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;List overflow.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Overflow bar.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scaffold overflow.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;In today’s discussion, we will focus on text overflow.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is text Overflow?&lt;/strong&gt;🔎&lt;/p&gt;

&lt;p&gt;Placing any text on the page results in different sizes, as we work with various device dimensions. Especially since the text won’t be alone, we’ll have images and icons. This can cause an overflow if the text size and the screen are small, creating a visual issue. Therefore, we need to ensure that the text size we choose is suitable for all devices and consistent with the overall design of our application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let’s see what Flutter offers to solve this problem.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There is a property in the Text widget called overflow, it controls what happens if the text exceeds the space that allows it and it takes other properties with it to show correctly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Max lines property :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This sets the number of lines the text can span if its size exceeds the width of the screen, and it takes integer values.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Softwrap property:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This determines whether the text can wrap onto multiple lines or stay on a single line, and it takes a Boolean value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;False:&lt;/strong&gt; means that if the text exceeds the screen width, it will not wrap to a new line.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;True:&lt;/strong&gt; means that if the text exceeds the screen width, it can wrap onto multiple lines as appropriate for the screen size.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now let’s see the different values to overflow property and how can we use it!&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Overflow.ellipses:&lt;br&gt;
When an overflow occurs, I make the remaining text appear as dots (….).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;overflow.visible:&lt;br&gt;
Here it will make the text appear entirely even if it exceeds the container’s bounds, which can distort the page layout if there are other elements underneath. We should use it correctly according to our needs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Overflow.fade:&lt;br&gt;
Makes the text fade out gradually if it exceeds a specified space, ensuring it doesn’t abruptly cut off and potentially disrupt the page layout.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Overflow.clip:&lt;br&gt;
Cuts off any extra text that exceeds the specified space, ensuring it doesn’t display beyond the container’s boundaries.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Overflow.values:&lt;br&gt;
Displays a list of all possible values for the TextOverflow property.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fa8cg9vez6qsuuqejkkwt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fa8cg9vez6qsuuqejkkwt.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let’s take an example:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fdtvde59tyzb6xo4v5r1w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fdtvde59tyzb6xo4v5r1w.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, if the text exceeds its bounds, I tell it to display on two lines. However, if it goes beyond these two lines, I instruct it to show “…..” at the end of the text, hiding the rest of it.&lt;/p&gt;

&lt;p&gt;Now, with SoftWrap set to false, it means the text adjusts to the specified number of lines without any spaces. If we set it to true, it still adjusts to the specified number of lines but includes spaces between them.&lt;/p&gt;

&lt;p&gt;In practice, there isn’t much difference between true and false because in both cases, if it exceeds two lines, it will display “…..”. However, this is just in appearance.&lt;/p&gt;

&lt;p&gt;Remember, if you use maxLines alone without overflow, it will give you an error.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fri29t6uu9r2ny3dndz6e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fri29t6uu9r2ny3dndz6e.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So when do we use softWrap property?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We can use softWrap with text and set its value to true without specifying maxLines. In this case, the text will naturally wrap to fit the screen size, adapting to different device sizes. This is useful when displaying product descriptions, writing articles, or any paragraph.&lt;/p&gt;

&lt;p&gt;If we set it to false, we ensure that the text does not wrap onto multiple lines and remains on a single line, which is useful for titles or labels.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For example:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fsj8aalkxczphkdy5zeu8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fsj8aalkxczphkdy5zeu8.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fz86ygx8ozc4g921xt4fr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fz86ygx8ozc4g921xt4fr.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If I want the text to have scrolling, or if part of it should be truncated and moved to the next line, or even if it shouldn’t be displayed at all, then here I use &lt;code&gt;overflow&lt;/code&gt; with &lt;code&gt;maxLines&lt;/code&gt;. It’s preferable that &lt;code&gt;softWrap&lt;/code&gt; be set to &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here’s the output for the examples we discussed before of overflow values.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Ffw7bnobyehd2ars56b8h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Ffw7bnobyehd2ars56b8h.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Certainly, the text will typically be inside other widgets like Rows or Columns, and it will have a font size. Here, overflow can occur if the font size is large and the screen size is small.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F4725ky8cei0c8tnxx5x1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F4725ky8cei0c8tnxx5x1.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, we can use Expanded and use overflow normally with it, and if we also set maxLines, it’s okay according to the desired layout.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Alternatively&lt;/strong&gt;, using FittedBox with Expanded and setting fit: BoxFit.scaleDown, it adjusts the font size based on the screen size, scaling it down if it’s too large.&lt;/p&gt;

&lt;p&gt;Here, if I set maxLines, it won’t do anything and will ignore it because fit continues to scale down the font size to keep it on one line.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F51lt8txyy0gyvnu8yykv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F51lt8txyy0gyvnu8yykv.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F6vbhgbrrild9l43sqll9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F6vbhgbrrild9l43sqll9.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;There’s another package called autosize_text:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It allows you to adjust the font appearance and specify a minimum font size so that it doesn’t shrink below a certain value. This package can be explored further for more details. Still, of course, it’s better to manually adjust the font size yourself to avoid reducing your application’s performance caused by additional packages.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pub.dev/packages/auto_size_text" rel="noopener noreferrer"&gt;https://pub.dev/packages/auto_size_text&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can follow different sequences to fix the overflowing text issue while preparing the UI for your Flutter app. Taking the help of the right team of experts should help you with the process.&lt;/p&gt;

&lt;p&gt;And that’s how we handle Text Overflow. Remember to use each property according to your UI needs and how you’re building it. Insha’Allah, we’ll talk about the remaining types in other articles.&lt;/p&gt;

&lt;p&gt;If there are any additions or other methods, remember to share them with us in the comments!🌟&lt;/p&gt;

&lt;p&gt;Connect with me on LinkedIn and GitHub for more articles and insights. If you have questions, contact me.👀&lt;/p&gt;

&lt;p&gt;&lt;a href="https://linktr.ee/rowan_ibrahim" rel="noopener noreferrer"&gt;https://linktr.ee/rowan_ibrahim&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;See you on the new topic!🌟&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>mobile</category>
    </item>
    <item>
      <title>Crafting Clarity: A Journey into the World of Clean Code Code Needs Care!🤯</title>
      <dc:creator>Rowan Ibrahem</dc:creator>
      <pubDate>Fri, 21 Jun 2024 19:26:18 +0000</pubDate>
      <link>https://forem.com/rowan_ibrahim/crafting-clarity-a-journey-into-the-world-of-clean-codecode-needs-care-32mi</link>
      <guid>https://forem.com/rowan_ibrahim/crafting-clarity-a-journey-into-the-world-of-clean-codecode-needs-care-32mi</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction ✍🏻&lt;/strong&gt;&lt;br&gt;
Do you spend countless hours fixing bugs in your code? Have you wondered why it takes so long?&lt;/p&gt;

&lt;p&gt;Everyone can write code that computers understand. But, not everyone can write code that humans can easily read.&lt;/p&gt;

&lt;p&gt;As software developers, understanding how to write clean code is essential. Let’s dive into the world of Clean Code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3vn90unur4w5145m38uc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3vn90unur4w5145m38uc.jpg" alt="Image description" width="736" height="736"&gt;&lt;/a&gt;``&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Table of Contents&lt;/strong&gt;&lt;br&gt;
What is the clean code?&lt;br&gt;
What causes bad code?&lt;br&gt;
Why is clean code important?&lt;br&gt;
Comparison Between Bad Code and Clean Code.&lt;br&gt;
How Can We Determine if Our Code is Clean?&lt;br&gt;
Principles of Clean Code.&lt;br&gt;
Conclusion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the clean code ?&lt;/strong&gt;🤔&lt;br&gt;
Writing clean code is a fundamental skill for every software engineer. Clean code is to write code that is well-organized, easy to read, understand, and maintain. Writing clean code allows others to read it without wasting time to understand it. Robert Cecil Martin made it popular. He has also gained popularity as Uncle Bob. He wrote “Clean Code: A Handbook of Agile Software Craftsmanship” in 2008.&lt;/p&gt;

&lt;p&gt;In another sense, if three people have different experience levels, they can quickly understand the same code. It’s a clean code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What causes bad code?&lt;/strong&gt;&lt;br&gt;
Consider this scenario: There’s a new project, and your manager gives you a tight deadline. You start coding, promising yourself to enhance it later. But you deliver the product quickly because of pressure from your manager and the customer. But, it’s poorly written. You will never return to improve it.&lt;/p&gt;

&lt;p&gt;Oh, there is Leblanc’s law says:&lt;/p&gt;

&lt;p&gt;“Later equals never.”&lt;/p&gt;

&lt;p&gt;That means if you said you’d improve this later, you wouldn’t return to it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why is clean code important?&lt;/strong&gt;&lt;br&gt;
Let’s revisit a story from the “Clean Code” book to understand the importance of clean code. A company wanted to release a product quickly, resulting in poorly written code. When they tried to add more features, they found it almost impossible to make changes. The changes would break the existing functions and they lost all their money.&lt;/p&gt;

&lt;p&gt;Clean code ensures that companies can add features quickly and without errors.&lt;/p&gt;

&lt;p&gt;When we need to add more features or when someone contributes to complete with you, it will take a long time to read and understand it to fix old bugs and make new features.&lt;/p&gt;

&lt;p&gt;When writing code implementation is simple, the difficulty is reading and debugging. That takes a long time.&lt;/p&gt;

&lt;p&gt;Keeping code clean will give you the most value from your software. The right clean code tool can help you get there. Clean code makes debugging more efficient and unit testing easier.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuaxp4x6bblaquh41b934.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuaxp4x6bblaquh41b934.jpg" alt="Image description" width="500" height="501"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A comparison between clean and badly written code.&lt;/strong&gt;&lt;br&gt;
The compiler will compile every code, clean or not. But not every code will be readable. Let’s take a look:&lt;/p&gt;

&lt;p&gt;Can you see this?&lt;/p&gt;

&lt;p&gt;You don’t need to understand. Let’s see first:&lt;/p&gt;

&lt;p&gt;Bad code&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc48oo1bwhxk52y1hdchz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc48oo1bwhxk52y1hdchz.png" alt="Image description" width="800" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Clean version &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F69bbd867ggfb2q6f0mdt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F69bbd867ggfb2q6f0mdt.png" alt="Image description" width="800" height="638"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Even without understanding the code, do you see the difference? It’s formatting the code that makes the code easy to read and comfortable to the eye.&lt;/p&gt;

&lt;p&gt;Let’s see another example, its login page contains an image and text field.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmr8x5svvx1cd9phjt8jx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmr8x5svvx1cd9phjt8jx.png" alt="Image description" width="800" height="735"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the same page but make every part as a small function. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjaom51mehjqj99l3qm3w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjaom51mehjqj99l3qm3w.png" alt="Image description" width="800" height="831"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, we make functions with clear names. They make the code shorter. If we want to fix any part, we can go right to it.&lt;/p&gt;

&lt;p&gt;You will never know the importance of clean code. Even though you edit your code, you will say: “What a horrible thing I wrote.”🤯&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How Can We Determine if Our Code is Clean?&lt;/strong&gt;&lt;br&gt;
Writing clean code is an art and a way of thinking. It’s like a craft that comes from knowledge and practice. Knowledge comes from knowing principles, patterns, and practice. So, you know this and use it in your code.&lt;/p&gt;

&lt;p&gt;There is a Boy Scout rule that says:&lt;/p&gt;

&lt;p&gt;“Leave the campground cleaner than you found it.”&lt;/p&gt;

&lt;p&gt;That means we need to always check our code and enhance it. Every time we read it we will find that we can make it more cleanly.&lt;/p&gt;

&lt;p&gt;In the book “Art of Clean Code,” they provide some questions we should ask ourselves to help us improve our code.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Can you consolidate files and modules to reduce interdependencies?&lt;/li&gt;
&lt;li&gt;Can you divide large, complicated files into simpler ones?&lt;/li&gt;
&lt;li&gt;Can you generalize code into libraries to simplify the main application?&lt;/li&gt;
&lt;li&gt;Can you use existing libraries to reduce the amount of code?&lt;/li&gt;
&lt;li&gt;Can you use caching to avoid recomputing results?&lt;/li&gt;
&lt;li&gt;Are there more suitable algorithms for your tasks?&lt;/li&gt;
&lt;li&gt;Can you remove premature optimizations that don’t improve performance?&lt;/li&gt;
&lt;li&gt;Would another programming language be more suitable for your problem?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Principles of Clean Code.&lt;/strong&gt;&lt;br&gt;
Like a beautiful painting, clean code needs well-chosen colors and composition. It follows several principles. We will discuss each in later articles.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Meaningful and descriptive names.&lt;/li&gt;
&lt;li&gt;Proper Indentation.&lt;/li&gt;
&lt;li&gt;Short functions that do one thing.&lt;/li&gt;
&lt;li&gt;The DRY (Don’t Repeat Yourself) Principle.&lt;/li&gt;
&lt;li&gt;Avoid code duplication.&lt;/li&gt;
&lt;li&gt;Establish code writing standards.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These principles are just a starting point; there are many more to explore and apply.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion :&lt;/strong&gt;&lt;br&gt;
“Coders spend the vast majority of their time reading old code to write new code. If the old code is easy to read, this will speed up the process considerably.”&lt;/p&gt;

&lt;p&gt;If we write messy code, it will reduce productivity, even if we can make it productive and enjoyable while reading it. Clean code makes it easier to reduce errors and add features without being scared to have errors in another function.&lt;/p&gt;

&lt;p&gt;By following this, you will become a professional developer, and always remember there are no limitations to making your code clean; you can make it better every time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmapzj21qpno7s8a9gqur.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmapzj21qpno7s8a9gqur.jpg" alt="Image description" width="736" height="736"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;That’s it! Start now and begin writing clean code! Connect with me on LinkedIn and GitHub for more articles and insights. If you have questions, contact me.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://linktr.ee/rowan_ibrahim"&gt;https://linktr.ee/rowan_ibrahim&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Remember, “Later Equals Never.” Start writing clean code today! 😉&lt;/p&gt;

</description>
      <category>cleancode</category>
      <category>cleancoding</category>
      <category>writing</category>
      <category>career</category>
    </item>
  </channel>
</rss>
