<?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: Amaury</title>
    <description>The latest articles on DEV Community by Amaury (@iamrr90).</description>
    <link>https://dev.to/iamrr90</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%2F881699%2Fd08ed6ae-0fbf-49e9-b994-f76c4afa54ea.jpg</url>
      <title>DEV Community: Amaury</title>
      <link>https://dev.to/iamrr90</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/iamrr90"/>
    <language>en</language>
    <item>
      <title>RIP XML (Welcome Compose)</title>
      <dc:creator>Amaury</dc:creator>
      <pubDate>Wed, 02 Aug 2023 14:57:51 +0000</pubDate>
      <link>https://dev.to/rootstrap/rip-xml-welcome-compose-1aii</link>
      <guid>https://dev.to/rootstrap/rip-xml-welcome-compose-1aii</guid>
      <description>&lt;p&gt;&lt;strong&gt;RIP XML "They killed an innocent" (welcome Compose)&lt;/strong&gt;&lt;br&gt;
"They killed an innocent," says a song. That's what is happening to XML in Android, Google and the community are slowly killing XML.&lt;/p&gt;

&lt;p&gt;Since the announcement of Android Compose back in 2021 at the Google IO developers conference, developers have been testing and working with this new Declarative pattern for Android, and slowly Compose has been winning space in the Android community.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Big steps for a baby:&lt;/strong&gt;&lt;br&gt;
As with all, new things generate a lot of uncertainty, and usually, when you are adopting a new tech you have to be very careful with it, at the beginning we don't use to count on enough documentation or a community that supports it, so we strongly suggest considering this points before adopting new tech in general:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Learning curve: We should evaluate the learning curve of the new technology and determine if it is feasible to allocate enough time and resources to learn and become proficient in it.&lt;/li&gt;
&lt;li&gt;Technical requirements: Analyze the technical requirements and determine if it is compatible with the existing infrastructure and software, and the company vision.&lt;/li&gt;
&lt;li&gt;Availability of resources: Assess the availability of resources, such as documentation, tutorials, and support forums, to aid in the learning and development process.&lt;/li&gt;
&lt;li&gt;Company goals: Determine if the new technology aligns with the company goals and if it can help achieve them more efficiently or effectively than the current technology.&lt;/li&gt;
&lt;li&gt;Cost: Consider the cost of adopting the new technology, including licensing, training, and impact on productivity during the transition.&lt;/li&gt;
&lt;li&gt;Risks and challenges: Identify risks and challenges associated with the new technology, such as security, adaptability, compatibility issues, or a lack of community support and updates.&lt;/li&gt;
&lt;li&gt;User experience: Consider how the new technology will impact the user experience and whether it will improve or hinder it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The transition&lt;/strong&gt;&lt;br&gt;
But the idea of doing the transition to Compose was always over the table, so we started to learn it, testing, documenting, fighting poor online documentation and tutorials, fighting with bugs and undocumented issues (🥲), new design approaches, and studying new architectures.&lt;/p&gt;

&lt;p&gt;So trust me when I say this transition can take a while, when you have a big team, aligning all the team members in the same direction is a big challenge, so my advice is don't try to jump into a bottomless pool and start a project with a new tech, or the consequence could be catastrophic.&lt;br&gt;
Right now we can say that Compose is mature enough to start taking it seriously and start the transition to it, so here it's the big question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is XML so bad that we need to move to Compose?&lt;/strong&gt;&lt;br&gt;
No really, in general, over other advantages, XML offers a structured, efficient, and maintainable way to define UI elements, promoting a good development workflow and a consistent user experience. But Compose provide several advantages over XML:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Declarative UI: is cleaner, more readable, and more performant than Imperative UI.&lt;/li&gt;
&lt;li&gt;XML depends too much on the application's live cycle.&lt;/li&gt;
&lt;li&gt;Compose allows you to do more with less code compared to XML, redefining all the views and simplifying their use, no more recycler views yea!!!.&lt;/li&gt;
&lt;li&gt;Compose is more intuitive: as declarative UI you just need to tell the UI what to show changing the data state and not setting up the UI like in XML.&lt;/li&gt;
&lt;li&gt;State management: data state is not attached to the app live-cycle, we don't need to take care anymore of that.&lt;/li&gt;
&lt;li&gt;Memory: all the compositions are painted "on demand" so the user just sees what needs to see and doesn't have hidden views or unused views in the background, improving the app performance.&lt;/li&gt;
&lt;li&gt;Design: the design system is more robust and intuitive.&lt;/li&gt;
&lt;li&gt;Learn more about Compose&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why now?&lt;/strong&gt;&lt;br&gt;
Compose is in a stage where we can use it to create complex solutions, saving time and effort for the team. The Android Development community is adopting compose very fast, and XML will be obsolete in the future, the same thing that happens with Java for Android when we move to Kotlin.&lt;/p&gt;

&lt;p&gt;On the other hand with Compose, you can create UI components more intuitively and concisely, using Kotlin code instead of XML. This makes it easier to understand and modify your UI code and reduces the amount of boilerplate code you need to write, improving the readability and the maintenance cost. &lt;/p&gt;

