<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: hossam rakha</title>
    <description>The latest articles on DEV Community by hossam rakha (@hossamrakha0).</description>
    <link>https://dev.to/hossamrakha0</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%2F416505%2Fdd369383-cff1-43ab-b64d-fe9ad2b9c19f.jpg</url>
      <title>DEV Community: hossam rakha</title>
      <link>https://dev.to/hossamrakha0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hossamrakha0"/>
    <language>en</language>
    <item>
      <title>The difference between clean code and clean architecture?</title>
      <dc:creator>hossam rakha</dc:creator>
      <pubDate>Sun, 17 Dec 2023 16:53:06 +0000</pubDate>
      <link>https://dev.to/hossamrakha0/the-difference-between-clean-code-and-clean-architecture-3881</link>
      <guid>https://dev.to/hossamrakha0/the-difference-between-clean-code-and-clean-architecture-3881</guid>
      <description>&lt;p&gt;I've been exploring clean code and clean architecture lately and wanted to share what I've discovered about their differences.&lt;/p&gt;

&lt;p&gt;Firstly, it's important to understand that clean code and clean architecture are distinct concepts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CuJPoqvc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f8vz1m6obwqtvottgfws.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CuJPoqvc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f8vz1m6obwqtvottgfws.jpeg" alt="what?" width="640" height="357"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Initially, when I aimed to write code that was easy to understand, I followed advice from articles on organizing folders, and classes, and dividing projects into sections. However, as my projects grew, I encountered a problem: my code started getting messy, and I couldn't figure out why.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mKwdiFkM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/spjzfgpkmditg7d9asel.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mKwdiFkM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/spjzfgpkmditg7d9asel.png" alt="clean code" width="800" height="798"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's define clean Architecture:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Clean Architecture, introduced by Robert C. Martin (Uncle Bob), focuses on building software systems that are maintainable, scalable, and testable. It highlights the separation of concerns, independence from frameworks, and using abstractions for a clear and understandable architecture in applications.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;On the other hand,&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Clean code refers to well-structured, easily understandable, and maintainable code that adheres to best practices and coding standards. Also emphasized by Robert C. Martin, it revolves around writing code that's clear and straightforward to work with.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These concepts complement each other. Achieving readable software isn't solely about choosing the right software architecture. For instance, in Android development, there are various architectures like MVC, MVP, and MVVM, and in Flutter, options like BLoC or Provider State Management. These serve as guidelines to simplify software development by segregating concerns. Your choice depends on your team and software requirements.&lt;/p&gt;

&lt;p&gt;But why does code still become messy despite using these architectures? The answer is simple: neglecting the basics of writing clean code. Choosing an architecture pattern is just one aspect. Lengthy functions, unclear variable names, poorly named classes, and disorganized code structures are the real issues.&lt;/p&gt;

&lt;p&gt;To address this:&lt;/p&gt;

&lt;p&gt;Before delving into software architecture debates, focus on writing readable code.&lt;br&gt;
Consider the practical tips for writing cleaner code from resources like:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/clarityai-engineering/clean-code-a-practical-approach-896546435235"&gt;Clean Code — A practical approach&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://dev.to/favourmark05/writing-clean-code-best-practices-and-principles-3amh"&gt;Dev.to Article&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/leonardolemie/clean-code-java"&gt;Java GitHub repository&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/williambarreiro/clean-code-dart"&gt;Dart GitHub repository&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once you grasp the basics of clean code, then proceed to choose a suitable software architecture for your project. You can explore further by reading the "Clean Code" book by Uncle Bob and apply your knowledge to build cleaner, more maintainable software.&lt;/p&gt;

</description>
      <category>cleancoding</category>
      <category>cleancode</category>
      <category>android</category>
      <category>flutter</category>
    </item>
    <item>
      <title>Flutter: How to write clean-code in flutter</title>
      <dc:creator>hossam rakha</dc:creator>
      <pubDate>Wed, 29 Mar 2023 17:13:12 +0000</pubDate>
      <link>https://dev.to/hossamrakha0/flutter-how-to-write-clean-code-in-flutter-1jg0</link>
      <guid>https://dev.to/hossamrakha0/flutter-how-to-write-clean-code-in-flutter-1jg0</guid>
      <description>&lt;p&gt;&lt;strong&gt;Learn how to code in Dart in a way that every other developer can understand&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Recently i have seen many flutter projects with MVC architecture using Model-View-Controller(RxDart).&lt;/p&gt;

