<?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 Muhammad Sufiyan on Medium]]></title>
        <description><![CDATA[Stories by Muhammad Sufiyan on Medium]]></description>
        <link>https://medium.com/@ksufi7350?source=rss-4b40ec0ffce2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BMgO_UFJeWgMgsxdeL2txQ.jpeg</url>
            <title>Stories by Muhammad Sufiyan on Medium</title>
            <link>https://medium.com/@ksufi7350?source=rss-4b40ec0ffce2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 20:11:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ksufi7350/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[Demystifying Machine Learning: Supervised vs. Unsupervised Learning with Real-Life Stories]]></title>
            <link>https://medium.com/@ksufi7350/title-demystifying-machine-learning-supervised-vs-7c267ad38e44?source=rss-4b40ec0ffce2------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c267ad38e44</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Muhammad Sufiyan]]></dc:creator>
            <pubDate>Sun, 19 Jan 2025 15:49:20 GMT</pubDate>
            <atom:updated>2025-01-20T08:12:48.263Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Demystifying Machine Learning: Supervised vs. Unsupervised Learning with Real-Life Stories</strong></p><p><strong>Introduction: The Rise of Machine Learning</strong><br>Machine Learning (ML) is a transformative technology that is reshaping industries and enhancing everyday life. From recommending your next Netflix binge to detecting fraudulent transactions, ML has become a cornerstone of innovation. But what exactly is ML?</p><p>In simple terms, ML is a branch of artificial intelligence (AI) that enables machines to learn from data and improve their performance over time without being explicitly programmed. At its core, ML can be broadly divided into two main types: <strong>Supervised Learning</strong> and <strong>Unsupervised Learning</strong>. Let’s dive into these categories, explore their differences, and understand how they apply to real-world problems.</p><p>— -</p><p><strong>What is Supervised Learning?</strong><br>Supervised Learning is like learning under a mentor’s guidance. The algorithm is trained using a dataset that includes <strong>labeled data</strong> — where each input is paired with a corresponding output. The model’s goal is to learn a mapping from inputs to outputs and use this knowledge to make predictions on new, unseen data.</p><p><strong>Key Characteristics of Supervised Learning:</strong><br>1. <strong>Labeled Data:</strong> The training data includes input-output pairs.<br>2. <strong>Goal</strong>: Learn the relationship between inputs and outputs.<br>3. <strong>Feedback:</strong> The model’s predictions are compared to actual labels, and errors are corrected during training.</p><p><strong>Types of Supervised Learning</strong>:<br>1. <strong>Regression:</strong><br> — Used to predict continuous values.<br> — <strong>Example:</strong> Predicting house prices based on features like area, number of bedrooms, and location.</p><p>2. <strong>Classification:</strong><br> — Used to predict categories or discrete labels.<br> — <strong>Example:</strong> Email spam detection, where emails are classified as “Spam” or “Not Spam.”</p><p><strong>Real-Life Example: Predicting House Prices</strong><br>Imagine a real estate company wants to predict the price of houses. They collect data on:<br>- <strong>Inputs (Features): </strong>House size, number of bedrooms, neighborhood.<br>- <strong>Output (Label)</strong>:House price.</p><p>Using this labeled dataset, the supervised learning model learns to predict the price of a house based on its features.</p><p>— -</p><p><strong>What is Unsupervised Learning?</strong><br>Unsupervised Learning is like exploring a new city without a map. The algorithm works with <strong>unlabeled data</strong>, meaning there are no predefined outputs. The model’s goal is to find patterns, relationships, or structures within the data.</p><p>Key Characteristics of Unsupervised Learning:<br>1. <strong>Unlabeled Data: </strong>Only input data is provided, with no output labels.<br>2. <strong>Goal: </strong>Discover hidden patterns or group similar data points.<br>3. <strong>Autonomy: </strong>The algorithm works independently to organize data.</p><p><strong>Types of Unsupervised Learning:</strong><br>1. <strong>Clustering:<br></strong> — Groups similar data points into clusters.<br> — <strong>Example</strong>: Customer segmentation in marketing.</p><p>2. <strong>Dimensionality Reduction:</strong><br> — Reduces the number of features in the data while retaining important information.<br> — Example: Visualizing high-dimensional data in 2D or 3D.</p><p><strong>Real-Life Example: Customer Segmentation</strong><br>E-commerce platforms often use unsupervised learning to group customers based on:<br>- <strong>Inputs (Features):</strong> Purchase history, browsing patterns, demographics.</p><p>The algorithm identifies clusters of customers (e.g., budget shoppers, tech enthusiasts) without any predefined labels. These insights help businesses target each group with personalized offers.</p><p>— -</p><p><strong>Applications of Supervised and Unsupervised Learning</strong></p><p><strong>Supervised Learning Applications:</strong><br>1. <strong>Medical Diagnosis:</strong> Predicting diseases based on symptoms and medical history.<br>2. <strong>Finance</strong>: Detecting fraudulent transactions by analyzing labeled transaction data.<br>3. <strong>Weather Forecasting</strong>: Predicting temperature, rainfall, and other weather conditions.</p><p><strong>Unsupervised Learning Applications:</strong><br>1. <strong>Social Media:</strong> Grouping users with similar interests for targeted content recommendations.<br>2. <strong>E-commerce: </strong>Recommending products by clustering users with similar buying patterns.<br>3. <strong>Biology:</strong> Analyzing DNA sequences to discover genetic similarities.</p><p>— -</p><p><strong>Conclusion: The Journey Ahead</strong><br>Supervised and unsupervised learning are two fundamental pillars of Machine Learning. While supervised learning excels in tasks where labeled data is available, unsupervised learning shines in uncovering hidden insights from raw, unlabeled data. Together, these approaches enable machines to solve a wide range of problems — from predicting outcomes to discovering patterns.</p><p>Understanding these methods is the first step in your journey to mastering Machine Learning. The next? Exploring real-world algorithms and diving into hands-on projects. The possibilities are endless, and ML is your gateway to shaping the future!</p><p>— -</p><p><strong>Call to Action:</strong><br>If you found this article helpful, share it with your peers and join the conversation in the comments! What ML application excites you the most? Let us know below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c267ad38e44" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Efficient Routing in Flutter Using onGenerateRoute]]></title>
            <link>https://medium.com/@ksufi7350/efficient-routing-in-flutter-using-ongenerateroute-20dff172d192?source=rss-4b40ec0ffce2------2</link>
            <guid isPermaLink="false">https://medium.com/p/20dff172d192</guid>
            <category><![CDATA[routing]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[navigation]]></category>
            <dc:creator><![CDATA[Muhammad Sufiyan]]></dc:creator>
            <pubDate>Sun, 29 Dec 2024 14:24:22 GMT</pubDate>
            <atom:updated>2024-12-29T14:24:22.688Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*cQAr3pK7YZ_3e7VUTHie5Q.png" /></figure><p>In modern Flutter app development, efficient navigation plays a key role in ensuring maintainability and scalability. While traditional routing methods involve hardcoding route paths in the MaterialApp widget, this approach can quickly become cumbersome as the app grows. A better approach involves using the onGenerateRoute property along with centralized route management. In this article, we’ll explore how to implement this approach, emphasizing its advantages over traditional methods.</p><h3>The Problem with Traditional Routing</h3><p>In traditional routing, routes are typically declared directly in the MaterialApp widget like this:</p><pre>MaterialApp(<br>  routes: {<br>    &#39;/&#39;: (context) =&gt; SplashScreen(),<br>    &#39;/home&#39;: (context) =&gt; HomeScreen(),<br>    &#39;/login&#39;: (context) =&gt; LoginScreen(),<br>    &#39;/signup&#39;: (context) =&gt; SignupScreen(),<br>  },<br>);</pre><p>While this method works well for small applications, it becomes problematic in larger apps:</p><ol><li><strong>Scalability Issues</strong>: Adding new routes requires modifying the central routes map, making it error-prone and harder to manage.</li><li><strong>Lack of Modularity</strong>: All route logic is tightly coupled, violating principles of modular programming.</li><li><strong>Debugging Challenges</strong>: Missing or incorrect route names can lead to runtime errors, making debugging difficult.</li></ol><p>To address these issues, we’ll use a modular approach with onGenerateRoute.</p><h3>Breaking Down the Solution</h3><p>Our solution involves three steps:</p><ol><li><strong>Create a Centralized Route Name File</strong></li><li><strong>Implement a Route Generator</strong></li><li>**Define Routes in **<strong>main.dart</strong></li></ol><p>Let’s explore each step in detail.</p><h3>1. Create a Centralized Route Name File</h3><p>We begin by defining all our route names in a separate class. This ensures consistency and avoids hardcoding strings throughout the app.</p><p>**File: **<strong>routes_names.dart</strong></p><pre>class RoutesNames {<br>  static const String splash = &#39;splash_screen&#39;;<br>  static const String home = &#39;home_screen&#39;;<br>  static const String login = &#39;login_screen&#39;;<br>  static const String signup = &#39;signup_screen&#39;;<br>}</pre><p>This file acts as a single source of truth for route names, ensuring consistency and reducing errors.</p><h3>2. Implement a Route Generator</h3><p>Next, we create a separate class to handle route switching logic based on the RouteSettings passed to it. This improves modularity and makes the navigation logic reusable.</p><p>**File: **<strong>routes.dart</strong></p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:mvvm_architecture/view/home_screen_view.dart&#39;;<br>import &#39;package:mvvm_architecture/view/login_view.dart&#39;;<br>import &#39;package:mvvm_architecture/view/signup_view.dart&#39;;<br>import &#39;package:mvvm_architecture/view/splash_screen.dart&#39;;</pre><pre>class Routes {<br>  static Route&lt;dynamic&gt; generateRoute(RouteSettings settings) {<br>    switch (settings.name) {<br>      case &#39;splash_screen&#39;:<br>        return MaterialPageRoute(builder: (_) =&gt; SplashScreen());<br>      case &#39;home_screen&#39;:<br>        return MaterialPageRoute(builder: (_) =&gt; HomeScreen());<br>      case &#39;login_screen&#39;:<br>        return MaterialPageRoute(builder: (_) =&gt; LoginView());<br>      case &#39;signup_screen&#39;:<br>        return MaterialPageRoute(builder: (_) =&gt; SignupView());<br>      default:<br>        return MaterialPageRoute(<br>          builder: (_) =&gt; Scaffold(<br>            body: Center(<br>              child: Text(&#39;No route defined for \${settings.name}&#39;),<br>            ),<br>          ),<br>        );<br>    }<br>  }<br>}</pre><p>The generateRoute method uses a switch statement to map route names to their corresponding screens. If a route is not defined, a fallback screen displays an error message, ensuring graceful failure.</p><h3>3. Define Routes in main.dart</h3><p>Finally, we configure our MaterialApp to use the route generator and set the initial route.</p><p>**File: **<strong>main.dart</strong></p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:mvvm_architecture/util/routes/routes_names.dart&#39;;<br>import &#39;package:mvvm_architecture/util/routes/routes.dart&#39;;<br>import &#39;package:mvvm_architecture/view_model/user_view_model.dart&#39;;<br>import &#39;package:mvvm_architecture/view_model/auth_view_model.dart&#39;;<br>import &#39;package:provider/provider.dart&#39;;</pre><pre>void main() {<br>  runApp(const MyApp());<br>}</pre><pre>class MyApp extends StatelessWidget {<br>  const MyApp({Key? key}) : super(key: key);</pre><pre>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>        title: &#39;Flutter Demo&#39;,<br>        theme: ThemeData(<br>          primarySwatch: Colors.blue,<br>        ),<br>        initialRoute: RoutesNames.splash,<br>        onGenerateRoute: Routes.generateRoute,<br>      ),<br>    );<br>  }<br>}</pre><p>Here, we:</p><ul><li>Set RoutesNames.splash as the initialRoute.</li><li>Use the onGenerateRoute property to delegate route switching logic to our Routes class.</li></ul><h3>4. Navigate Between Screens</h3><p>With the routing system in place, navigating between screens becomes seamless. Use the Navigator.pushNamed method to navigate to a specific route:</p><pre>Navigator.pushNamed(context, RoutesNames.home);</pre><p>Here, RoutesNames.home ensures consistency and prevents hardcoding route names, making navigation more reliable.</p><h3>Advantages of This Approach</h3><ol><li><strong>Modularity</strong>: Separating route names and route logic into different files makes the codebase more organized and maintainable.</li><li><strong>Scalability</strong>: Adding or modifying routes is straightforward, as all logic is centralized.</li><li><strong>Consistency</strong>: Using constants for route names ensures consistency and minimizes the risk of typos.</li><li><strong>Graceful Error Handling</strong>: The fallback route ensures that the app doesn’t crash if an undefined route is accessed.</li><li><strong>Better Debugging</strong>: Centralized logic makes it easier to trace and fix navigation-related issues.</li></ol><h3>Conclusion</h3><p>Using onGenerateRoute with centralized route management is a clean and scalable way to handle navigation in Flutter applications. By separating route names and logic into distinct files, you can significantly improve the maintainability and scalability of your app. This approach is especially beneficial for larger apps where traditional methods fall short.</p><p>Adopt this modern routing technique in your next Flutter project and experience the difference!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20dff172d192" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MVVM: Officially Recommended by Google for Flutter Development]]></title>
            <link>https://medium.com/@ksufi7350/mvvm-officially-recommended-by-google-for-flutter-development-ba17f899d320?source=rss-4b40ec0ffce2------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba17f899d320</guid>
            <category><![CDATA[mvvm-architecture]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Muhammad Sufiyan]]></dc:creator>
            <pubDate>Sun, 29 Dec 2024 10:58:11 GMT</pubDate>
            <atom:updated>2024-12-29T11:22:23.832Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qUPeSn5De7lFmj7B4KRDnQ.png" /></figure><p>In a significant move, <strong>Google</strong> has officially recommended the MVVM (Model-View-ViewModel) architecture for Flutter app development. This announcement marks a pivotal moment, as it reaffirms the importance of MVVM in building modern, maintainable, and scalable applications. Google’s official recommendation of the MVVM (Model-View-ViewModel) architecture for Flutter app development was announced with the release of <strong>Flutter 3.27</strong> on <strong>July 11, 2024</strong>.</p><p>This article explores why MVVM is gaining traction, breaks down its fundamentals, and provides a detailed folder structure example to guide you in implementing this architecture in your Flutter projects.</p><h3>Why Google’s Endorsement Matters</h3><p>Google’s endorsement of MVVM solidifies its role as a go-to architectural pattern for Flutter developers. Google’s backing provides credibility, encourages adoption, and assures developers that MVVM aligns with best practices for building robust applications. It simplifies development workflows, enhances maintainability, and promotes a separation of concerns, which are essential in today’s agile development environment.</p><h3>What is MVVM?</h3><p>The MVVM architecture is a design pattern that separates the application’s logic into three distinct layers:</p><ol><li><strong>Model</strong>: Manages the data and business logic. It retrieves and processes data, often from a repository or API, and acts as the single source of truth for the app.</li><li><strong>View</strong>: Represents the UI of the application and is responsible for displaying data to the user. The View listens to updates from the ViewModel but avoids holding any business logic.</li><li><strong>ViewModel</strong>: Acts as a bridge between the View and the Model. It handles UI logic, transforms data for the View, and exposes states or events that the View can observe.</li></ol><p>This separation of concerns ensures better testability, maintainability, and scalability of applications.</p><h3>Folder Structure for MVVM in Flutter</h3><p>To implement MVVM effectively in Flutter, organizing your project is crucial. Here’s an example of a folder structure for an MVVM-based Flutter app:</p><pre>lib/<br>├── data/<br>│   ├── network/<br>│   │   └── response/<br>│   │       └── app_exception.dart<br>│   ├── models/<br>│   └── repository/<br>├── resource/<br>├── util/<br>├── view/<br>├── view_model/<br>└── main.dart</pre><h3>Purpose of Each Folder</h3><ol><li><strong>data/network/response</strong>: Handles API responses and defines custom exceptions (app_exception.dart) to manage network errors effectively.</li><li><strong>data/models</strong>: Contains the data models used across the app. For example, a Todo model can define the structure of a to-do item.</li><li><strong>data/repository</strong>: Implements the repository pattern to abstract data sources. This ensures the ViewModel interacts with a unified API for data, whether it comes from a local database or a remote server.</li><li><strong>resource</strong>: Stores static resources like images, fonts, and localized strings.</li><li><strong>util</strong>: Houses utility functions, constants, and helpers that are used throughout the app.</li><li><strong>view</strong>: Contains the UI components (screens, widgets) that render the user interface.</li><li><strong>view_model</strong>: Implements the ViewModel classes, which manage UI logic and state. These classes expose data to the View and respond to user interactions.</li><li><strong>main.dart</strong>: The entry point of the application, where initial setups like Provider or GetIt dependency injections are configured.</li></ol><h3>Example: Building a To-Do App with MVVM</h3><p>Let’s apply the MVVM pattern to a simple To-Do app. Here’s how each layer interacts:</p><h3>Model</h3><pre>class Todo {<br>  final String id;<br>  final String title;<br>  final bool isCompleted;</pre><pre>  Todo({required this.id, required this.title, this.isCompleted = false});<br>}</pre><h3>ViewModel</h3><pre>import &#39;package:flutter/foundation.dart&#39;;<br>import &#39;../models/todo.dart&#39;;</pre><pre>class TodoViewModel extends ChangeNotifier {<br>  List&lt;Todo&gt; _todos = [];</pre><pre>  List&lt;Todo&gt; get todos =&gt; _todos;</pre><pre>  void addTodo(String title) {<br>    _todos.add(Todo(id: DateTime.now().toString(), title: title));<br>    notifyListeners();<br>  }</pre><pre>  void toggleTodoStatus(String id) {<br>    final index = _todos.indexWhere((todo) =&gt; todo.id == id);<br>    if (index != -1) {<br>      _todos[index] = Todo(<br>        id: _todos[index].id,<br>        title: _todos[index].title,<br>        isCompleted: !_todos[index].isCompleted,<br>      );<br>      notifyListeners();<br>    }<br>  }<br>}</pre><h3>View</h3><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:provider/provider.dart&#39;;<br>import &#39;../view_model/todo_view_model.dart&#39;;</pre><pre>class TodoScreen extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    final viewModel = Provider.of&lt;TodoViewModel&gt;(context);</pre><pre>    return Scaffold(<br>      appBar: AppBar(title: Text(&#39;MVVM To-Do App&#39;)),<br>      body: Column(<br>        children: [<br>          Expanded(<br>            child: ListView.builder(<br>              itemCount: viewModel.todos.length,<br>              itemBuilder: (context, index) {<br>                final todo = viewModel.todos[index];<br>                return ListTile(<br>                  title: Text(todo.title),<br>                  trailing: Checkbox(<br>                    value: todo.isCompleted,<br>                    onChanged: (_) {<br>                      viewModel.toggleTodoStatus(todo.id);<br>                    },<br>                  ),<br>                );<br>              },<br>            ),<br>          ),<br>          Padding(<br>            padding: const EdgeInsets.all(8.0),<br>            child: TextField(<br>              onSubmitted: (value) =&gt; viewModel.addTodo(value),<br>              decoration: InputDecoration(<br>                labelText: &#39;Add To-Do&#39;,<br>                border: OutlineInputBorder(),<br>              ),<br>            ),<br>          ),<br>        ],<br>      ),<br>    );<br>  }<br>}</pre><h3>Final Thoughts</h3><p>With Google’s official recommendation, MVVM has become a cornerstone of Flutter app development. Its focus on a clear separation of concerns, testability, and maintainability makes it an excellent choice for both beginners and advanced developers. By adopting the MVVM architecture and following the folder structure outlined here, you can create scalable and efficient Flutter apps.</p><p>Start integrating MVVM into your projects today and experience the difference it makes!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba17f899d320" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>