&lt;p&gt;Also rovides a faster way to develop your app's user interface. You can use Compose to quickly prototype your UI design and see the results in real-time, without having to compile and run your app. This can save you a lot of time and effort, especially during the early stages of UI development.&lt;/p&gt;

&lt;p&gt;And finally Compose provides a more flexible and customizable way to create UI components. You can easily create custom UI components and modify existing ones to fit your specific needs. With Compose, you can also easily reuse UI components across different parts of your app, saving you time and effort in the long run. Compose is designed to perform better than XML-based UI development. Uses a more efficient rendering engine that can reduce the amount of CPU and memory usage, resulting in a smoother and more responsive user interface.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
The transition to a new tech could be a challenge depending on the context, as individuals you may take a risk, but as a team, we have to consider a lot of things. &lt;/p&gt;

&lt;p&gt;As a team, this is the moment to start developing products with Compose, very soon we will bring you a base project with an initial setup for an Android project with Compose including Theming, Navigation, Testing, DI, and more. We encourage you to start learning Compose to be more productive and bring to the end user a better experience.&lt;/p&gt;

&lt;p&gt;Keep calm and code clean. 😜&lt;/p&gt;

&lt;p&gt;keywords: #android #compose #xml #google&lt;/p&gt;

</description>
      <category>compose</category>
      <category>android</category>
      <category>google</category>
    </item>
    <item>
      <title>Serverless architecture</title>
      <dc:creator>Amaury</dc:creator>
      <pubDate>Wed, 29 Mar 2023 15:00:11 +0000</pubDate>
      <link>https://dev.to/iamrr90/serverless-architecture-2cfj</link>
      <guid>https://dev.to/iamrr90/serverless-architecture-2cfj</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;What's the meaning of serverless architecture?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If you are thinking of "Apps running without servers", the answer is NO.&lt;/p&gt;

&lt;p&gt;The terms refer to apps(web|mobile|games) that use a third-party service as a back-end with infrastructure already implemented instance of using a dedicated server. For example, Amazon with AWS Serverless Application Repository | AWS Lambdas, Google with Firebase, Microsoft with Azure Serverless, Node JS with RealmDB that uses GraphQL, and others.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Traditional architecture:&lt;/strong&gt;
&lt;/h3&gt;

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

&lt;h3&gt;
  
  
  Serverlees architecture:
&lt;/h3&gt;

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

&lt;h3&gt;
  
  
  &lt;strong&gt;Understanding the server-less architecture&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Now, let’s see what the images above mean with two real application scenarios.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Imagine that we have a blog app and we want to create a new blog post.

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Using traditional architecture:&lt;/strong&gt; We sent that information to the server, and the server verifies that we have permission to create a new post and saves the data into the database, the Front-End doesn’t care where or how the server is protecting the data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Using server-less architecture:&lt;/strong&gt; All we have to do is save the data into the database directly and the same database checks with the security rules if the data can be saved, and the server-less service takes care of the security in both cases, so we don't have to take care of it.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;In the same blog app, we now need to show the feed of posts.

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Using traditional architecture:&lt;/strong&gt; We ask for the feed, the server verifies first that we have the authorization to call that endpoint, then we ask the database for the data and respond to the data in a certain format.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Using server-less architecture:&lt;/strong&gt; All we have to do is create a function to get the data or make a call to the database, and the server-less service takes care of the security in both cases, so we don't have to take care of it. Note that in both cases when you are using a server-less solution the tests in the back end are not needed, however with traditional architecture, we need to write a lot of tests besides coding the entire solution.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The service takes care of the infrastructure.&lt;/li&gt;
&lt;li&gt;They take care of maintenance.&lt;/li&gt;
&lt;li&gt;Have strong security rules that you can modify if needed.&lt;/li&gt;
&lt;li&gt;You only have to focus on the application logic.&lt;/li&gt;
&lt;li&gt;SDKs for all platforms.&lt;/li&gt;
&lt;li&gt;Enhanced Latency(better user experience) &amp;amp; Geo-location.&lt;/li&gt;
&lt;li&gt;The cost depends on the use*.&lt;/li&gt;
&lt;li&gt;The learning curve is quite fast.&lt;/li&gt;
&lt;li&gt;Human resource cost.&lt;/li&gt;
&lt;li&gt;Horizontal scalability&lt;/li&gt;
&lt;li&gt;Services provide integration with other platform services.&lt;/li&gt;
&lt;li&gt;Use his authentication service and integrations with other authentication tools like Google, Facebook, Apple, etc...&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Disadvantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Limitations with business logic.&lt;/li&gt;
&lt;li&gt;Scalability is limited to service capabilities.&lt;/li&gt;
&lt;li&gt;It's hard to debug functions or tasks.&lt;/li&gt;
&lt;li&gt;Sometimes the security rules are very complex.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The cost depends on the usage:&lt;/strong&gt; Usually, the cost is cheaper than traditional cloud solutions, but you have to consider in your business analysis that the more you use the service the higher the price will be. If you have 2k users it will probably be free but if you have 200k users the cost will go up, depending on how many actions/functions you are using, so just keep that in mind. Before selecting the service to use, take a look at the operational cost of users/actions. Usually, all services have pricing calculation tools. With traditional architectures, you are billed monthly by the cloud provider, it doesn't matter if your application has traffic or not. In the case of a serverless solution you "pay as you go" so you don't have to worry about extra billing.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Use Cases:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;News, Blogs, Reservations, etc.., in general applications that only show information and with little or no backend logic needed, most of the business logic is in the front.&lt;/li&gt;
&lt;li&gt;Chats, bots, customer services.&lt;/li&gt;
&lt;li&gt;Applications that share real-time data like the stock market, the weather, IoT applications, geo-location, games, and others.&lt;/li&gt;
&lt;li&gt;Social networks.&lt;/li&gt;
&lt;li&gt;Microservices.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In conclusion, serverless is a great option for applications that do not need complex business logic or need real-time data. Also, development time can be optimized, since you don't need to write any code for the back end or deploy any solution and a single developer can take care of both the front end and the back end, which is a saving in human resources.&lt;/p&gt;