&lt;p&gt;In my opinion it’s so simple architecture anyone can proceed with it easily. Especially if you are using flutter for the first time. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The downside of using RxDart for handling the state management is the need to write some business logic in our view ( Widget ) or in our model this happens a lot in our projects specifically the big projects. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So i believe if you have been using this architecture for one or two projects so it's the time now to upgrade the architecture and your code since you already have an experience with flutter framework.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solutions:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NsbpwNKd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0iwlsbeheuxgcdpxgexh.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NsbpwNKd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0iwlsbeheuxgcdpxgexh.jpeg" alt="clean code" width="625" height="468"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Learning more about clean-code (i believe using a good architecture for the project is essential and it helps a lot in the long-term, but it won’t guarantee that the code will be always clean. We can pick up the best architecture which doesn’t exist 😛 and still it can be violated by writing functions with many lines and using a lot of for-loops or using many duplicate codes with bad variables names or writing many business logic code in the View.  So we can review some tips we knows already about writing clean code in general which doesn’t relate to specific programming-language or framework then we pick up the suitable architecture for the project 🙂&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;1- &lt;a href="https://github.com/JuanCrg90/Clean-Code-Notes"&gt;https://github.com/JuanCrg90/Clean-Code-Notes&lt;/a&gt;&lt;br&gt;
2- &lt;a href="https://www.pluralsight.com/blog/software-development/10-steps-to-clean-code"&gt;https://www.pluralsight.com/blog/software-development/10-steps-to-clean-code&lt;/a&gt;&lt;br&gt;
3- &lt;a href="https://dev.to/thawkin3/in-defense-of-clean-code-100-pieces-of-timeless-advice-from-uncle-bob-5flk"&gt;https://dev.to/thawkin3/in-defense-of-clean-code-100-pieces-of-timeless-advice-from-uncle-bob-5flk&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Picking up the architecture (there are many architecture patterns out there to use in flutter like Bloc, Provider, Riverpod, Redux, etc…)
So literally choosing a specific pattern is depends on the team and the project. In my opinion if the project is considered to be a small project then i would suggest using model-view-RxDart. It’s simple and easy to use since the project is simple.&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;If the project considered to be a big project so i would suggest using a good state management pattern like Bloc &lt;br&gt;
 &lt;a href="https://pub.dev/packages/flutter_bloc"&gt;https://pub.dev/packages/flutter_bloc&lt;/a&gt;. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MZ58DLx4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q5m46qvi07491v6nkzai.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MZ58DLx4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q5m46qvi07491v6nkzai.png" alt="Image description" width="880" height="1017"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;With the help of using the Bloc pattern we can use a dependency injection library &lt;a href="https://pub.dev/packages/get_it"&gt;https://pub.dev/packages/get_it&lt;/a&gt;  and the benefits of using DI is Maintaining our code will be simpler since our classes will be loosely coupled, meaning they are less dependent on one another. Code reuse reduces the amount of boilerplate code.&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Note: get_it for repositories that are needed outside the build context and bloc for all UI state and logic.&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Links for studying the bloc pattern and get_it:&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;1- Bloc:&lt;br&gt;
&lt;a href="https://medium.com/flutter-community/flutter-bloc-for-beginners-839e22adb9f5"&gt;https://medium.com/flutter-community/flutter-bloc-for-beginners-839e22adb9f5&lt;/a&gt;&lt;br&gt;
&lt;a href="https://bloclibrary.dev/#/gettingstarted"&gt;https://bloclibrary.dev/#/gettingstarted&lt;/a&gt; &lt;br&gt;
&lt;a href="https://github.com/felangel/bloc/tree/master/examples"&gt;https://github.com/felangel/bloc/tree/master/examples&lt;/a&gt; &lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=oxeYeMHVLII&amp;amp;list=PLB6lc7nQ1n4jCBkrirvVGr5b8rC95VAQ5"&gt;https://www.youtube.com/watch?v=oxeYeMHVLII&amp;amp;list=PLB6lc7nQ1n4jCBkrirvVGr5b8rC95VAQ5&lt;/a&gt; ( Note: this tutorial is a bit old, but it’s still a good tutorial to know about the bloc concepts )&lt;/p&gt;

&lt;p&gt;2- Get-it&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=DbV5RV2HRUk"&gt;https://www.youtube.com/watch?v=DbV5RV2HRUk&lt;/a&gt;&lt;br&gt;
&lt;a href="https://medium.com/flutter-community/flutter-fast-dependency-injection-5748d956bb5c"&gt;https://medium.com/flutter-community/flutter-fast-dependency-injection-5748d956bb5c&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/fluttercommunity/get_it/tree/master/example"&gt;https://github.com/fluttercommunity/get_it/tree/master/example&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3- using Bloc with Get_it &lt;br&gt;
&lt;a href="https://cshanjib.medium.com/authentication-using-flutter-bloc-and-dependency-injection-257accdb6e3e"&gt;https://cshanjib.medium.com/authentication-using-flutter-bloc-and-dependency-injection-257accdb6e3e&lt;/a&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>mobile</category>
    </item>
  </channel>
</rss>
