<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Muayad alrazehi on Medium]]></title>
        <description><![CDATA[Stories by Muayad alrazehi on Medium]]></description>
        <link>https://medium.com/@moaidmoaidrazhy?source=rss-3c5918214738------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*IsIFHmSAEZAoyYvQcvvYyg.png</url>
            <title>Stories by Muayad alrazehi on Medium</title>
            <link>https://medium.com/@moaidmoaidrazhy?source=rss-3c5918214738------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 05:37:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@moaidmoaidrazhy/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Serverless: Code Fast, Scale Easy, Pay As You Go!]]></title>
            <link>https://medium.com/@moaidmoaidrazhy/serverless-code-fast-scale-easy-pay-as-you-go-4ef06d3a5a73?source=rss-3c5918214738------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ef06d3a5a73</guid>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[saas]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[iaas]]></category>
            <dc:creator><![CDATA[Muayad alrazehi]]></dc:creator>
            <pubDate>Thu, 22 Feb 2024 04:08:53 GMT</pubDate>
            <atom:updated>2024-02-22T04:08:53.285Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*kXhOZ-B3IL3qfdfMjDot4w.png" /></figure><p>Imagine you’re craving pizza. Do you:</p><ul><li><strong>Buy the whole pie, even if you only want a slice?</strong> (That’s traditional server management: fixed costs, even if underutilized.)</li><li><strong>Rent a single slice, and get more if you’re hungry?</strong> (That’s serverless: pay only for what you use!)</li></ul><p>Serverless computing is the “rent-a-slice” approach to cloud development. No more managing servers, scaling manually, or wasting resources. Just write your code, let the cloud provider handle the rest, and pay only when your code runs.</p><p><strong>Ready to ditch the server pizza party and enjoy the freedom of serverless?</strong> Read on!</p><h3><strong>traditional client-server architectures with dedicated servers</strong> often present <strong>roadblocks</strong>:</h3><ul><li><strong>Inflexible server management:</strong> Provisioning, scaling, and patching servers consume valuable developer time and resources.</li><li><strong>Manual scaling processes:</strong> Predicting future demand and scaling infrastructure accordingly can be challenging, leading to either overprovisioning (wasted resources) or underprovisioning (performance bottlenecks).</li><li><strong>Constant maintenance burden:</strong> Patching vulnerabilities, updating software, and ensuring server health adds to operational overhead.</li><li><strong>Resource inefficiency:</strong> Running dedicated servers often results in under-utilized resources, increasing costs.</li></ul><h3><strong>Enter Serverless: A Paradigm Shift:</strong></h3><p>Serverless computing throws a lifeline to developers, offering an on-demand cloud model where the focus shifts from managing servers to writing powerful code. Here’s the magic:</p><ul><li><strong>Cloud provider takes the wheel:</strong> Gone are the days of manual server management. The cloud provider handles provisioning, scaling, and maintenance, freeing you to focus on what matters most — your application logic.</li><li><strong>Event-driven execution:</strong> Serverless functions are triggered by specific events, such as HTTP requests, database changes, or messages in queues. This allows for highly responsive and scalable applications.</li><li><strong>Focus on the core:</strong> With serverless, you can ditch the infrastructure concerns and concentrate on developing clean, efficient code that delivers business value.</li></ul><h3><strong>Key Concepts simplified:</strong></h3><p>To understand serverless better, let’s delve into its core concepts:</p><ul><li><strong>Event-driven architecture:</strong> Imagine dominoes where one falling event triggers the next. Similarly, functions react to incoming events, creating a chain of execution when needed.</li><li><strong>Function as a Service (FaaS):</strong> Platforms like AWS Lambda and Google Cloud Functions offer FaaS, allowing you to upload your code snippets (functions) and have them executed in response to events. Think of it as renting computing power on demand.</li><li><strong>Backend as a Service (BaaS):</strong> Some serverless offerings include pre-built services like authentication and databases (BaaS). These seamlessly integrate with FaaS platforms, offering a comprehensive development experience.</li></ul><h3><strong>Traditional vs. Serverless: A Clear Comparison:</strong></h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bdd3f4e3124bbba0ddb25526948176e1/href">https://medium.com/media/bdd3f4e3124bbba0ddb25526948176e1/href</a></iframe><h3>Demystifying Serverless: Unleashing Agility and Efficiency in Cloud Development</h3><p><strong>Facing the Need for Speed:</strong></p><p>In today’s fast-paced digital landscape, cloud applications demand ever-increasing agility and scalability. Yet, traditional client-server architectures with dedicated servers often present roadblocks:</p><ul><li><strong>Inflexible server management:</strong> Provisioning, scaling, and patching servers consume valuable developer time and resources.</li><li><strong>Manual scaling processes:</strong> Predicting future demand and scaling infrastructure accordingly can be challenging, leading to either overprovisioning (wasted resources) or underprovisioning (performance bottlenecks).</li><li><strong>Constant maintenance burden:</strong> Patching vulnerabilities, updating software, and ensuring server health adds to operational overhead.</li><li><strong>Resource inefficiency:</strong> Running dedicated servers often results in under-utilized resources, increasing costs.</li></ul><p><strong>Enter Serverless: A Paradigm Shift:</strong></p><p>Serverless computing throws a lifeline to developers, offering an on-demand cloud model where the focus shifts from managing servers to writing powerful code. Here’s the magic:</p><ul><li><strong>Cloud provider takes the wheel:</strong> Gone are the days of manual server management. The cloud provider handles provisioning, scaling, and maintenance, freeing you to focus on what matters most — your application logic.</li><li><strong>Event-driven execution:</strong> Serverless functions are triggered by specific events, such as HTTP requests, database changes, or messages in queues. This allows for highly responsive and scalable applications.</li><li><strong>Focus on the core:</strong> With serverless, you can ditch the infrastructure concerns and concentrate on developing clean, efficient code that delivers business value.</li></ul><p><strong>Key Concepts Demystified:</strong></p><p>To understand serverless better, let’s delve into its core concepts:</p><ul><li><strong>Event-driven architecture:</strong> Imagine dominoes where one falling event triggers the next. Similarly, functions react to incoming events, creating a chain of execution when needed.</li><li><strong>Function as a Service (FaaS):</strong> Platforms like AWS Lambda and Google Cloud Functions offer FaaS, allowing you to upload your code snippets (functions) and have them executed in response to events. Think of it as renting computing power on demand.</li><li><strong>Backend as a Service (BaaS):</strong> Some serverless offerings include pre-built services like authentication and databases (BaaS). These seamlessly integrate with FaaS platforms, offering a comprehensive development experience.</li></ul><p><strong>Traditional vs. Serverless: A Clear Comparison:</strong></p><p>FeatureTraditional Client-ServerServerlessServer ManagementManualManaged by cloud providerScalabilityManual, often complexAutomatic, event-drivenCostsFixed, resource-intensivePay-per-use, cost-efficientDeveloper FocusInfrastructure concernsCode development and logic</p><p>drive_spreadsheetExport to Sheets</p><h3>Why Choose Serverless?</h3><ul><li><strong>Agility and speed:</strong> Develop and deploy faster with minimal infrastructure concerns.</li><li><strong>Seamless scalability:</strong> Automatically scale functions up or down based on demand, ensuring optimal performance.</li><li><strong>Cost optimization:</strong> Pay only for the resources you use, eliminating idle server costs.</li><li><strong>Reduced maintenance:</strong> Free yourself from time-consuming server management tasks.</li><li><strong>Improved developer experience:</strong> Focus on writing great code without infrastructure worries.</li></ul><h3><strong>Putting it into Practice: AWS and Google Cloud Examples:</strong></h3><p>Let’s see how serverless translates into actual code. Here are simple function examples in Python (you can use Node.js or other supported languages):</p><p><strong>AWS Lambda (resizing an image upon upload):</strong></p><pre>def resize_image(event, context):<br>    # Access uploaded image data from event<br>    image_data = event[&quot;Records&quot;][0][&quot;s3&quot;][&quot;object&quot;][&quot;key&quot;]<br>    # Resize image<br>    resized_image = resize_image_function(image_data)<br>    # Store resized image<br>    store_resized_image(resized_image)<br>    return &quot;Image resized successfully!&quot;</pre><p><strong>Google Cloud Function (processing order data):</strong></p><pre>def process_order(data, context):<br>    # Extract order data from Pub/Sub message<br>    order_id = data[&quot;orderId&quot;]<br>    # Process order logic<br>    process_order_payment(order_id)<br>    update_order_status(order_id)<br>    return &quot;Order processed!&quot;</pre><p>These are just glimpses into the possibilities. Serverless can power diverse use cases, from event-driven microservices to data processing tasks.</p><p><strong>Important Considerations:</strong></p><p>While serverless promises numerous benefits, it’s crucial to be aware of certain aspects:</p><ul><li><strong>Be careful who you rent from:</strong> Switching cloud providers might be tricky later.</li><li><strong>Cold starts:</strong> Initial function executions might experience slight performance delays. Use optimization techniques to minimize cold start impact.</li><li><strong>Keep an eye on things:</strong> Make sure you know what your code is doing so you’re not surprised by the bill.</li></ul><p><strong>Serverless is a powerful tool for modern cloud apps. Give it a try and see how fast and easy your code can run!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ef06d3a5a73" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mocking in Software Testing]]></title>
            <link>https://medium.com/@moaidmoaidrazhy/mocking-in-software-testing-a4eb8a8b1257?source=rss-3c5918214738------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4eb8a8b1257</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[mocking]]></category>
            <category><![CDATA[unit-testing]]></category>
            <dc:creator><![CDATA[Muayad alrazehi]]></dc:creator>
            <pubDate>Mon, 19 Feb 2024 04:30:40 GMT</pubDate>
            <atom:updated>2024-02-19T04:30:40.637Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tQ4S3mmF92QJHF-WrJPRsw.jpeg" /></figure><p>Ever wondered how astronauts prepare for spacewalks? They practice in simulated environments to ensure they&#39;re ready for the challenges of outer space. In the tech world, a similar concept called mocking allows developers to create pretend versions of components. Let&#39;s explore this idea and see how it works in practical terms using Flutter, Spring Boot, and Laravel.</p><h4>What is Mocking?</h4><p>Mocking in software testing is creating objects that simulate the behavior of real objects. It allows developers to simulate different scenarios without affecting the real system. Imagine it as a virtual playground where developers can experiment with their code.</p><h4><strong>When to Use Mocking?</strong></h4><p>Mocking becomes essential when developers need to focus on specific parts of their software or when real components are tricky to use. For example, when making HTTP calls or interacting with databases, mocking provides a controlled way to test these interactions without relying on the actual external services. It’s a bit like having a practice field where you can refine specific skills without worrying about the entire game.</p><h4>Examples using Flutter, Spring Boot, and Laravel:</h4><h4>Flutter</h4><pre>import &#39;package:flutter_test/flutter_test.dart&#39;;<br>import &#39;package:mockito/mockito.dart&#39;;<br>import &#39;package:your_flutter_app/services/data_service.dart&#39;;<br>import &#39;package:your_flutter_app/widgets/data_widget.dart&#39;;<br><br>class MockDataService extends Mock implements DataService {}<br><br>void main() {<br>  testWidgets(&#39;DataWidget should display data from the service&#39;, (WidgetTester tester) async {<br>    // Create a mock service<br>    final MockDataService mockService = MockDataService();<br><br>    // Stub the service response<br>    when(mockService.fetchData()).thenAnswer((_) async =&gt; &#39;Mocked Data&#39;);<br><br>    // Build our widget with the mocked service<br>    await tester.pumpWidget(DataWidget(dataService: mockService));<br><br>    // Verify that the widget displays the mocked data<br>    expect(find.text(&#39;Mocked Data&#39;), findsOneWidget);<br>  });<br>}</pre><h4>Spring Boot</h4><p>using mockito</p><pre>package com.in28minutes.mockito.mockitodemo;<br><br>public class SomeBusinessImpl {<br>	private DataService dataService;<br><br>	public SomeBusinessImpl(DataService dataService) {<br>		super();<br>		this.dataService = dataService; <br>              }<br><br>.... <br>}</pre><pre>package com.in28minutes.mockito.mockitodemo;<br><br>import static org.junit.Assert.assertEquals;<br>import static org.mockito.Mockito.mock;<br>import static org.mockito.Mockito.when;<br><br>import org.junit.Test;<br><br>public class SomeBusinessMockTest {<br><br>	@Test<br>	public void testFindTheGreatestFromAllData() {<br>		DataService dataServiceMock = mock(DataService.class);<br>		when(dataServiceMock.retrieveAllData()).thenReturn(new int[] { 24, 15, 3 });<br>		SomeBusinessImpl businessImpl = new SomeBusinessImpl(dataServiceMock);<br>		int result = businessImpl.findTheGreatestFromAllData();<br>		assertEquals(24, result);<br>	}<br><br>}</pre><h4>Laravel:</h4><pre>namespace App\Services;<br><br>class BusinessLogicService<br>{<br>    private $dataService;<br><br>    public function __construct(DataService $dataService)<br>    {<br>        $this-&gt;dataService = $dataService;<br>    }<br><br>    public function findTheGreatestFromAllData()<br>    {<br>      ....<br>    }<br>}</pre><pre>// tests/Unit/BusinessLogicServiceTest.php<br><br>namespace Tests\Unit;<br><br>use App\Services\BusinessLogicService;<br>use App\Services\DataService;<br>use Tests\TestCase;<br><br>class BusinessLogicServiceTest extends TestCase<br>{<br>    public function testFindTheGreatestFromAllData()<br>    {<br>        // Mocking the DataService<br>        $dataServiceMock = $this-&gt;createMock(DataService::class);<br>        $dataServiceMock-&gt;method(&#39;retrieveAllData&#39;)-&gt;willReturn([24, 15, 3]);<br><br>        // Creating an instance of the BusinessLogicService with the mocked DataService<br>        $businessService = new BusinessLogicService($dataServiceMock);<br><br>        // Performing the test<br>        $result = $businessService-&gt;findTheGreatestFromAllData();<br><br>        // Assertions<br>        $this-&gt;assertEquals(24, $result);<br>    }<br><br>}</pre><h4>Conclusion</h4><p>In conclusion, mocking simplifies software testing by providing a safe space for developers to experiment, especially when dealing with external services like HTTP calls and databases. It’s like a virtual lab where they can fine-tune their code before it faces the real world. As you delve into software development, consider incorporating mocking into your testing toolkit. It’s a practical and efficient way to ensure your code is ready for prime time.</p><p>Happy Testing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4eb8a8b1257" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integration Testing: Bridging the Gap Between Units]]></title>
            <link>https://medium.com/@moaidmoaidrazhy/integration-testing-bridging-the-gap-between-units-f1ef7017ea28?source=rss-3c5918214738------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1ef7017ea28</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[integration-testing]]></category>
            <dc:creator><![CDATA[Muayad alrazehi]]></dc:creator>
            <pubDate>Sun, 18 Feb 2024 04:57:20 GMT</pubDate>
            <atom:updated>2024-02-18T05:01:16.609Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AKCG35i89GX7uPPBTidWeg.jpeg" /></figure><p>have you seen a band of musicians without a composer or a conductor, it&#39;s a total miss! even though they are all professionals, it is the same in our code where each method, class, or module may be tested with unit tests and works just perfectly, but when it comes to connecting parts together that’s when the noise starts, here is where our integration test comes to insure harmony among units.</p><h4><strong>What is Integration Testing?</strong></h4><p>In software development, <strong>integration testing</strong> is a crucial testing approach that verifies how individual units (modules, components, or microservices) of a system interact and collaborate as a collective whole. It builds upon unit testing, which examines the functionality of individual units in isolation, by focusing on the interfaces and data flow between them.</p><h4><strong>Key Objectives of Integration Testing:</strong></h4><ul><li><strong>Identify Interface Issues:</strong> Uncover flaws in data exchange, communication protocols, and API usage between interconnected units.</li><li><strong>Expose Inter-Unit Dependencies:</strong> Reveal hidden or unexpected dependencies between units that could lead to brittle integrations.</li><li><strong>Verify Business Logic:</strong> Ensure that the combined behavior of integrated units fulfills the overall system’s business requirements.</li><li><strong>Prevent System-Level Defects:</strong> Catch issues early in the development cycle that might manifest as complex system-wide problems later.</li></ul><h4><strong>Benefits of Integration Testing:</strong></h4><ul><li><strong>Enhanced System Quality:</strong> Reduces the likelihood of integration-related defects, leading to a more robust and reliable system.</li><li><strong>Early Defect Detection:</strong> Discovers issues early when they’re easier and cheaper to fix.</li><li><strong>Faster Feature Delivery:</strong> Streamlines development by enabling you to test features in integration before final system testing.</li></ul><h4><strong>Integration Testing Approaches:</strong></h4><p>Several approaches exist, each with its own strengths and weaknesses:</p><ul><li><strong>Top-Down Testing:</strong> Starts with high-level modules and integrates lower-level modules progressively.</li><li><strong>Bottom-Up Testing:</strong> Begins with low-level modules and gradually integrates them into higher-level modules.</li><li><strong>Big Bang Testing:</strong> Integrates all modules at once (risky, often used for small systems).</li><li><strong>Sandwich Testing:</strong> Combines top-down and bottom-up approaches.</li></ul><h4>Examples of I<strong>ntegration Testing in Flutter, Laravel, and Spring Boot:</strong></h4><h4>Flutter</h4><ul><li>Use Flutter Driver for UI integration tests (widgets, screens, interactions).</li><li>Mock external dependencies like networks or services with package:mockito.</li><li>Consider state management testing tools like package:flutter_test/widget_tester.dart.</li></ul><pre>// Testing login integration with UI (using Flutter Driver)<br>testWidgets(&#39;Login functionality test&#39;, (WidgetTester tester) async {<br>  await tester.pumpWidget(MyApp());<br>  final emailField = find.byType(TextField).first;<br>  final passwordField = find.byType(TextField).last;<br>  final loginButton = find.text(&#39;Login&#39;);<br><br>  await tester.enterText(emailField, &#39;user@example.com&#39;);<br>  await tester.enterText(passwordField, &#39;password&#39;);<br>  await tester.tap(loginButton);<br>  await tester.pumpAndSettle();<br><br>  // Assert on UI changes or API calls triggered after login<br>  expect(find.text(&#39;Welcome back, user!&#39;), findsOneWidget);<br>});<br><br>// Mocked integration test with network (using package:mockito)<br>test(&#39;Fetch user data successfully&#39;, () async {<br>  final mockUserService = MockUserService();<br>  final userId = 123;<br><br>  when(mockUserService.getUser(userId)).thenAnswer((_) =&gt; Future.value(<br>    User(id: userId, name: &#39;John Doe&#39;),<br>  ));<br><br>  final app = MyApp(userService: mockUserService);<br>  final user = await app.fetchUser(userId);<br><br>  expect(user.id, userId);<br>  expect(user.name, &#39;John Doe&#39;);<br>});</pre><h4><strong>Laravel:</strong></h4><ul><li>Leverage PHPUnit or Laravel’s built-in testing package for integration tests.</li><li>Mock or stub external dependencies (services, databases) with PHPUnit’s mocking facilities.</li><li>Use Laravel’s API routes testing mechanisms for API integrations.</li></ul><pre>// Integration test for user registration (using PHPUnit)<br>public function testRegisterUser()<br>{<br>  $userData = [<br>    &#39;name&#39; =&gt; &#39;John Doe&#39;,<br>    &#39;email&#39; =&gt; &#39;user@example.com&#39;,<br>    &#39;password&#39; =&gt; &#39;password&#39;,<br>  ];<br><br>  $this-&gt;post(&#39;/register&#39;, $userData)<br>    -&gt;assertStatus(201)<br>    -&gt;assertJsonFragment([&#39;message&#39; =&gt; &#39;User registered successfully&#39;]);<br><br>  // Optional: assert user is saved in database<br>  $this-&gt;assertDatabaseHas(&#39;users&#39;, [&#39;email&#39; =&gt; &#39;user@example.com&#39;]);<br>}<br><br>// API route integration test (using Laravel test methods)<br>public function testApiLogin()<br>{<br>  $userData = [<br>    &#39;email&#39; =&gt; &#39;user@example.com&#39;,<br>    &#39;password&#39; =&gt; &#39;password&#39;,<br>  ];<br><br>  $this-&gt;json(&#39;POST&#39;, &#39;/api/login&#39;, $userData)<br>    -&gt;assertStatus(200)<br>    -&gt;assertJsonStructure([<br>      &#39;token&#39;,<br>      &#39;user&#39; =&gt; [&#39;id&#39;, &#39;name&#39;, &#39;email&#39;],<br>    ]);<br>}</pre><h4>SpringBoot</h4><ul><li>Employ JUnit with Spring’s @SpringBootTest annotation for integration tests.</li><li>Autowire beans and inject mocks or stubs for external dependencies.</li><li>Test various layers (REST controllers, services, data access) in isolation and combined.</li></ul><pre>@SpringBootTest<br>public class UserServiceIntegrationTest {<br><br>  @Autowired<br>  private UserService userService;<br><br>  @MockBean<br>  private UserRepository userRepository;<br><br>  @Test<br>  public void testFindUserById() {<br>    long userId = 123;<br>    User user = new User(userId, &quot;John Doe&quot;);<br><br>    // Mock user repository behavior<br>    when(userRepository.findById(userId)).thenReturn(Optional.of(user));<br><br>    User foundUser = userService.findById(userId);<br><br>    assertNotNull(foundUser);<br>    assertEquals(userId, foundUser.getId());<br>    assertEquals(&quot;John Doe&quot;, foundUser.getName());<br>  }<br><br>  // Integration test for REST controller (using MockMvc)<br>  @Test<br>  public void testUpdateUser() throws Exception {<br>    long userId = 123;<br>    String newName = &quot;Jane Doe&quot;;<br><br>    UpdateUserDto updateDto = new UpdateUserDto(newName);<br><br>    MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new UserController(userService)).build();<br><br>    mockMvc.perform(put(&quot;/api/users/{id}&quot;, userId)<br>      .contentType(MediaType.APPLICATION_JSON)<br>      .content(asJsonString(updateDto)))<br>      .andExpect(status().isOk());<br><br>    // Additional assertions on user update behavior<br>  }<br>}</pre><p>Remember, just as an orchestra’s harmonious symphony elevates a solo performance, integration testing takes your software beyond the sum of its parts. Start integrating today and witness the emergence of a truly cohesive and reliable system…. Happy Testing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1ef7017ea28" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unit Testing: Your Code’s First Line of Defense]]></title>
            <link>https://medium.com/@moaidmoaidrazhy/unit-testing-your-codes-first-line-of-defense-89acabca79fb?source=rss-3c5918214738------2</link>
            <guid isPermaLink="false">https://medium.com/p/89acabca79fb</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[unit-testing]]></category>
            <dc:creator><![CDATA[Muayad alrazehi]]></dc:creator>
            <pubDate>Sat, 17 Feb 2024 05:21:35 GMT</pubDate>
            <atom:updated>2024-02-17T05:31:46.678Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BI1PWIJqjEvw9w0fQh66Yw.jpeg" /></figure><p>Unit testing is a fundamental practice in software development, where individual units of code, typically functions or methods, are isolated and tested for correctness. It’s like having a personal trainer for each muscle group in your code, ensuring each performs its designated task flawlessly. Let’s delve into the details</p><h4><strong>What are Unit Tests?</strong></h4><ul><li>Imagine a function responsible for calculating the area of a circle. A unit test would feed different radius values and verify that the output matches the expected area using mathematical formulas.</li><li>Unit tests are written by developers using specialized frameworks, making them automated and repeatable. This allows for quick feedback on code changes, preventing regressions and catching bugs early.</li></ul><h4><strong>Benefits of Unit Testing:</strong></h4><ul><li><strong>Prevents Regressions:</strong> As projects grow, modifications in one area can unintentionally break seemingly unrelated parts. <strong>Unit tests act as sentries, alerting you to such regressions before they impact users.</strong></li><li><strong>Improved Code Quality:</strong> Catches errors early, saving time and money compared to fixing bugs later in the development lifecycle.</li><li><strong>Increased Confidence:</strong> Developers gain confidence in their code, leading to improved maintainability and refactoring abilities.</li><li><strong>Faster Development:</strong> Automating tests speeds up the feedback loop, making development more efficient and iterative.</li><li><strong>Better Documentation:</strong> Tests act as living documentation, clarifying code functionality and intent.</li></ul><h4><strong>Beyond the Basics:</strong></h4><ul><li><strong>Test Coverage:</strong> The percentage of code covered by tests. While high coverage is desired, it’s crucial to focus on critical functionality.</li><li><strong>Mocking:</strong> Creating fake objects to isolate unit behavior, preventing reliance on external dependencies.</li><li><strong>Test-Driven Development (TDD):</strong> Writing tests first to guide code implementation, promoting good design and clarity.</li></ul><h4>Unit Testing Examples in Some Popular Frameworks:</h4><p>Now, let’s see how unit testing translates to specific frameworks:</p><p><strong>Laravel:</strong></p><pre>&lt;?php<br>// Test for a function calculating product discount<br>public function testProductDiscount()<br>{<br>    $product = new Product(100, 0.1); // Mock product with price and discount<br>    $discount = $product-&gt;calculateDiscount(); // Call the function<br>    $this-&gt;assertEquals(10, $discount); // Assert expected discount<br>}<br>// Using PHPUnit and Laravel&#39;s testing tools</pre><p><strong>Spring Boot:</strong></p><pre>@RunWith(SpringRunner.class)<br>@SpringBootTest<br>public class UserServiceTest {<br>    @Autowired<br>    private UserService userService;<br>    @Test<br>    public void testFindUserById() {<br>        User expectedUser = new User(1, &quot;John Doe&quot;); // Mock user object<br>        Optional&lt;User&gt; actualUser = userService.findById(1);<br>        assertThat(actualUser.isPresent()).isTrue();<br>        assertThat(actualUser.get()).isEqualToComparingFieldByField(expectedUser);<br>    }<br>// Using JUnit and Spring Boot&#39;s testing annotations</pre><p><strong>Flutter:</strong></p><pre>void main() {<br>  test(&#39;Calculate total price&#39;, () {<br>    // Mock cart items with prices<br>    final items = [<br>      CartItem(name: &#39;Item 1&#39;, price: 10.0),<br>      CartItem(name: &#39;Item 2&#39;, price: 5.0),<br>    ];<br>    final totalPrice = calculateTotalPrice(items); // Call the function<br>    expect(totalPrice, equals(15.0));<br>  });<br>// Using test and expect from flutter_test package<br>}d</pre><p>Remember, these are just basic examples. Unit testing can be more complex, covering different scenarios and edge cases. Additionally, each framework offers its own tools and best practices for testing. Make sure to consult the official documentation and explore advanced testing techniques for your specific framework.</p><p>Happy testing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89acabca79fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Kafka?]]></title>
            <link>https://medium.com/@moaidmoaidrazhy/what-is-kafka-32498af39bc4?source=rss-3c5918214738------2</link>
            <guid isPermaLink="false">https://medium.com/p/32498af39bc4</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[kafka]]></category>
            <dc:creator><![CDATA[Muayad alrazehi]]></dc:creator>
            <pubDate>Fri, 16 Feb 2024 03:43:16 GMT</pubDate>
            <atom:updated>2024-02-16T03:43:16.740Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*F0Q_gWQECE5SZ3dQJdzmIQ.png" /></figure><p>in a <a href="https://medium.com/@moaidmoaidrazhy/rethinking-microservices-communication-moving-beyond-http-restful-apis-c238353417a0">previous article</a> we talked about microservices communication methods and message brokers were one of them, today we are exploring Kafka in simple terms, what is it? usages and examples scenarios.</p><p>In today’s data-driven world, managing high-velocity information streams is critical for businesses of all sizes. That’s where Apache Kafka, a <strong>distributed event streaming platform</strong>, shines.</p><h3><strong>What is Kafka?</strong></h3><p>Apache Kafka is an open-source distributed streaming platform designed to handle high-volume, real-time data feeds. It is often used for messaging, log aggregation, stream processing, and commit logs. Kafka is a highly scalable and fault-tolerant platform, making it a popular choice for mission-critical applications.</p><p>Think of Kafka as a superhighway for your data. It lets you publish and subscribe to real-time streams of information, enabling various applications to communicate and react instantly. At its core, Kafka operates with:</p><ul><li><strong>Topics:</strong> Categorized channels for data streams.</li><li><strong>Partitions:</strong> Subdivisions within topics for parallel processing.</li><li><strong>Producers:</strong> Applications pushing data to topics.</li><li><strong>Consumers:</strong> Applications subscribing to topics to receive data.</li><li><strong>Brokers:</strong> Servers storing and managing data partitions.</li></ul><h3><strong>Why choose Kafka?</strong></h3><p>Kafka boasts several advantages that make it a popular choice for various use cases:</p><ul><li><strong>Scalability:</strong> Designed to handle massive data volumes with ease.</li><li><strong>Fault Tolerance:</strong> Built for resilience, so data loss is minimal even with node failures.</li><li><strong>Performance:</strong> High-throughput data processing with low latency.</li><li><strong>Real-time Capabilities:</strong> Handles data streams as they occur, ideal for real-time analytics and application updates.</li><li><strong>Flexibility:</strong> Integrates seamlessly with various technologies and systems.</li></ul><h3><strong>Where does Kafka shine?</strong></h3><p>Kafka finds application in diverse scenarios, including:</p><ul><li><strong>Microservices Communication:</strong> Enables efficient communication between microservices for building robust and responsive applications.</li><li><strong>Event-Driven Architectures:</strong> Reacts to events in real-time, streamlining processes and improving agility.</li><li><strong>Real-time Analytics:</strong> Feeds data pipelines for continuous analysis and insights.</li><li><strong>Log Aggregation and Processing:</strong> Collects and processes logs from various sources for centralized monitoring and analysis.</li><li><strong>Data Integration and Streaming:</strong> Integrates data from different sources and enables real-time data analysis.</li><li><strong>IoT Data Ingestion and Processing:</strong> Handles high-volume, high-velocity IoT data streams for continuous monitoring and insights.</li></ul><h3>Example using Spring boot</h3><p>Here’s a small Spring Boot example demonstrating the value of Kafka with a simple producer and consumer:</p><p><strong>Scenario:</strong> We have a web application that receives user orders. We want to process these orders asynchronously in another service without blocking the web application. Kafka acts as the intermediary, decoupling the two services.</p><ol><li><strong>Dependencies:</strong></li></ol><p>Add the spring-kafka kafka-clients kafka-streamsdependencies to your pom.xml in the corresponding sender, and receiver.</p><p><strong>2. Producer:</strong></p><p>Create a producer service that receives orders from the web application and publishes them to a Kafka topic:</p><pre>@Service<br>public class OrderProducer {<br>@Autowired<br>    private KafkaTemplate&lt;String, Order&gt; kafkaTemplate;<br>    public void submitOrder(Order order) {<br>        kafkaTemplate.send(&quot;orders&quot;, order);<br>        System.out.println(&quot;Order sent to Kafka: &quot; + order);<br>    }<br>}</pre><p><strong>3. Consumer:</strong></p><p>Create a consumer service that listens to the “orders” topic and processes the received orders in another service (simulated by logging here):</p><pre>@KafkaListener(topics = &quot;orders&quot;, groupId = &quot;order-processor&quot;)<br>public void processOrder(Order order) {<br>    // Simulate processing in another service<br>    System.out.println(&quot;Processing order: &quot; + order);<br>}</pre><p><strong>4. Running the application:</strong></p><ul><li>Start a Kafka cluster (locally or using a managed service).</li><li>Run the Spring Boot application.</li><li>Submit an order through your web application.</li></ul><p><strong>Value of Kafka in this example:</strong></p><ul><li><strong>Decoupling:</strong> The web application and order processing service are independent, improving scalability and maintainability.</li><li><strong>Asynchronous processing:</strong> Orders are processed asynchronously, preventing the web application from blocking.</li><li><strong>Scalability:</strong> You can easily scale Kafka horizontally to handle high volumes of orders.</li><li><strong>Fault tolerance:</strong> If a consumer fails, other consumers can process the order, ensuring data integrity.</li></ul><p><strong>Note:</strong> This is a simplified example. In a real application, you’ll likely need additional features like error handling, retries, and data serialization/deserialization.</p><p><strong>Additional points:</strong></p><ul><li>You can configure different producer and consumer properties (e.g., retry attempts, batching etc.) for various use cases.</li><li>Spring Boot Kafka offers additional features like stream processing (KSQL) and monitoring.</li></ul><p>I hope this small example demonstrates the value of Kafka in decoupling services and enabling asynchronous processing!</p><h3><strong>Conclusion</strong></h3><p>Apache Kafka is a powerful and versatile platform that can be used for a variety of use cases. Its scalability, fault tolerance, high performance, and flexibility make it a popular choice for mission-critical applications. If you are looking for a platform to handle high-volume, real-time data feeds, then Apache Kafka is a great option to consider.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32498af39bc4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rethinking Microservices Communication: Moving Beyond HTTP/RESTful APIs]]></title>
            <link>https://medium.com/@moaidmoaidrazhy/rethinking-microservices-communication-moving-beyond-http-restful-apis-c238353417a0?source=rss-3c5918214738------2</link>
            <guid isPermaLink="false">https://medium.com/p/c238353417a0</guid>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Muayad alrazehi]]></dc:creator>
            <pubDate>Thu, 15 Feb 2024 05:13:22 GMT</pubDate>
            <atom:updated>2024-02-15T05:20:50.184Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FVZC6VBUbic5vG8wRbZzvg.jpeg" /></figure><p>we all know that microservices are separate applications with possibly different frameworks, languages, and platforms that perform certain tasks, traditionally the go-to method for microservices communication has been through HTTP/RESTful APIs. While this approach has been reliable and widely adopted, it’s essential to recognize that it may not always be the most efficient solution, especially in diverse microservices architectures where applications are developed using different languages and frameworks. In this article, we will explore various communication methods beyond HTTP/RESTful APIs, shedding light on more efficient and versatile approaches.</p><h4>HTTP/RESTful APIs: The Standard Norm:</h4><ul><li>Historically, microservices have heavily relied on HTTP/RESTful APIs for communication.</li><li>This approach simplifies integration, making it easier for services to interact through well-defined endpoints.</li><li>However, as microservices ecosystems grow in complexity, new challenges emerge that call for more specialized communication methods.</li></ul><h4>Message Brokers: Asynchronous Communication:</h4><ul><li>To address the limitations of synchronous communication, microservices often leverage message brokers like RabbitMQ or Apache Kafka.</li><li>Message brokers facilitate asynchronous communication, enabling services to exchange information without being directly dependent on one another.</li><li>This approach enhances system resilience and scalability.</li><li>In the message broker model, there are senders (microservices publishing messages) and listeners (microservices subscribing to receive relevant messages).</li></ul><h4>gRPC: Optimizing Remote Procedure Calls:</h4><ul><li>For high-performance communication, gRPC has gained popularity as an open-source RPC (Remote Procedure Call) framework.</li><li>It employs Protocol Buffers for serialization, offering efficient communication between microservices.</li><li>gRPC’s support for bidirectional streaming makes it particularly suitable for real-time applications.</li></ul><h4>GraphQL: Tailored Data Queries:</h4><ul><li>Microservices seeking more flexibility in data retrieval often turn to GraphQL.</li><li>GraphQL allows clients to query the data they need, reducing over-fetching and under-fetching of information.</li><li>This approach enhances communication efficiency by tailoring responses to specific client requirements.</li></ul><h4>WebSocket for Real-Time Interaction:</h4><ul><li>Real-time communication in microservices is efficiently handled through WebSocket protocols.</li><li>WebSocket provides full-duplex communication channels, ensuring instant data updates between services.</li><li>It is a valuable choice for applications requiring real-time collaboration and notifications.</li></ul><h4>Service Mesh: Dedicated Communication Infrastructure:</h4><ul><li>Service mesh tools like Istio or Linkerd introduce a dedicated infrastructure layer for handling service-to-service communication.</li><li>Features like load balancing, encryption, and traffic management simplify the complexities of microservices communication.</li><li>Service mesh enhances communication reliability and security.</li></ul><h4>Event Sourcing: Ensuring Consistency:</h4><ul><li>Event sourcing introduces a paradigm where every change to the application state is captured as a sequence of events.</li><li>Microservices can subscribe to relevant events, ensuring consistency across the system.</li><li>Event sourcing enhances traceability and scalability in a microservices architecture.</li></ul><p><strong>Conclusion</strong>:</p><p>While HTTP/RESTful APIs have been the cornerstone of microservices communication, it’s crucial to acknowledge that they are not the only solution, and in many cases, <strong>not the most efficient one</strong>. By exploring alternative communication methods tailored to the diverse needs of microservices, developers can create architectures that are not only robust and scalable but also optimized for the unique challenges posed by different applications using various languages and frameworks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c238353417a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Microservices vs. Monolith Architecture]]></title>
            <link>https://medium.com/@moaidmoaidrazhy/microservices-vs-monolith-b3dbc96de71a?source=rss-3c5918214738------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3dbc96de71a</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Muayad alrazehi]]></dc:creator>
            <pubDate>Tue, 13 Feb 2024 22:46:20 GMT</pubDate>
            <atom:updated>2024-02-13T23:01:01.899Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*4cvpkyLEX3TZUCyIp85sbg.jpeg" /></figure><p>Microservices architecture is a <strong>paradigm in software development</strong> where a complex application is decomposed into a collection of <strong>small, independent services</strong> that communicate with each other through well-defined APIs.</p><p>Each microservice is designed to <strong>perform a specific business function</strong>, and together they collaborate to deliver the overall application functionality.</p><p>This approach contrasts with the traditional <strong>monolithic architecture</strong>, where the entire application is built as a <strong>single</strong>, tightly <strong>integrated unit</strong>.</p><h4><strong>The Monolith: Classic Unity</strong></h4><p>Now, picture a tightly-knit community, where everyone collaborates seamlessly. That’s the monolith approach. In this architecture, the entire application resides in a single codebase, offering its own set of benefits:</p><p><strong>Simplicity:</strong> Development, debugging, and monitoring are easier as everything is in one place. No need to juggle numerous moving parts.</p><p><strong>Performance:</strong> Communication within a single process minimizes network overhead, potentially leading to better performance for specific use cases.</p><p><strong>Lower Operational Overhead:</strong> Less infrastructure and operational expertise are required compared to microservices, reducing complexity and costs.</p><p><strong>Security:</strong> A smaller attack surface due to the application functioning within a single unit improves overall security posture.</p><p><strong>Faster development for smaller projects:</strong> For simpler applications with limited functionalities and growth expectations, a monolith offers a quicker and more resource-efficient development process.</p><p>However, this unity can also become a limitation:</p><p><strong>Scalability:</strong> Scaling the entire application can be inefficient, as all functionalities share resources, potentially leading to bottlenecks.</p><p><strong>Agility:</strong> Changes require redeploying the entire application, potentially slowing down development cycles and hindering agility.</p><p><strong>Fault Tolerance:</strong> A failure in one part can bring down the entire application, impacting overall reliability.</p><p><strong>Technology Limitations:</strong> Tied to a single technology stack, the monolith limits flexibility and adoption of new technologies.</p><p><strong>Team Complexity:</strong> Managing a large codebase can be challenging for large teams, potentially hindering ownership and agility.</p><h4>Microservices: The Distributed Powerhouse</h4><p>Imagine a bustling metropolis, each district serving a specific need. That’s the essence of microservices. In this architecture, an application is composed of several independent, self-contained services, each responsible for a distinct functionality. This distributed approach boasts several <strong>advantages</strong>:</p><p><strong>Scalability on Demand:</strong> Need more muscle for user authentication? Simply scale up that specific service! Unlike monoliths, where scaling the entire application can be cumbersome, microservices allow you to scale specific functionalities based on their individual needs, optimizing resource utilization.</p><p><strong>Agile Development:</strong> Gone are the days of waiting for entire applications to be updated. With microservices, teams can work on, deploy, and update individual services independently, speeding up development cycles and fostering faster innovation. Imagine fixing a bug in the payment service without impacting the shopping cart functionality!</p><p><strong>Resilience in the Face of Failure:</strong> A glitch in one service, like a power outage in a district, won’t cripple the entire system. The isolation of microservices ensures resilience, keeping the rest of the application humming smoothly. Even if the user authentication service experiences hiccups, users with active sessions can still browse products.</p><p><strong>Technological Playground:</strong> Feeling adventurous? Different services can leverage different technologies, catering to their specific needs. This promotes experimentation and allows you to choose the best tool for each job, just like a city might have dedicated districts for tech startups and historical landmarks.</p><p><strong>Empowering Teams:</strong> Foster ownership and responsibility by assigning distinct services to dedicated teams. This focused approach leads to clear accountability and a deeper understanding of each functionality.</p><p>However, this distributed landscape also brings its own set of <strong>challenges</strong>:</p><p><strong>Complexity Symphony:</strong> Debugging, monitoring, and managing communication between numerous services demand increased effort and expertise. It’s like coordinating a complex transportation network in a bustling metropolis.</p><p><strong>Operational Overhead:</strong> More moving parts translate to more complexity in infrastructure and operational overhead. Think of the additional traffic management and maintenance required in a city with many districts.</p><p><strong>Network Latency Blues:</strong> Communication between services adds network overhead, potentially impacting performance, especially for latency-sensitive applications. Imagine relying on slow messengers to carry crucial information between districts.</p><p><strong>Security Tightrope Walk:</strong> A wider attack surface due to its distributed nature and API communication necessitates robust security measures, just like a city with many entry points needs strong security protocols.</p><p><strong>Development Coordination:</strong> Coordinating development across services requires additional tooling, processes, and communication, adding complexity to the software development lifecycle.</p><p><strong>When to Choose:</strong></p><p>Neither approach is inherently superior. The optimal choice depends on your specific project requirements and team capabilities. Carefully consider the trade-offs between flexibility, scalability, and ease of development when making your decision.</p><p>That was it. see you soon :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3dbc96de71a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Flutter Flavors]]></title>
            <link>https://medium.com/@moaidmoaidrazhy/understanding-flutter-flavors-470166244585?source=rss-3c5918214738------2</link>
            <guid isPermaLink="false">https://medium.com/p/470166244585</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[flavor]]></category>
            <category><![CDATA[configuration]]></category>
            <dc:creator><![CDATA[Muayad alrazehi]]></dc:creator>
            <pubDate>Tue, 13 Feb 2024 02:04:41 GMT</pubDate>
            <atom:updated>2024-02-13T02:04:41.856Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*21lqKYB0wO_khDU7UDXGMg.jpeg" /></figure><p>Have you ever wondered how to set up different environments in your Flutter app?</p><p>Flutter’s flexibility allows developers to create versatile applications with a single codebase. One powerful feature contributing to this flexibility is “flavors.”<br><strong>Flavors</strong> (known as <em>build configurations, Scheme</em> in iOS and macOS) or flavorDimensions in Android enable the creation of different versions of an app that share a common codebase but have distinct configurations, features, or branding. This is particularly useful when managing various environments such as development, staging, and production.</p><p>Let’s get our hands dirty and see what we are talking about in action.<br><strong>Objective</strong>: create a flutter <strong>Android app with two environments each with a different color and title and build APKs from each environment that are distinct in their application ID and build name</strong>.</p><p>first, let&#39;s create a class representing our environment and main color</p><pre>class EnvConfig {<br>  final String env;<br>  final Color mainColor;<br><br>  EnvConfig({<br>    required this.env,<br>    required this.mainColor,<br>  });<br>}</pre><p>let’s edit the <em>main.dart</em>, remove the default main method and replace it with this one</p><pre>void runWithConfig(EnvConfig config) {<br>  runApp(FlavorsApp(envConfig: config));<br>}</pre><p>our simple app just to see the changes, nothing fancy.</p><pre>class FlavorsApp extends StatelessWidget {<br>  final EnvConfig envConfig;<br><br>  const FlavorsApp({super.key, required this.envConfig});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      title: &#39;Flutter Flavors Demo&#39;,<br>      theme: ThemeData(<br>        colorScheme: ColorScheme.fromSeed(seedColor: envConfig.mainColor),<br>      ),<br>      home: Scaffold(<br>        appBar: AppBar(<br>          title:  Text(&#39;Env is ${envConfig.env}&#39;),<br>        ),<br>        body:  const Center(<br>          child: Text(&#39;Hello, world!&#39;),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>let’s create two dart main_env1 and main_env2</p><pre>void main() {<br>  final env1 = EnvConfig(<br>    env: &#39;Env 1&#39;,<br>    mainColor: Colors.deepPurple,<br>  );<br>  runWithConfig(env1);<br>}</pre><pre>void main() {<br>  final env1 = EnvConfig(<br>    env: &#39;Env 2&#39;,<br>    mainColor: Colors.deepOrange,<br>  );<br>  runWithConfig(env1);<br>}</pre><p>now let’s add a new build config to Android Studio so we can run and check if everything is going well so far</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*sjSsh-SbiQkAqbJnhu9v_Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*trdttntxk52BOCEpJxlukg.png" /></figure><p>and the same thing for env2.</p><p>now we can choose the environment to run on</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*2RcLMzvTgiI6CDeuL-X9lQ.png" /></figure><p>and see the changes appearing</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ybhEpXFS6hg6u2Km4pO_-Q.png" /></figure><p>Good So Far 🤩 , but we didn’t use flavor yet😱<br>and we don’t know how we can build APKs with different IDs and Build based on the environment, here where <strong>flavorDimensions </strong>come</p><p>let’s go to app-level build.gradle file and add the following to android block</p><pre>flavorDimensions &quot;flavor_demo&quot; <br>    productFlavors {<br>        env1 {<br>            dimension &quot;flavor_demo&quot;<br>            applicationIdSuffix &quot;.env1&quot; <br>            versionNameSuffix &quot;-env1&quot; <br>        }<br>        env2 {<br>            dimension &quot;flavor_demo&quot;<br>            applicationIdSuffix &quot;.env2&quot;<br>            versionNameSuffix &quot;-env2&quot;<br>        }<br>    }</pre><p><strong>flavorDimensions</strong> is a way of grouping product flavors , you can have multiple dimensions like flavor_demo, flavor_demo2 etc</p><p><strong>applicationIdSuffix</strong> Will be appended to the applicationId</p><p><strong>versionNameSuffix</strong> Will be appended to the versionName</p><p>now you can run the following and get separate APKs with your config and different app IDs and build names</p><pre>flutter build apk --flavor env1 -t lib/main_env1.dart<br>flutter build apk --flavor env2 -t lib/main_env2.dart</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*X3bxPP3I7GaU2H7x-nllwQ.png" /></figure><p>Well, this was a small explanation about flavors in Android, and similar steps using schemes can be done in IOS, This is just a starting point. You can use flavors for more advanced scenarios:</p><ul><li><strong>Connect to different Firebase projects:</strong> Use environment-specific GoogleServices-Info.plist files for each flavor.</li><li><strong>Enable/disable features:</strong> Use conditional logic based on the flavor to show/hide specific UI elements or functionality.</li><li><strong>Manage secrets:</strong> Store environment-specific secrets securely and access them based on the flavor.</li></ul><p>Remember, flavors are a powerful tool for managing app variations efficiently. By understanding their potential and implementing them effectively, you can create adaptable and targeted experiences for your users across different environments.</p><p>Thanks for reaching this far !.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=470166244585" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[node watch vs. nodemon]]></title>
            <link>https://medium.com/@moaidmoaidrazhy/node-watch-vs-nodemon-4c8f0fc8a1af?source=rss-3c5918214738------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c8f0fc8a1af</guid>
            <category><![CDATA[hot-reload]]></category>
            <category><![CDATA[hot-restart]]></category>
            <category><![CDATA[filewatcher]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[nodemon]]></category>
            <dc:creator><![CDATA[Muayad alrazehi]]></dc:creator>
            <pubDate>Thu, 05 Oct 2023 03:08:28 GMT</pubDate>
            <atom:updated>2023-10-05T03:23:05.587Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*hKKXqbrQFhMciis34S4Yww.png" /></figure><p>what is the difference? <strong>node — watch main.js</strong> ,<strong> modemon main.js</strong></p><p><a href="https://www.npmjs.com/package/nodemon"><strong>nodemon</strong></a> is a package for node that is described by authors like</p><blockquote>a tool that helps develop Node.js based applications by automatically restarting the node application when file changes in the directory are detected.</blockquote><blockquote>nodemon does <strong>not</strong> require <em>any</em> additional changes to your code or method of development. nodemon is a replacement wrapper for node. To use nodemon, replace the word node on the command line when executing your script.</blockquote><p>On the other hand <strong>node -- watch </strong>is a mode in which you can run your node server and it will reload when a change happens to the specified file or path, it was first introduced in <a href="https://nodejs.org/en/blog/release/v18.11.0#watch-mode-experimental"><strong>v18.11.0</strong></a><strong> </strong>as an <strong>experimental feature</strong>.</p><h4><strong>Watch Mode Usage Example</strong></h4><p>Imagine you have the following js files.</p><pre>// second.js<br>console.log(&quot;Hi from second.js&quot;);</pre><pre>// first.js<br>import &quot;./second.js&quot;;<br><br>console.log(&quot;Hi from first.js&quot;);</pre><p>now if we run</p><pre>node --watch first.js</pre><p>any change in first.js would cause the server to restart however the interesting part is that <strong>if a change happens in the second server will restart.</strong></p><p>you can also specify certain directory to be observed like this</p><pre>node --watch-path=./someFolder someFile.js</pre><h4>Nodemon Usage Example</h4><pre>nodemon first.js</pre><p>nodemon supports local and global configuration files. These are usually named nodemon.json and can be located in the current working directory or in your home directory. An alternative local configuration file can be specified with the --config &lt;file&gt; option.</p><pre>// nodemon.json<br>{<br>  &quot;verbose&quot;: true,<br>  &quot;ignore&quot;: [&quot;*.test.js&quot;, &quot;**/fixtures/**&quot;],<br>  &quot;execMap&quot;: {<br>    &quot;rb&quot;: &quot;ruby&quot;,<br>    &quot;pde&quot;: &quot;processing --sketch={{pwd}} --run&quot;<br>  }<br>}</pre><h3><strong>When to use which?</strong></h3><p>if you are looking for a <strong>simple</strong> server reload whenever a change happens you can <strong>node watch mode.</strong></p><p>if you have a large project that has <strong>complex</strong> structure and files that don’t require observing and you want more control then go with <strong>nodemon </strong>since it allows for adding <strong>config files </strong>to ignore files or customize the behavior of its execution or even maybe run it on non-node projects!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c8f0fc8a1af" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>