&lt;p&gt;Keep calm and code clean. 😜&lt;/p&gt;

</description>
      <category>api</category>
      <category>mobile</category>
      <category>serverless</category>
    </item>
    <item>
      <title>Android XML reported death</title>
      <dc:creator>Amaury</dc:creator>
      <pubDate>Mon, 27 Mar 2023 16:56:17 +0000</pubDate>
      <link>https://dev.to/iamrr90/android-xml-reported-death-15hn</link>
      <guid>https://dev.to/iamrr90/android-xml-reported-death-15hn</guid>
      <description>&lt;p&gt;"They killed an innocent," says a song. That's what is happening right now to XML UI's in android, Google and the community are slowly killing XML.&lt;/p&gt;

&lt;p&gt;Since the announcement of Android Compose back in 2021 at the Google IO developers conference, developers have been testing and working with this new Declarative pattern for android, and slowly Compose has been winning space in the Android community.&lt;/p&gt;

&lt;p&gt;Big steps for a baby:&lt;br&gt;
As with all, new things generate a lot of uncertainty, and usually, when you are adopting a new tech you have to be very careful with it, at the beginning we don't use to count on enough documentation or a community that supports it, so we strongly suggest considering this points before adopting new tech in general:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Learning curve: We should evaluate the learning curve of the new technology and determine if it is feasible to allocate enough time and resources to learn and become proficient in it.&lt;/li&gt;
&lt;li&gt;Technical requirements: Analyze the technical requirements and determine if it is compatible with the existing infrastructure and software, and the company vision.&lt;/li&gt;
&lt;li&gt;Availability of resources: Assess the availability of resources, such as documentation, tutorials, and support forums, to aid in the learning and development process.&lt;/li&gt;
&lt;li&gt;Company goals: Determine if the new technology aligns with the company goals and if it can help achieve them more efficiently or effectively than the current technology.&lt;/li&gt;
&lt;li&gt;Cost: Consider the cost of adopting the new technology, including licensing, training, and impact on productivity during the transition.&lt;/li&gt;
&lt;li&gt;Risks and challenges: Identify risks and challenges associated with the new technology, such as security, adaptability, compatibility issues, or a lack of community support and updates.&lt;/li&gt;
&lt;li&gt;User experience: Consider how the new technology will impact the user experience and whether it will improve or hinder it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But the idea of doing the transition to Compose was always over the table, so we started to learn it slowly, testing, documenting, poor online documentation and tutorials, fighting with bugs and undocumented issues(🥲), new design approaches, and studying new architectures. &lt;br&gt;
So trust me when I say this transition can take a while, when you have a big team, aligning all the team members in the same direction is a big challenge, so my advice is don't try to jump into a bottomless pool and start a project with a new tech, or the consequence could be catastrophic.&lt;/p&gt;

&lt;p&gt;Right now we can say that Compose is mature enough to start taking it seriously and start the transition to it, so here it's the big question: &lt;br&gt;
&lt;strong&gt;Is XML so bad that we need to move to Compose?&lt;/strong&gt;&lt;br&gt;
No really. But Compose provide several advantages over XML: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Declarative UI: is cleaner, more readable, and more performant than Imperative UI.&lt;/li&gt;
&lt;li&gt;XML depends too much on the application's live cycle.&lt;/li&gt;
&lt;li&gt;Compose allows you to do more with less code compared to XML, redefining all the views and simplifying their use, no more recycler views yea!!!.&lt;/li&gt;
&lt;li&gt;Compose is more intuitive: as declarative UI you just need to tell the UI what to show changing the data state and not setting up the UI like in XML.&lt;/li&gt;
&lt;li&gt;State management: data state is not attached to the app live-cycle, we don't need to take care anymore of that.&lt;/li&gt;
&lt;li&gt;Memory: all the compositions are painted "on demand" so the user just sees what needs to see and doesn't have hidden views or unused views in the background, improving the app performance.&lt;/li&gt;
&lt;li&gt;Design: the design system is more robust and intuitive.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Learn more about Compose&lt;/p&gt;

&lt;p&gt;Why now?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Maturity: We consider that Compose is in a stage where we can use it to create complex solutions, saving time and effort for the team.&lt;/li&gt;
&lt;li&gt;Community: The Android Development community is adopting compose very fast, and XML will be obsolete in the future, the same thing that happens with Java for Android when we change to Kotlin.&lt;/li&gt;
&lt;li&gt;Knowledge: For the past year the team has been working to improve their skills with Compose, to deliver high-quality products faster and with the highest industry quality standard.&lt;/li&gt;
&lt;li&gt;Declarative UI: On the other hand with Compose, you can create UI components more intuitively and concisely, using Kotlin code instead of XML. This makes it easier to understand and modify your UI code and reduces the amount of boilerplate code you need to write, improving the readability and the maintenance cost.&lt;/li&gt;
&lt;li&gt;Faster UI development: Compose provides a faster way to develop your app's user interface. You can use Compose to quickly prototype your UI design and see the results in real-time, without having to compile and run your app. This can save you a lot of time and effort, especially during the early stages of UI development.&lt;/li&gt;
&lt;li&gt;More flexibility and customization: Compose provides a more flexible and customizable way to create UI components. You can easily create custom UI components and modify existing ones to fit your specific needs. With Compose, you can also easily reuse UI components across different parts of your app, saving you time and effort in the long run.&lt;/li&gt;
&lt;li&gt;Improved performance: Compose is designed to provide better performance compared to XML-based UI development. Compose uses a more efficient rendering engine that can reduce the amount of CPU and memory usage, resulting in a smoother and more responsive user interface.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;The transition to a new tech could be a challenge depending on the context, as individuals you may take a risk, but as a team, we have to consider a lot of things. As a team, we feel like this is the moment to start developing products with Compose, very soon we will bring you a base project with an initial setup for an android project with compose including Theming, Navigation, Testing, DI, and more. We encourage you to start learning Compose to be more productive and bring to the end user a better experience.&lt;/p&gt;

&lt;p&gt;Keep calm and code clean. 😜&lt;/p&gt;

</description>
      <category>android</category>
      <category>compose</category>
      <category>mobile</category>
    </item>
    <item>
      <title>Imperative and Declarative UI Pattern - Is Declarative Programming the future?</title>
      <dc:creator>Amaury</dc:creator>
      <pubDate>Thu, 16 Mar 2023 13:42:00 +0000</pubDate>
      <link>https://dev.to/rootstrap/imperative-and-declarative-ui-pattern-is-declarative-programming-the-future-2f6b</link>
      <guid>https://dev.to/rootstrap/imperative-and-declarative-ui-pattern-is-declarative-programming-the-future-2f6b</guid>
      <description>&lt;p&gt;Check out the &lt;a href="https://www.rootstrap.com/blog/imperative-v-declarative-ui-design-is-declarative-programming-the-future"&gt;Original post&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Behind every mobile application, a UI framework determines how developers create the application and how well it performs. Today, UI frameworks fit into two categories: declarative and imperative. The majority of apps use the imperative approach. &lt;/p&gt;

&lt;p&gt;However, as the newer, declarative frameworks develop and reveal their many advantages, several major tech companies have switched to developing their apps with declarative UI designs.&lt;/p&gt;

&lt;p&gt;As declarative programming becomes more popular, we want to evaluate its advantages and disadvantages and consider how it improves upon imperative designs. &lt;/p&gt;

&lt;p&gt;In this article, we will define and compare imperative and declarative UI design and explore the benefits and drawbacks of designing apps with declarative programming.&lt;/p&gt;

&lt;p&gt;Understanding Imperative and Declarative UI Designs&lt;br&gt;
Imperative and declarative UI frameworks refer to frameworks that use imperative and declarative programming styles, respectively. Below, we define these terms as they relate to UI design and describe the differences between the two paradigms or models.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Imperative Programming&lt;/strong&gt;&lt;br&gt;
Currently the most common paradigm, imperative programming requires the developer to write step-by-step how the program will reflect the desired state or perform an operation. For UI creation, developers write detailed code that tells the device how to display the components.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Declarative Programming&lt;/strong&gt;&lt;br&gt;
Declarative programming allows developers to design the user interface based solely on what they want to be displayed without regard to how the device will update its state.&lt;/p&gt;

&lt;p&gt;Oftentimes, declarative frameworks rely on an underlying imperative implementation that translates the declarative command into a set of imperative instructions for the device to complete. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's look at an example&lt;/strong&gt;&lt;br&gt;
Website designer sitting at a computer &lt;br&gt;
Web design&lt;br&gt;
Consider a simple mobile app with a button that toggles its color. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Imperative design&lt;/strong&gt;&lt;br&gt;
A developer must create a button component and add an event handler function to it. The event handler function would run when clicked and contain an if-else statement that changes the color based on the button's color when pressed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Declarative design&lt;/strong&gt;&lt;br&gt;
The developer creates a button component with the property toggle color. The declarative design appears much simpler and more intuitive.&lt;/p&gt;

&lt;p&gt;However, the declarative example only works because of an imperative implementation in the framework that interprets the toggle color property and assigns the proper event handler that determines the current button color and how it needs to change. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why use Declarative Programming?&lt;/strong&gt;&lt;br&gt;
Less code, faster development&lt;br&gt;
Imperative programming requires a lot of code to manage the UI. Developers must determine the contents, define themes, position components, and manage event handlers. With many responsibilities, developers have less time to polish the design and debug other UI issues. &lt;/p&gt;

&lt;p&gt;Moreover, imperative UI design typically requires multiple programming languages, one for the UI design and another for the functionality of each UI element.&lt;/p&gt;

&lt;p&gt;With declarative programming, on the other hand, we only need to design UIs within the Swift (for IOS) or Kotlin (for Android) code, eliminating the need to maintain and handle separate UI files. In short, declarative UI programming means less code and faster development.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Theming&lt;/strong&gt;&lt;br&gt;
Declarative UIs come with a pre-configured theme. Developers can customize this theme to meet their preferences by altering properties like typography, color, buttons, etc. A pre-configured yet fully customizable theme saves developers time as they don't need to build a theme from scratch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dynamism&lt;/strong&gt;&lt;br&gt;
Declarative UI frameworks provide control structures developers can use to manipulate the drawing of the user interface. Compared to imperative frameworks typically used for Android and IOS development, declaratively developed user interfaces can use these control structures to be more dynamic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;State management&lt;/strong&gt;&lt;br&gt;
With an imperative design, developers face the difficulty of syncing the UI with the app state by manually updating all the components to reflect the changes in the app. Traditionally, developers created a user interface with a tree of widgets/layouts.&lt;/p&gt;

&lt;p&gt;Whenever the app's data or state required a UI component to update, the program had to traverse through the tree of widgets, select the right one, and change it. As the tree of elements grows, the design becomes more complex and error-prone.&lt;/p&gt;

&lt;p&gt;The declarative UI paradigm eliminates this process of manual synchronization. The declarative framework automatically updates the UI to match the app's state, simplifying state management by a significant degree.&lt;/p&gt;

&lt;p&gt;Other Advantages of Declarative UI Design&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Live previews for rapid UI development.&lt;/li&gt;
&lt;li&gt;SwiftUI &amp;amp; Compose foster collaboration between designers and web developers &lt;/li&gt;
&lt;li&gt;It's an opportunity to learn a valuable skill.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Disadvantages of Declarative UI Design&lt;/strong&gt;&lt;br&gt;
Since declarative programming has only emerged in the past few years, there are still unresolved issues and disadvantages. Current problems with declarative UI design include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Declarative UIs only support more recent operating systems &lt;/li&gt;
&lt;li&gt;You may encounter problems no one has faced before&lt;/li&gt;
&lt;li&gt;Some features are only available in native, imperative UI frameworks&lt;/li&gt;
&lt;li&gt;Best declarative programming practices and conventions have not yet been established&lt;/li&gt;
&lt;li&gt;Insufficient documentation&lt;/li&gt;
&lt;li&gt;Small developer community&lt;/li&gt;
&lt;li&gt;Little integration with third-party libraries&lt;/li&gt;
&lt;li&gt;The learning curve can be very steep initially&lt;/li&gt;
&lt;li&gt;Many issues with the declarative paradigm, however, are likely temporary. As more companies and developers see the advantages of declarative design and invest more resources into growing the development community, they will resolve many of the aforementioned issues.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why you should start thinking declaratively?&lt;/strong&gt;&lt;br&gt;
Declarative app development requires a new perspective. Many assumptions that developers might have, in regards to app development, no longer apply if using a declarative design.&lt;/p&gt;

&lt;p&gt;For example, with declarative programming, developers can rebuild the UI to reflect the app's current state instead of modifying it directly. The formula below illustrates this new perspective.&lt;/p&gt;

&lt;p&gt;When the state of your app changes (for example, the user flips a switch in the settings screen), the state changes, which triggers a redraw of the user interface. There is no imperative changing of the UI itself (like a textView.text = "Hi").&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Several major names in the tech industry, such as Meta, Google, and Apple, have already adopted the declarative paradigm because they see its value as a simple yet effective method of app development.&lt;/p&gt;

&lt;p&gt;These companies believe it is the future of front-end development. Here at Rootstrap, we believe we should be ready for it too, and we encourage developers to explore how declarative design could improve UI development.&lt;/p&gt;

</description>
      <category>mobile</category>
      <category>android</category>
      <category>ios</category>
      <category>flutter</category>
    </item>
    <item>
      <title>Flutter Navigation: Navigator vs Go Router</title>
      <dc:creator>Amaury</dc:creator>
      <pubDate>Thu, 16 Mar 2023 13:35:48 +0000</pubDate>
      <link>https://dev.to/rootstrap/flutter-navigation-navigator-vs-go-router-1bi1</link>
      <guid>https://dev.to/rootstrap/flutter-navigation-navigator-vs-go-router-1bi1</guid>
      <description>&lt;p&gt;In this post we are going to learn a little bit more about Flutter Navigation and go_router.&lt;/p&gt;

&lt;p&gt;Check the &lt;a href="https://www.rootstrap.com/blog/flutter-navigation-with-router-go" rel="noopener noreferrer"&gt;original POST&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How does flutter navigation work?&lt;/p&gt;

&lt;p&gt;Flutter navigation provides a way for you to navigate from one widget to another in your app. This is achieved by using a navigation stack, which is essentially a collection of routes.&lt;/p&gt;

&lt;p&gt;Navigator is a built-in Flutter widget that provides a simple and convenient way to manage the navigation stack and navigate between routes. It's straightforward to use and can be a good choice for basic navigation needs. On it a route represents a widget and its associated data. When you navigate to a new route, it is pushed onto the navigation stack, and when you navigate back, the current route is popped off the stack.&lt;/p&gt;

&lt;p&gt;Navigator provides a number of navigation widgets, including Navigator, MaterialPageRoute, and CupertinoPageRoute, that make it easy to manage the navigation stack and provide common navigation patterns.&lt;/p&gt;

&lt;p&gt;With Navigator, you can push and pop routes, as well as manage the navigation stack. MaterialPageRoute and CupertinoPageRoute are two common types of routes in Flutter that are used to transition between pages. They provide animation and visual effects appropriate for the material design or Cupertino design languages, respectively.&lt;/p&gt;

&lt;p&gt;Overall, Flutter navigation is designed to be flexible, allowing you to create complex navigation patterns that meet the needs of your app.&lt;/p&gt;

&lt;p&gt;But there are some limitations and potential problems that you should be aware of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Limited routing features: Navigator provides basic routing functionality, but it doesn't offer advanced features like named routes, path parameters, query parameters, or wildcard matching, which can make it challenging to build more complex navigation patterns.&lt;/li&gt;
&lt;li&gt;Code complexity: As your app grows in complexity, managing the navigation stack with Navigator can become more challenging, making your code more difficult to maintain and debug.&lt;/li&gt;
&lt;li&gt;Lack of customizability: Navigator provides basic animation and visual effects for transitioning between routes, but it doesn't allow you to customize the routing transitions and animations.&lt;/li&gt;
&lt;li&gt;Global state management: Navigator doesn't provide a built-in solution for managing the global states, which can make it challenging to share data between routes.&lt;/li&gt;
&lt;li&gt;Inconsistent navigation patterns: Because Navigator is a low-level widget, it can be challenging to ensure that navigation patterns are consistent across your app. This can lead to a fragmented user experience.&lt;/li&gt;
&lt;li&gt;These limitations can make it challenging to build complex, scalable, and consistent navigation patterns with Navigator. If you encounter these limitations, you may want to consider using a third-party routing library, such as go_router, to address them.&lt;/li&gt;
&lt;li&gt;On the other hand, go_router is a third-party routing library maintained by the Flutter team, that provides advanced routing functionality that is not available in Navigator. For example, go_router provides features such as named routes, path parameters, query parameters, and wildcard matching, which can be useful for building more complex navigation patterns.&lt;/li&gt;
&lt;li&gt;Additionally, go_router provides a more elegant and declarative approach to routing, making it easier to manage the routing logic in your app. This can help to make your code more organized and maintainable, especially as your app grows in complexity.&lt;/li&gt;
&lt;li&gt;So, if you need advanced routing features and a more elegant routing solution, you may consider using go_router. But if your navigation needs are simple, Navigator may be a more appropriate choice.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are several advantages of using go_router in Flutter:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Named routes: go_router supports named routes, which makes it easier to manage and organize the navigation logic in your app. Named routes allow you to define the routes in a central location and then reference them throughout your app, making it easier to make changes to your navigation logic in the future.&lt;/li&gt;
&lt;li&gt;Path parameters: go_router supports path parameters, which allow you to pass data to your routes based on the URL. This is useful for building dynamic navigation patterns, such as when you need to pass an ID or other data to a route.&lt;/li&gt;
&lt;li&gt;Query parameters: go_router also supports query parameters, which allow you to pass data to your routes through the URL query string. This is useful for cases where you need to pass data that is not part of the route path.&lt;/li&gt;
&lt;li&gt;Wildcard matching: go_router supports wildcard matching, which makes it easy to define catch-all routes that can handle any URL that doesn't match another route.&lt;/li&gt;
&lt;li&gt;Declarative routing: go_router provides a more elegant and declarative approach to routing, making it easier to manage the routing logic in your app. This can help to make your code more organized and maintainable, especially as your app grows in complexity.&lt;/li&gt;
&lt;li&gt;Custom routing transitions: go_router allows you to customize the routing transitions and animations, making it possible to create custom and unique navigation experiences in your app.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Overall, go_router provides a number of advanced routing features that can make it easier to manage and organize the navigation logic in your Flutter app. If your navigation needs are complex, go_router may be a good choice for your project.&lt;/p&gt;

&lt;p&gt;Let's see an example of how we can structure our app:&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%2Fohu4008w2elml8pdtob2.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%2Fohu4008w2elml8pdtob2.png" alt="go_router example graph"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 Dart
static GoRouter onBoardingRouter(AuthState authState) =&amp;gt; GoRouter(
        initialLocation: "/logIn",
        navigatorKey: onBoardingNavigatorKey,
        routes: [
          GoRoute(
            name: "login",
            path: "/logIn",
            builder: (context, state) =&amp;gt; const LoginPage(),
            //Example of redirection        
            redirect: (context, state) =&amp;gt; authState == AuthState.loading ? "/splash" : null,
          ),
          GoRoute(
            name: "splash",
            path: "/splash",
            builder: (context, state) =&amp;gt; const SplashPage(),
          ),
          GoRoute(
            name: "signUp",
            path: "/signUp",
            builder: (context, state) =&amp;gt; const SignUpPage(),
          ),
          GoRoute(
            name: "passwordReset",
            path: "/passwordReset",
            builder: (context, state) =&amp;gt; const ResetPasswordPage(),
          ),
        ],
      );


static GoRouter mainRouter = GoRouter(
    initialLocation: "/main",
    routes: [
      ShellRoute(
        navigatorKey: mainNavigatorKey,
        builder: (context, state, child) {
          return Cookies(
            child: HomeCorePage(
              child: child,
            ),
          );
        },
        routes: [
          GoRoute(
            name: "main",
            path: "/main",
            builder: (context, state) =&amp;gt; const HomePage(),
            routes: [
              GoRoute(
                name: "postDetails",
                path: "postDetails",
                builder: (context, state) =&amp;gt;
                    PostDetailsPage(postId: state.params['id'] ?? ""),
              ),
              GoRoute(
                name: "chat",
                path: "chat",
                builder: (context, state) =&amp;gt; ChatPage(),
              ),
              //...........
            ],
          ),
        ],
      ),
      ShellRoute(
        navigatorKey: mainNavigatorKey,
        builder: (context, state, child) {
          return Cookies(
            child: SettingsCorePage(
              child: child,
            ),
          );
        },
        routes: [
          GoRoute(
            name: "settings",
            path: "/settings",
            builder: (context, state) =&amp;gt; const HomePage(),
            routes: [
              GoRoute(
                name: "profileEdit",
                path: "profile",
                builder: (context, state) =&amp;gt; const EditProfilePage(),
                routes: [
                  GoRoute(
                    name: "resetPassword",
                    path: "resetPassword",
                    builder: (context, state) =&amp;gt; const ResetPasswordPage(),
                  ),
                ],
              ),
              GoRoute(
                name: "themeSetup",
                path: "theme",
                builder: (context, state) =&amp;gt; const ResetPasswordPage(),
              ),
              //...........
            ],
          ),
        ],
      ),
    ],
  );


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Go_router manages different types of routes:&lt;br&gt;
ShellRoute: is a container, basically, all the child routes will be rendered inside of its widget.&lt;br&gt;
i.e: Here HomeCorePage can have a container that renders a child widget with a classic nav drawer or a bottom nav bar to nav between screens, as usual when you change between screen we de HomeCorePage render again the new child and keeps the state of the rest of the screen.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 Dart
static GoRoutermainRouter= GoRouter(
  initialLocation: "/main",
  routes: [
    // Home Navigation with drawer or bottom nav bar
    ShellRoute(
      navigatorKey: mainNavigatorKey,
      builder: (context, state, child) {
        return Cookies(
          child: HomeCorePage(
            child: child,
          ),
        );
      },
      routes: [
        GoRoute(
          name: "main",
          path: "/main",
          builder: (context, state) =&amp;gt; const HomePage(),
        ),
        GoRoute(
          name: "settings",
          path: "/settings",
          builder: (context, state) =&amp;gt; const SettingsPage(),
        ),
      ],
    ),
  ],
);


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;GoRoute: the main route type, this is where you declare your route with the widget to render, and can have different children, let's see:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 Dart
GoRoute(
          name: "main",
          path: "/main",
          builder: (context, state) =&amp;gt; const HomePage(),
          redirect: (context, state) {
                if (!isUserAuthTo("main"))
                         return "/unauth";
                if (!state.params.containsKey("id"))
                      return "/main"
                    // return null to continue to the sub route
                return null;
          },
          routes: [
            GoRoute(
                name: "details",
                    path: "/details/:id",
                    builder: (context, state) =&amp;gt; const Details(id: state.params["id"] ?? ""),
                ),
),
@amaury901130



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here we can see different things:&lt;br&gt;
Every route can have N sub-routes.&lt;br&gt;
We can add validations before nav to a sub-route and redirect the user to any other page that we need in case don't match the validation.&lt;br&gt;
Another advantage of go_router is that we can manage nav errors easily in the GoRouter class:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 Dart
GoRouter(
   // when trying to nav to a missing route.
      errorBuilder: (context, state) {
          return ErrorPage(ErrorCode.e404);
      },
      initialLocation: "/main",
      routes: ....
)


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Deeplinks:&lt;br&gt;
When a deep link is received from the platform, GoRouter will display the configured screen based on the URL path. To configure your Android or iOS app for deep linking, see the Deep linking documentation at flutter.dev:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Enable deep linking on Android&lt;/strong&gt;&lt;br&gt;
Add a metadata tag and intent filter to AndroidManifest.xml inside the  tag with the ".MainActivity" name:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 xml
&amp;lt;!-- Deep linking --&amp;gt;
&amp;lt;meta-data android:name="flutter_deeplinking_enabled" android:value="true" /&amp;gt;
&amp;lt;intent-filter android:autoVerify="true"&amp;gt;
    &amp;lt;action android:name="android.intent.action.VIEW" /&amp;gt;
    &amp;lt;category android:name="android.intent.category.DEFAULT"/&amp;gt;
    &amp;lt;category android:name="android.intent.category.BROWSABLE"/&amp;gt;
    &amp;lt;data android:scheme="http" android:host="flutterbooksample.com" /&amp;gt;
    &amp;lt;data android:scheme="https" /&amp;gt;
&amp;lt;/intent-filter&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;A full restart is required to apply these changes.&lt;br&gt;
Test on Android emulator&lt;br&gt;
To test with an Android emulator, give the adb command an intent where the host name matches the name defined in AndroidManifest.xml:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 xml
adb shell 'am start -a android.intent.action.VIEW \\ -c android.intent.category.BROWSABLE \\ -d "&amp;lt;http://flutterbooksample.com/book/1&amp;gt;"' \\ &amp;lt;package name&amp;gt;

Replace the &amp;lt;package name&amp;gt; with the package name of your Android app. If you named the package com.example.myflutterapp, run the following command:

adb shell 'am start -a android.intent.action.VIEW \\ -c android.intent.category.BROWSABLE \\ -d "&amp;lt;http://flutterbooksample.com/book/1&amp;gt;"' \\ com.example.myflutterapp


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;For more details, see the Verify Android App Links documentation in the Android docs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Enable deep linking on iOS&lt;/strong&gt;&lt;br&gt;
Add two new keys to Info.plist in the ios/Runner directory:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 xml
&amp;lt;key&amp;gt;FlutterDeepLinkingEnabled&amp;lt;/key&amp;gt; 
&amp;lt;true/&amp;gt; 
&amp;lt;key&amp;gt;CFBundleURLTypes&amp;lt;/key&amp;gt; 
&amp;lt;array&amp;gt; 
    &amp;lt;dict&amp;gt; 
    &amp;lt;key&amp;gt;CFBundleTypeRole&amp;lt;/key&amp;gt; 
    &amp;lt;string&amp;gt;Editor&amp;lt;/string&amp;gt; 
    &amp;lt;key&amp;gt;CFBundleURLName&amp;lt;/key&amp;gt; 
    &amp;lt;string&amp;gt;flutterbooksample.com&amp;lt;/string&amp;gt; 
    &amp;lt;key&amp;gt;CFBundleURLSchemes&amp;lt;/key&amp;gt; 
    &amp;lt;array&amp;gt; 
    &amp;lt;string&amp;gt;customscheme&amp;lt;/string&amp;gt; 
    &amp;lt;/array&amp;gt; 
    &amp;lt;/dict&amp;gt;
&amp;lt;/array&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The CFBundleURLName is a unique URL used to distinguish your app from others that use the same scheme. The scheme (customscheme://) can also be unique.&lt;br&gt;
A full restart is required to apply these changes.&lt;br&gt;
Test on iOS simulator&lt;br&gt;
Use the xcrun command to test on the iOS Simulator:&lt;br&gt;
xcrun simctl openurl booted &lt;br&gt;
customscheme://flutterbooksample.com/book/1&lt;/p&gt;

&lt;p&gt;In conclusion&lt;br&gt;
Go_router is an alternative to Navigator that offers some advantages over the latter, especially in large and complex applications. We strongly recommend that if you're working on a complex application and need advanced navigation management, you should consider using go_router. &lt;br&gt;
Below are some reasons why we should consider using go_router instead of Navigator:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Greater flexibility in defining routes: Go_router allows for a more flexible definition of navigation routes than Navigator. With go_router, we can define routes based on any criteria, such as the access route, URL parameters, application state, etc.&lt;/li&gt;
&lt;li&gt;Better navigation management: Go_router offers more advanced navigation management than Navigator. For example, go_router allows us to define multiple navigation stacks for different areas of the application, making it easier to navigate between them without losing context.&lt;/li&gt;
&lt;li&gt;Integration with the BLoC pattern: Go_router integrates well with the Business Logic Component (BLoC) pattern, which is a popular architecture pattern in Flutter. Go_router allows us to define routes that are directly linked to BLoC events, making it easier to manage navigation and application state.&lt;/li&gt;
&lt;li&gt;Better performance: Go_router offers performance improvements over Navigator in large and complex applications. Go_router uses a tree-based data structure to store navigation routes, allowing for faster and more efficient route lookup.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>flutter</category>
      <category>gorouter</category>
      <category>android</category>
      <category>ios</category>
    </item>
  </channel>
</rss>
