<?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 TommyRaspati on Medium]]></title>
        <description><![CDATA[Stories by TommyRaspati on Medium]]></description>
        <link>https://medium.com/@tommyraspati?source=rss-77fa947366f4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3K7PpIafpTvvHENwpzpYIA@2x.jpeg</url>
            <title>Stories by TommyRaspati on Medium</title>
            <link>https://medium.com/@tommyraspati?source=rss-77fa947366f4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 02:45:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tommyraspati/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[Enhancing Team Dynamics and People Management in University Projects]]></title>
            <link>https://medium.com/@tommyraspati/enhancing-team-dynamics-and-people-management-in-university-projects-6d7472a08523?source=rss-77fa947366f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d7472a08523</guid>
            <category><![CDATA[discord]]></category>
            <category><![CDATA[ppl-fasilkom-ui]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[teamwork]]></category>
            <dc:creator><![CDATA[TommyRaspati]]></dc:creator>
            <pubDate>Mon, 10 Jun 2024 14:51:43 GMT</pubDate>
            <atom:updated>2024-06-10T14:51:43.800Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_wj94VfcQ4WP3pNf.jpg" /></figure><p>As a third-year computer science student, I’ve experienced the highs and lows of working on team projects. Currently, I’m enrolled in a course called PPL (Proyek Perangkat Lunak), which requires us to create a software project, either a website or a mobile application. The catch? The teams are assigned randomly. This experience has taught me the importance of teamwork, effective people management, and strong team dynamics in achieving project success and fostering personal growth. In this article, I’ll share strategies for enhancing team dynamics and people management in a university course project setting.</p><h3>Understanding the Importance of Team Dynamics in University Projects</h3><p><strong>Defining Team Dynamics and Its Impact on Project Outcomes</strong></p><p>Team dynamics refer to the psychological and behavioral relationships between team members. In university projects, particularly in computer science courses, these dynamics can significantly impact project outcomes. Effective team dynamics lead to improved collaboration, creativity, and project quality.</p><p><strong>Challenges and Opportunities in University Projects</strong></p><p>University projects come with unique challenges and opportunities. The diverse skill sets within a team can be both a challenge and a benefit. For instance, our team consists of members who are strong in frontend development and others who excel in backend development. This diversity allows us to complement each other’s skills and learn from one another, ultimately enhancing the overall project.</p><p><strong>Benefits of Strong Team Dynamics</strong></p><ul><li><strong>Improved Collaboration:</strong> Effective communication and mutual respect lead to better teamwork.</li><li><strong>Increased Creativity:</strong> Diverse perspectives foster innovative solutions.</li><li><strong>Higher Project Quality:</strong> When team members work well together, the quality of the project improves.</li></ul><h3>Key Strategies for Enhancing Team Dynamics and People Management</h3><p><strong>1. Role Assignment and Communication</strong></p><p>In our team, we ensure that each member is responsible for one or more features of the website during each sprint. We use GitLab Issues to divide our tasks, this clear division of responsibilities helps prevent confusion and ensures that everyone knows what they need to do.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RV650GJpCrRFm_LTyI3Bzg.png" /></figure><p><strong>Importance of Communication</strong></p><p>Frequent communication is crucial. Human beings need to communicate to understand each other, share ideas, and solve problems. We prioritize open and frequent communication to ensure everyone is on the same page.</p><p><strong>2. Knowledge Sharing and Problem Solving on Discord</strong></p><p>Discord has been our go-to platform for communication. Here’s how we utilize it:</p><ul><li><strong>Knowledge Sharing:</strong> We share tutorials, code snippets, and resources in dedicated channels. This helps everyone stay updated and learn new things.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*ZwjCPay-2mNhc9m6Iiub4w.png" /></figure><ul><li><strong>Problem Solving:</strong> Whenever someone encounters a problem, they ask for help on Discord. This immediate assistance keeps the project moving forward.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*s2QP-EqK_InxLiE9W5sl6w.png" /></figure><ul><li><strong>Casual Conversations:</strong> We’ve dedicated a channel for non-project related discussions. Talking about movies, games, or other interests helps build camaraderie and strengthens team bonds.</li></ul><p><strong>3. Commenting on GitLab Merge Requests</strong></p><p>Providing constructive feedback on merge requests is a crucial part of our workflow. We highlight what was done well and suggest improvements. This practice not only improves the code quality but also fosters a culture of continuous learning and collaboration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*GVJWcVDSttqKzdm15cTvMg.png" /></figure><p><strong>4. Pair Programming</strong></p><p>For difficult tasks, we practice pair programming. This method involves two programmers working together at one workstation. One writes the code while the other reviews each line as it’s written. This approach not only enhances code quality but also encourages knowledge sharing and teamwork.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*JXPrdyVLdDAAV3WTOt93RA.png" /></figure><h3>Conclusion</h3><p>Working on a university course project as a randomly assigned team can be challenging, but it’s also an excellent opportunity to develop strong team dynamics and people management skills. By defining clear roles, maintaining open communication, sharing knowledge, and providing constructive feedback, you can enhance your team’s collaboration and project quality. These strategies have not only helped my team succeed in our PPL project but also enabled us to emerge as one of the top two teams in the class. I hope these insights can help you achieve similar success in your projects. 🤞❤️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d7472a08523" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Monitoring Your Django Project with Prometheus and Grafana]]></title>
            <link>https://medium.com/@tommyraspati/monitoring-your-django-project-with-prometheus-and-grafana-b06a5ca78744?source=rss-77fa947366f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/b06a5ca78744</guid>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[grafana]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[prometheus]]></category>
            <category><![CDATA[ppl-fasilkom-ui]]></category>
            <dc:creator><![CDATA[TommyRaspati]]></dc:creator>
            <pubDate>Mon, 10 Jun 2024 11:47:40 GMT</pubDate>
            <atom:updated>2024-06-10T11:47:40.320Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*3RyBO5pNVTk8GYH0K1mlyA.png" /></figure><p>Monitoring your web applications effectively ensures optimal performance and timely identification of issues. Prometheus and Grafana are powerful tools for monitoring your applications at scale. In this article, we will explore how to set up monitoring for a Django application using Prometheus for data collection and Grafana for data visualization.</p><p><strong>What are Prometheus and Grafana?</strong></p><ul><li><strong>Prometheus</strong> is an open-source system monitoring and alerting toolkit originally built by SoundCloud. It is highly dynamic, supports multiple modes of graphing and dashboarding, and gathers data at specified intervals.</li><li><strong>Grafana</strong> is an open-source platform for monitoring and observability. It allows you to query, visualize, alert on, and understand your metrics no matter where they are stored. It provides tools to turn your time-series database (TSDB) data into beautiful graphs and visualizations.</li></ul><h3>Step 1: Install Prometheus</h3><p><strong>Setting Up Prometheus</strong></p><ol><li><strong>Download and Install:</strong> You can download Prometheus from the official Prometheus website. Follow the installation instructions based on your operating system.</li><li><strong>Configure Prometheus to Scrape Django Metrics:</strong> Modify your Prometheus configuration file (prometheus.yml) to scrape metrics from your Django application running on localhost port 8000</li></ol><pre>global:<br>  scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.<br>  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.<br><br>scrape_configs:<br>  - job_name: &quot;prometheus&quot;<br>    static_configs:<br>      - targets: [&quot;localhost:8000&quot;]<br></pre><h3>Step 2: Set Up Django for Prometheus</h3><ol><li><strong>Install Django Prometheus Integration:</strong> Run the following command to install the django-prometheus package:</li></ol><pre>pip install django-prometheus</pre><p>2. <strong>Update Django Settings:</strong> Add django_prometheus to your INSTALLED_APPS and middleware in your Django settings.</p><pre>INSTALLED_APPS = [<br>    ...<br>    &#39;django_prometheus&#39;,<br>    ...<br>]<br><br>MIDDLEWARE = [<br>    &#39;django_prometheus.middleware.PrometheusBeforeMiddleware&#39;,<br>    ...<br>    &#39;django_prometheus.middleware.PrometheusAfterMiddleware&#39;,<br>]</pre><p>3. <strong>Expose Metrics Endpoint:</strong> Update your urls.py to include Prometheus&#39; URLs for metrics collection.</p><pre>from django.urls import path, include<br><br>urlpatterns = [<br>    ...<br>    path(&#39;&#39;, include(&#39;django_prometheus.urls&#39;)),<br>]</pre><p>4. <strong>Run Django Application:</strong> Ensure your Django application is running on port 8000.</p><h3>Step 3: Install and Run Grafana</h3><ol><li><strong>Install Grafana:</strong> Download Grafana from the official Grafana website. Follow the instructions for your operating system.</li><li><strong>Start Grafana Server:</strong> Navigate to the Grafana installation folder and run:</li></ol><pre>./bin/grafana-server</pre><p>3. <strong>Log In to Grafana:</strong> Access Grafana by going to http://localhost:3000. The default login is admin for both username and password.</p><h3>Step 4: Connect Prometheus with Grafana</h3><ol><li><strong>Add Prometheus as a Data Source:</strong></li></ol><ul><li>In Grafana, navigate to “Configuration” &gt; “Data Sources.”</li><li>Click “Add Data Source,” then select “Prometheus.”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zAOC2ZqAQI1IYyhDgYhPvA.png" /></figure><ul><li>Enter the URL http://localhost:9090 for Prometheus and click &quot;Save &amp; Test.&quot;</li></ul><h3>Step 5: Import and Set Up a Dashboard</h3><ol><li><strong>Import a Pre-configured Dashboard:</strong></li></ol><ul><li>Visit this Grafana dashboard <a href="https://grafana.com/grafana/dashboards/17658-django/">link</a> and copy the dashboard ID.</li><li>In Grafana, go to “+ Create” &gt; “Import,” paste the dashboard ID, and click “Load.”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lVz0cNDB3PMs1CWQ0MbckQ.png" /></figure><ul><li>Select the Prometheus data source you added earlier and finalize the import.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T37DpFH2cctOCbrbsN8NZg.png" /></figure><p>Congratulations! You have successfully set up a monitoring system for your Django project using Prometheus and Grafana. The setup is now complete, and you are all set to explore various metrics on your new dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F_SJvKaPLdeaMZK7QOYrLw.png" /></figure><p><strong>Conclusion</strong></p><p>By following these steps, you have successfully set up a monitoring system for your Django project using Prometheus and Grafana. This setup allows you to visualize important metrics about your application’s performance and health, enabling you to make informed decisions about optimizations and troubleshoot issues effectively.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b06a5ca78744" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring the MVT Design Pattern in Django with Vue.js Integration]]></title>
            <link>https://medium.com/@tommyraspati/exploring-the-mvt-design-pattern-in-django-with-vue-js-integration-ee8c22fc3170?source=rss-77fa947366f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee8c22fc3170</guid>
            <category><![CDATA[ppl-fasilkom-ui]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[TommyRaspati]]></dc:creator>
            <pubDate>Mon, 06 May 2024 02:10:16 GMT</pubDate>
            <atom:updated>2024-05-06T08:00:32.719Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/605/0*hYI4v7VwegwTSKUf.png" /><figcaption>Image from: <a href="https://certisured.com/blogs/let-s-talk-about-mvt-architecture-in-django/">https://certisured.com/blogs/let-s-talk-about-mvt-architecture-in-django/</a></figcaption></figure><h3>Introduction: Understanding the MVT Architecture in Django</h3><p>Django, a high-level Python web framework, simplifies the creation of complex, database-driven websites through its pragmatic design and emphasis on reusability. One of the core architectural principles of Django is its adherence to the Model-View-Template (MVT) pattern. This pattern is a Django-specific take on the widely known Model-View-Controller (MVC) architecture. The MVT framework divides an application into three interconnected components, each serving a distinct development aspect, which helps developers maintain a clean and manageable code structure. In this post, we’ll delve into how each component of the MVT architecture operates and explore a practical integration with Vue.js, enhancing the front-end interactivity of a Django project.</p><h3>The Components of MVT</h3><h4>1. Model (M)</h4><p>In Django’s MVT architecture, the Model represents the data access layer. It is responsible for managing the data and its integrity. The model defines the essential fields and behaviors of the data you’re storing. Essentially, it serves as the structure of your database, detailing the organization and the relationships between data entities.</p><p><strong>Example Code from </strong><strong>models.py</strong>:</p><pre>class Stock(models.Model):<br>    STATUS_CHOICES = [<br>        (&#39;NEED&#39;, &#39;Need to Process&#39;),<br>        (&#39;SELL&#39;, &#39;Ready to Sell&#39;),<br>        (&#39;PROCESS&#39;, &#39;In Process&#39;),<br>    ]<br>    id = models.UUIDField(primary_key = True, default=uuid.uuid4)<br>    name = models.CharField(max_length=100)<br>    date = models.DateField()<br>    quantity = models.IntegerField(validators=[MinValueValidator(0)])    <br>    quality = models.CharField(max_length=50)<br>    description = models.TextField()<br>    stock_status = models.CharField(max_length=50, choices=STATUS_CHOICES, default=&quot;NEED&quot;)<br>    document = models.FileField(upload_to=filepath</pre><h4>2. View (V)</h4><p>The View in Django, unlike in MVC where it represents the UI, acts as the controller. The View retrieves data from the Model and executes the appropriate template. It is a request handler that processes user requests, fetching data from the model and passing it to the template.</p><p><strong>Example Code from </strong><strong>views.py</strong>:</p><pre>class StockList(APIView):<br>    permission_classes = [IsAuthenticated]<br>    def get(self, request):<br>        stocks = Stock.objects.all()<br>        serializer = StockSerializer(stocks, many=True)<br>        return JsonResponse(serializer.data, safe=False)<br>  .<br>  .<br>  .<br><br>  class StockUpdate(APIView):<br>    permission_classes = [IsAuthenticated]<br><br>    def patch(self, request, pk, *args, **kwargs):<br>        stock = get_object_or_404(Stock, pk=pk)<br>        serializer = StockSerializer(stock, data=request.data, partial=True)<br>        if serializer.is_valid():<br>            serializer.save()<br>            return Response({&#39;status&#39;: &#39;success&#39;, &#39;message&#39;: &#39;Stock updated successfully&#39;})<br>        else:<br>            return Response({&#39;status&#39;: &#39;error&#39;, &#39;errors&#39;: serializer.errors}, status=status.HTTP_400_BAD_REQUEST)<br><br>    def get(self, request, pk, *args, **kwargs):<br>        stock = get_object_or_404(Stock, pk=pk)<br>        serializer = StockSerializer(stock)<br>        return Response({&#39;status&#39;: &#39;success get&#39;, &#39;stock&#39;: serializer.data})</pre><h4>3. Template (T)</h4><p>In traditional Django applications, the Template is a web template system mixed with Django Template Language (DTL). However, in modern web applications, especially those requiring rich interaction and dynamics like SPA or mobile apps, integrating JavaScript frameworks like Vue.js becomes beneficial. In such setups, Vue.js components take over the role of Django templates, managing the presentation layer on the client side.</p><p><strong>Example StockUpdate.vue Component</strong>:</p><pre>&lt;template&gt;<br>  &lt;div class=&quot;stock-update-wrapper&quot;&gt;<br>    &lt;!-- Notification on top for success/error messages --&gt;<br>    &lt;div v-if=&quot;notification.visible&quot; class=&quot;notification-card&quot; :class=&quot;{&#39;success&#39;: notification.type === &#39;success&#39;, &#39;error&#39;: notification.type === &#39;error&#39;}&quot;&gt;<br>      &lt;div class=&quot;notification-message&quot;&gt;{{ notification.message }}&lt;/div&gt;<br>    &lt;/div&gt;<br>    &lt;!-- Form for updating stock --&gt;<br>    &lt;h4 class=&quot;stock-update-header&quot;&gt;Update Stock&lt;/h4&gt;<br>    &lt;div class=&quot;stock-update-container&quot;&gt;<br>      &lt;div class=&quot;form-body&quot;&gt;<br>        &lt;!-- Form fields for stock data --&gt;<br>        &lt;div class=&quot;form-column&quot;&gt;<br>          &lt;div class=&quot;form-group&quot;&gt;<br>            &lt;label for=&quot;name&quot;&gt;Name:&lt;/label&gt;<br>            &lt;input v-model=&quot;formData.name&quot; type=&quot;text&quot; id=&quot;name&quot; required&gt;<br>            &lt;div class=&quot;warning&quot;&gt;{{ warnings.name }}&lt;/div&gt;<br>          &lt;/div&gt;<br>          &lt;!-- Additional fields omitted for brevity --&gt;<br>        &lt;/div&gt;<br>        &lt;!-- Submit button --&gt;<br>        &lt;div class=&quot;form-footer&quot;&gt;<br>          &lt;button @click=&quot;updateStockData&quot; type=&quot;button&quot; class=&quot;submit-btn&quot;&gt;Update Stock&lt;/button&gt;<br>        &lt;/div&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;<br></pre><h3>Connecting Vue.js with Django Backend</h3><p>Vue.js communicates with the Django backend through API calls, typically handled by Axios — a popular HTTP client. Below is the explanation of how the methods in the Vue.js component interact with Django:</p><ol><li><strong>Fetching Stock Data</strong>: When the component is mounted, it fetches the current stock data from the Django backend. This is done using the mounted() lifecycle method which calls fetchStockData().</li><li><strong>Updating Stock Data</strong>: The updateStockData() method sends updated data back to the server. If there are any file uploads (like documents), it uses FormData to handle multipart/form-data requests.</li></ol><p>Here’s a more detailed look at these methods:</p><pre>&lt;script&gt;<br>import axios from &#39;axios&#39;;<br>export default {<br>  data() {<br>    return {<br>      formData: {<br>        name: &#39;&#39;,<br>        date: &#39;&#39;,<br>        // other fields<br>      },<br>      warnings: {<br>        name: &#39;&#39;,<br>        // other fields<br>      },<br>      notification: {<br>        visible: false,<br>        message: &#39;&#39;,<br>        type: &#39;&#39; // &#39;success&#39; or &#39;error&#39;<br>      },<br>    };<br>  },<br>  mounted() {<br>    this.fetchStockData();<br>  },<br>  methods: {<br>    fetchStockData() {<br>      const stockId = this.$route.params.stockId; // Dynamic ID<br>      const baseURL = &#39;http://localhost:8000&#39;;<br>      axios.get(`${baseURL}/stock/stock-update/${stockId}/`)<br>        .then(response =&gt; {<br>          this.formData = response.data.stock;<br>        })<br>        .catch(error =&gt; {<br>          console.error(&#39;Error fetching stock data:&#39;, error);<br>        });<br>    },<br>    updateStockData() {<br>      if (!this.validateForm()) return;<br>      const stockId = this.$route.params.stockId; // Dynamic ID<br>      const baseURL = &#39;http://localhost:8000&#39;;<br>      const formData = new FormData();<br>      Object.keys(this.formData).forEach(key =&gt; {<br>        formData.append(key, this.formData[key]);<br>      });<br>      axios.patch(`${baseURL}/stock/stock-update/${stockId}/`, formData)<br>        .then(response =&gt; {<br>          this.notification = { visible: true, message: &#39;Stock updated successfully!&#39;, type: &#39;success&#39; };<br>        })<br>        .catch(error =&gt; {<br>          this.notification = { visible: true, message: &#39;Error updating stock data&#39;, type: &#39;error&#39; };<br>        });<br>    },<br>  }<br>};<br>&lt;/script&gt;</pre><h3>Explanation</h3><ul><li><strong>fetchStockData()</strong>: This method makes a GET request to the Django backend to fetch the initial data for a specific stock item identified by stockId. It populates the form fields with the data retrieved.</li><li><strong>updateStockData()</strong>: After validating the form, this method sends a PATCH request with the updated stock data. It handles both text and file data, preparing the request as multipart/form-data if files are included.</li></ul><h3>Understanding the Difference Between MVC and MVT</h3><p>While both MVC (Model-View-Controller) and MVT (Model-View-Template) are architectural patterns used in software development, they have distinct characteristics tailored to their respective frameworks and use cases.</p><p><strong>MVC</strong> is the classic design pattern extensively used in many different programming languages and frameworks. It divides the application into three interconnected components:</p><ul><li><strong>Model</strong>: Manages the data and business logic of the application.</li><li><strong>View</strong>: Handles the display of information, based on the data received from the model.</li><li><strong>Controller</strong>: Acts as an intermediary that handles the input, converting it to commands for the model or view.</li></ul><p>In contrast, <strong>MVT</strong>, as implemented by Django, modifies the traditional MVC architecture slightly:</p><ul><li><strong>Model</strong>: Similar to MVC, it manages the data and business logic.</li><li><strong>View</strong>: In Django, the view functions more like the controller in MVC, handling the business logic and directing traffic between Model and Template.</li><li><strong>Template</strong>: Replaces the view in MVC, responsible solely for rendering the user interface.</li></ul><p>The key difference lies in Django’s handling of the “Controller” functionality, which is incorporated within the “View” component, thus simplifying the architecture and making it distinctively suited to Django’s rapid development philosophy.</p><h3>Conclusion: Merging Django’s Backend Robustness with Vue.js Frontend Dynamics</h3><p>Using the MVT design pattern in Django provides a robust structure for web application development, ensuring clear separation of concerns among the components. Integrating Vue.js as the template component in Django’s MVT architecture allows developers to harness the interactive and dynamic capabilities of Vue.js, making the web applications not only powerful in terms of backend processing but also interactive on the frontend. This blend of technologies ensures that applications are scalable, maintainable, and responsive to user interactions. Whether you are building a simple website or a complex web application. Understanding and implementing the MVT design pattern in Django with Vue.js can significantly enhance both the development process and the end-user experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee8c22fc3170" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Best Practices in Django: Applying SOLID Principles]]></title>
            <link>https://medium.com/@tommyraspati/best-practices-in-django-applying-solid-principles-7139e5b798ef?source=rss-77fa947366f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/7139e5b798ef</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[ppl-fasilkom-ui]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[solid-principles]]></category>
            <dc:creator><![CDATA[TommyRaspati]]></dc:creator>
            <pubDate>Mon, 29 Apr 2024 02:25:18 GMT</pubDate>
            <atom:updated>2024-06-10T08:54:07.063Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*dTr2xCRE6F90K5Hr.png" /></figure><h3>Introduction</h3><p>In modern software development, maintaining clean, scalable, and manageable code is crucial. SOLID principles are a set of design guidelines that aim to make software designs more understandable, flexible, and maintainable. In this post, I’ll explain each of the SOLID principles and show how I’ve applied them in a Django project especially on the “Order” feature to enhance the quality and maintainability of the code.</p><h3>Single Responsibility Principle (SRP)</h3><p><strong>Explanation:</strong> The Single Responsibility Principle states that a class should have one, and only one, reason to change, meaning it should have only one job. This principle helps in reducing the complexity of the class by limiting its responsibilities.</p><pre>class CreateOrder(APIView):    <br>    permission_classes = [IsSales | IsSuperAdmin]<br>    def _handle_products(self, products, is_reduced):<br>        for product in products:<br>            stock = Stock.objects.get(id=product[&#39;product&#39;])<br>            print(stock)<br>            if stock.quantity &lt; int(product[&#39;quantity&#39;]):<br>                raise RuntimeError(f&quot;{stock.name} quantity exceeds the available stock quantity. Available quantity: {stock.quantity}&quot;)<br>        for product in products:<br>            prod_id = product[&#39;product&#39;]<br>            prod_qty = product[&#39;quantity&#39;]<br>            stock = Stock.objects.get(id=prod_id)            <br>            stock.quantity -= int(prod_qty)<br>            stock.save()<br><br>    def post(self, request):<br>        data = request.data<br>        documents = request.FILES<br>        try:<br>.<br>.<br>.<br><br>class GetOrders(APIView):    <br>    permission_classes = [IsSales | IsSuperAdmin]<br><br>    def get(self, _):<br>        orders = Order.objects.all()<br>        serializer = OrderSerializer(orders, many=True)<br>        return JsonResponse(<br>            {<br>                &quot;data&quot;: serializer.data<br>            }<br>        )<br><br>class GetOrderByUniqueCode(APIView):<br>    permission_classes = [AllowAny]<br><br>    def get(self, request, unique_code):<br>        order = Order.objects.filter(unique_code=unique_code)<br>        if not order: <br>.<br>.<br>.<br><br>class UpdateOrderStatus(APIView):<br>    permission_classes = [IsSales | IsSuperAdmin ]<br><br>    def patch(self, request, unique_code):<br>        print(request.data)<br>        order = get_object_or_404(Order, unique_code=unique_code)<br>        new_status = request.data.get(&#39;status&#39;)<br>        new_document = request.FILES<br>.<br>.<br>.<br><br>def generate_unique_code(buyer_email):<br>    length = 4<br>    max_attempts = 1000  # Maximum number of attempts to generate a unique code<br>    attempts = 0<br>    while attempts &lt; max_attempts:<br>        code = &#39;&#39;.join(random.choices(string.ascii_uppercase + string.digits, k=length))<br>        unique_code = f&quot;{buyer_email[:1].upper()}{code}&quot;  # Combining stock name with generated code<br>        if not exists_unique_code(unique_code): return unique_code<br>        attempts += 1<br>    raise ValueError(&quot;Unable to generate a unique code.&quot;)</pre><p><strong>Code Example:</strong></p><ul><li><strong>CreateOrder, GetOrders, GetOrderByUniqueCode, UpdateOrderStatus</strong>: Each class is focused on handling requests for specific actions like creating an order, retrieving orders, getting orders by unique code, and updating order status. This demonstrates a good adherence to SRP.</li><li><strong>generate_unique_code function</strong>: This function generates a unique code and checks its uniqueness by calling another function. Splitting these concerns into separate functions enhances adherence to SRP.</li></ul><h3>Open/Closed Principle (OCP)</h3><p><strong>Explanation:</strong> Entities should be open for extension, but closed for modification. This means you should be able to add new functionality without changing the existing code.</p><p><strong>Code Example:</strong> The OrderStatus class in our models demonstrates the OCP. We can add new statuses to the OrderStatus choices without modifying how the status is used elsewhere in the application. This allows for extending the functionality of our order management system without disrupting existing features.</p><pre>class OrderStatus(models.TextChoices):<br>    &quot;&quot;&quot;<br>    A status model for order.<br>    &quot;&quot;&quot;<br>    PRP = &#39;STOCK_PREPARATION&#39;<br>    CHK = &#39;DOCUMENT_CHECKING&#39;<br>    SHP = &#39;ON_SHIPPING&#39;<br>    ARV = &#39;ARRIVED&#39;<br>    CLD = &#39;CANCELED&#39;<br>    # More statuses can be added here without affecting existing code</pre><h3>Liskov Substitution Principle (LSP)</h3><p><strong>Explanation:</strong> Subtypes must be substitutable for their base types. This principle ensures that a class and its subclasses can be used interchangeably without errors.</p><p><strong>Code Example:</strong> If we had subclasses of Order, such as SpecialOrder, they should be able to replace Order in the system without any disruption in behavior. This principle is more conceptual in the provided snippet but is critical for maintaining behavior consistency across a class hierarchy.</p><pre>class SpecialOrder(Order):<br>    # Should function correctly when used in place of Order<br>    pass</pre><h3>Interface Segregation Principle (ISP)</h3><p><strong>Explanation:</strong> This principle emphasizes creating smaller, more specific interfaces for tasks instead of large, general ones.</p><p><strong>Code Example:</strong> For instance, in a function where you need to generate a unique code in the process of creating an order, it’s more organized and clear to separate the code generation into its own functions like this:</p><pre>def generate_unique_code(buyer_email):<br>    length = 4<br>    max_attempts = 1000  # Maximum number of attempts to generate a unique code<br>    attempts = 0<br>    while attempts &lt; max_attempts:<br>        code = &#39;&#39;.join(random.choices(string.ascii_uppercase + string.digits, k=length))<br>        unique_code = f&quot;{buyer_email[:1].upper()}{code}&quot;  # Combining stock name with generated code<br>        if not is_unique_code_safe(unique_code): return unique_code<br>        attempts += 1<br>    raise ValueError(&quot;Unable to generate a unique code.&quot;)<br><br>def is_unique_code_safe(unique_code):<br>    if not Order.objects.filter(unique_code=unique_code).exists(): # refactor jadi bagian ini dikeluarin for test purposes<br>        return False <br>    else: return True<br><br>class CreateOrder(APIView):<br>    permission_classes = [IsWorker | IsSuperAdmin ]<br>    def post(self, request, *args, **kwargs):<br>        data = request.data  <br>        try:<br>            unique_code = generate_unique_code(str(data.get(&quot;buyer_email&quot;)))<br>            order_creator = request.user</pre><h3>Dependency Inversion Principle (DIP)</h3><p><strong>Explanation:</strong> High-level modules should not depend on low-level modules; both should depend on abstractions. Furthermore, abstractions should not depend on details, but details should depend on abstractions.</p><pre>class OrderItemSerializer(serializers.ModelSerializer):   <br>    class Meta:<br>        model = OrderItem<br>        fields = &#39;__all__&#39;<br><br>class OrderDocumentSerializer(serializers.ModelSerializer):<br>    class Meta:<br>        model = OrderDocument<br>        fields = &#39;__all__&#39;<br><br>class OrderSerializer(serializers.ModelSerializer):<br>    products = OrderItemSerializer(many=True)<br>    documents = OrderDocumentSerializer(many=True, read_only=True)<br>    class Meta:<br>        model = Order<br>        fields = &#39;__all__&#39;<br><br>    def create(self, validated_data):<br>        products_data = validated_data.pop(&#39;products&#39;)<br>        order = Order.objects.create(**validated_data)<br>        products = []<br>        for product_data in products_data:<br>            orderitem = OrderItem.objects.create(**product_data)<br>            stock = orderitem.product<br>            if stock.quantity &lt; product_data.get(&#39;quantity&#39;):<br>                raise serializers.ValidationError({&quot;message&quot;: &quot;Quantity ordered exceeds available stock&quot;})<br>            products.append(orderitem)<br>        order.products.set(products)   <br>        order.save() <br>        return order</pre><p><strong>Code Example:</strong> In the Django application, the OrderSerializer acts as an abstraction layer between the model and the view. It allows the view to interact with data in a high-level manner without being concerned with low-level database operations.</p><h3>Benefits of Applying SOLID Principles</h3><p>Applying SOLID principles in software development, particularly in frameworks like Django, offers significant advantages:</p><h3>1. Enhanced Maintainability</h3><p>SOLID principles encourage the development of software that is easier to understand and maintain. Each component has a clear and defined role, reducing the complexity and making it easier for developers to navigate and manage the codebase. This is especially valuable in long-term projects where changes and updates are frequent.</p><h3>2. Increased Scalability</h3><p>By adhering to these principles, systems are designed to be more flexible and scalable. The Open/Closed Principle, for instance, allows systems to grow and evolve with minimal modifications to existing code. This is crucial for adapting to new requirements or technologies without disrupting the existing system functionality.</p><h3>3. Improved Reusability</h3><p>Components designed with the Single Responsibility Principle in mind are more likely to be reusable in different parts of the application or even in different projects. This can lead to significant reductions in development time and cost as well-designed components can be easily repurposed or adapted.</p><h3>4. Reduced Risk of Bugs</h3><p>The clear separation of concerns and reduced interdependencies help in minimizing the risk of introducing bugs when changes are made. For example, changes in one module are less likely to impact other parts of the system if the modules are loosely coupled and well encapsulated.</p><h3>5. Easier Testing</h3><p>Testing becomes more straightforward when each part of the system has a single responsibility and does not depend on unnecessary external functionalities. Unit testing can be more effectively applied, as each test can focus on a specific behavior of a component without worrying about its dependencies.</p><h3>6. Better Team Collaboration</h3><p>When a system is built following SOLID principles, it becomes easier for teams to collaborate. The system’s architecture is cleaner and more predictable, and new team members can understand and contribute to the project more quickly.</p><h3>7. Facilitates Good Design Patterns</h3><p>SOLID principles lay the foundation for implementing various design patterns effectively. They prepare the system’s design to be robust enough to integrate patterns such as MVC, Decorator, Strategy, and more, which can further enhance the system’s flexibility and maintainability.</p><h3>Conclusion</h3><p>By adhering to SOLID principles, we can ensure that our Django application remains robust, extendable, and easy to maintain. These principles guide the design of our classes and their interactions, leading to a more organized and efficient codebase. As demonstrated, integrating SOLID principles in Django not only improves the structure but also enhances the overall development workflo</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7139e5b798ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Test-Driven Development in Django: Enhancing Software Quality and Maintainability]]></title>
            <link>https://medium.com/@tommyraspati/mastering-test-driven-development-in-django-enhancing-software-quality-and-maintainability-7c265c5eeae4?source=rss-77fa947366f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c265c5eeae4</guid>
            <category><![CDATA[tdd]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[code-coverage]]></category>
            <category><![CDATA[ppl-fasilkom-ui]]></category>
            <dc:creator><![CDATA[TommyRaspati]]></dc:creator>
            <pubDate>Tue, 23 Apr 2024 16:29:10 GMT</pubDate>
            <atom:updated>2024-04-23T16:29:10.398Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*DvBUlzGP0P9D6jsVq0e2lw.jpeg" /></figure><h3>What is Test-Driven Development (TDD)?</h3><p>Test-Driven Development (TDD) is not just a development technique; it’s a philosophy that revolutionizes the way software is built. At its core, TDD involves writing tests for your functions before even writing the code that makes them work. This might seem counterintuitive, but it’s a powerful way to ensure that your software is reliable from the very start. The process follows a simple, repetitive cycle known as “Red-Green-Refactor”:</p><ol><li><strong>Red</strong>: Write a test that defines a desired improvement or new function, which initially fails because the feature doesn’t yet exist.</li><li><strong>Green</strong>: Write the simplest code that can make the test pass.</li><li><strong>Refactor</strong>(if needed): Optimize the new code, making sure it conforms to good design principles, without affecting its behavior.</li></ol><p>This methodology shifts the focus from merely adding features to ensuring a robust and error-free implementation. Let’s delve deeper into the benefits that make TDD a game-changer in the world of software development.</p><h3>TDD Implementation on My Project</h3><p>In this section, I will explain how I implemented TDD in my recent project for the “update order status” feature.</p><ol><li>Red Phase: Write Failing Tests on tests.py (Positive and Negative Case)</li></ol><pre>class UpdateOrderStatusTestCase(TestCase):<br>    def setUp(self):<br>        # Create a test superuser<br>        self.client = APIClient()<br>        self.superuser = KridaUser.objects.create_superuser(email=&#39;admin@example.com&#39;, username=&#39;admin@example.com&#39;, password=&#39;admin_password&#39;)<br><br>        # Generate authentication token<br>        self.token = RefreshToken.for_user(self.superuser).access_token<br>        self.client.credentials(HTTP_AUTHORIZATION=f&#39;Bearer {self.token}&#39;)<br><br>        # Create Stock items with a date<br>        self.stock1 = Stock.objects.create(<br>            name=&quot;Test Stock 1&quot;,<br>            quantity=100,<br>            quality=&quot;Good&quot;,<br>            description=&quot;Test Description&quot;,<br>            stock_status=&quot;SELL&quot;,<br>            date=datetime.now().date()<br>        )<br>        self.stock2 = Stock.objects.create(<br>            name=&quot;Test Stock 2&quot;,<br>            quantity=200,<br>            quality=&quot;Good&quot;,<br>            description=&quot;Test Description&quot;,<br>            stock_status=&quot;SELL&quot;,<br>            date=datetime.now().date()<br>        )<br><br>        # Create OrderItem instances<br>        self.order_item1 = OrderItem.objects.create(product=self.stock1, quantity=1, subtotal=10)<br>        self.order_item2 = OrderItem.objects.create(product=self.stock2, quantity=1, subtotal=20)<br><br>        # Create Order instance<br>        self.order = Order.objects.create(<br>            unique_code=&#39;J1234&#39;,<br>            order_creator=self.superuser,<br>            buyer_email=&#39;buyer@mail.com&#39;,<br>            status=&quot;STOCK_PREPARATION&quot;,<br>            total_price=30,<br>            last_updated=timezone.now(),<br>        )<br>        # Add OrderItem instances to the Order<br>        self.order.products.add(self.order_item1, self.order_item2)<br>        self.order.save()<br><br>    def test_update_order_status_positive(self):<br>        update_data = {<br>            &quot;status&quot;: &quot;ON_SHIPPING&quot;,<br>        }<br><br>        response = self.client.patch(f&quot;/order/update/{self.order.unique_code}/&quot;, data=json.dumps(update_data), content_type=&quot;application/json&quot;)<br><br>        self.assertEqual(response.status_code, status.HTTP_200_OK)<br>        self.order.refresh_from_db()<br>        self.assertEqual(self.order.status, &quot;ON_SHIPPING&quot;)<br><br>    def test_update_order_status_unauthorized(self):<br>        # Clear the authentication credentials<br>        self.client.credentials()<br><br>        update_data = {&quot;status&quot;: &quot;ON_SHIPPING&quot;}<br>        response = self.client.patch(f&quot;/order/update/{self.order.unique_code}/&quot;, data=json.dumps(update_data), content_type=&quot;application/json&quot;)<br>        self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)<br><br>    def test_update_order_status_invalid(self):<br>        update_data = {&quot;status&quot;: &quot;INVALID_STATUS&quot;}<br>        response = self.client.patch(f&quot;/order/update/{self.order.unique_code}/&quot;, data=json.dumps(update_data), content_type=&quot;application/json&quot;)<br>        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)<br><br>    def test_update_order_status_non_existent_order(self):<br>        update_data = {&quot;status&quot;: &quot;ON_SHIPPING&quot;}<br>        response = self.client.patch(&quot;/order/update/non_existent_code/&quot;, data=json.dumps(update_data), content_type=&quot;application/json&quot;)<br>        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)<br><br>    def test_update_order_status_no_status_provided(self):<br>        update_data = {}  # No status provided<br>        response = self.client.patch(f&quot;/order/update/{self.order.unique_code}/&quot;, data=json.dumps(update_data), content_type=&quot;application/json&quot;)<br>        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)</pre><p>After writing the tests, you can run them by executing this command in your project directory; in this case, I run my tests that are only in the order application/folder:</p><pre>python manage.py test order</pre><p>Initially, some tests will fail because we have not yet implemented the URLs and the view logic for these tests.</p><h4>Command Output:</h4><pre>======================================================================<br>FAIL: test_update_order_status_invalid (order.tests.UpdateOrderStatusTestCase.test_update_order_status_invalid)<br>----------------------------------------------------------------------<br>Traceback (most recent call last):<br>  File &quot;/Users/macos/Documents/sem6fasilkom/PPL/ppl-a5-project/order/tests.py&quot;, line 217, in test_update_order_status_invalid<br>    self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)<br>AssertionError: 404 != 400<br><br>======================================================================<br>FAIL: test_update_order_status_no_status_provided (order.tests.UpdateOrderStatusTestCase.test_update_order_status_no_status_provided)<br>----------------------------------------------------------------------<br>Traceback (most recent call last):<br>  File &quot;/Users/macos/Documents/sem6fasilkom/PPL/ppl-a5-project/order/tests.py&quot;, line 227, in test_update_order_status_no_status_provided<br>    self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)<br>AssertionError: 404 != 400<br><br>======================================================================<br>FAIL: test_update_order_status_positive (order.tests.UpdateOrderStatusTestCase.test_update_order_status_positive)<br>----------------------------------------------------------------------<br>Traceback (most recent call last):<br>  File &quot;/Users/macos/Documents/sem6fasilkom/PPL/ppl-a5-project/order/tests.py&quot;, line 202, in test_update_order_status_positive<br>    self.assertEqual(response.status_code, status.HTTP_200_OK)<br>AssertionError: 404 != 200<br><br>======================================================================<br>FAIL: test_update_order_status_unauthorized (order.tests.UpdateOrderStatusTestCase.test_update_order_status_unauthorized)<br>----------------------------------------------------------------------<br>Traceback (most recent call last):<br>  File &quot;/Users/macos/Documents/sem6fasilkom/PPL/ppl-a5-project/order/tests.py&quot;, line 212, in test_update_order_status_unauthorized<br>    self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)<br>AssertionError: 404 != 401<br><br>----------------------------------------------------------------------<br>Ran 16 tests in 19.838s<br><br>FAILED (failures=4)<br>Destroying test database for alias &#39;default&#39;...<br></pre><p>2. Green Phase : Implement Routing and Update Order Status Function</p><ul><li>Create update order status function in views.py</li></ul><pre>class UpdateOrderStatus(APIView):<br>    permission_classes = [IsWorker, IsAdmin, IsSales]<br><br>    def patch(self, request, unique_code):<br>        order = get_object_or_404(Order, unique_code=unique_code)<br>        order_status = request.data.get(&#39;status&#39;)<br>        if order_status and order_status in OrderStatus.values:  # Check if the status is valid<br>            order.status = order_status<br>            order.save()<br>            serializer = OrderSerializer(order)<br>            return JsonResponse({&quot;data&quot;: serializer.data}, status=status.HTTP_200_OK)<br>        return JsonResponse({&#39;detail&#39;: &quot;Invalid status&quot;}, status=status.HTTP_400_BAD_REQUEST)</pre><ul><li>Add routing for update order status in urls.py</li></ul><pre>urlpatterns = [<br>    ...<br>    path(&#39;update/&lt;str:unique_code&gt;/&#39;, UpdateOrderStatus.as_view(), name=&#39;update_order_status&#39;),<br>    ...<br>]</pre><p>Now run the test again using this command</p><pre>python manage.py test order</pre><p>The tests should all pass now, demonstrating that the code has been successfully implemented according to the specifications.</p><h4>Command Output:</h4><pre>----------------------------------------------------------------------<br>Ran 16 tests in 18.386s<br><br>OK<br>Destroying test database for alias &#39;default&#39;...</pre><h3>Visualizing TDD Through Commit History</h3><p>To provide a clear view of how Test-Driven Development (TDD) is implemented in practice, I’ve included a series of screenshots from my commit history. Each commit corresponds to a specific stage in the TDD process for developing a feature.</p><h4>Understanding the Commit History</h4><p>Here’s what you’ll see in the commit history screenshots:</p><ul><li><strong>Red Phase Commits</strong>: These commits contain the initial tests for new features, which are expected to fail. The commit messages typically start with “Add failing test for [feature]”. This marks the beginning of a TDD cycle and sets the stage for development.</li><li><strong>Green Phase Commits</strong>: Following the Red commits, the next set are Green commits where the failing tests are made to pass by adding new functionality. Commit messages for these are usually formatted as “Implement [feature] to pass tests”. These commits demonstrate the successful coding of a feature to meet the specified test conditions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*AuStN1RCnu30GzP8B71IqA.png" /><figcaption>Commit history of TDD Implementations</figcaption></figure><h3><strong>Code Coverage Tools in Django</strong></h3><p>To support Test-Driven Development (TDD) and ensure high code coverage, it is essential to measure how much of your code is executed during automated tests. This is where code coverage tools come into play. In Django, one of the most popular tools for this purpose is coverage.</p><p><strong>Using Coverage in Django</strong></p><ol><li><strong>Specific Coverage</strong>: If you want to focus on testing a specific application within your Django project, you can use the --source option to narrow down the coverage analysis to that application. For example, to measure coverage exclusively in the &quot;order&quot; app, you would run:</li></ol><pre>coverage run --source=&#39;order&#39; manage.py test order</pre><p>This command tells the coverage tool to track only the files within the ‘order’ directory while executing tests specifically for the ‘order’ app.</p><p><strong>2. General Coverage</strong>: If you’re interested in assessing the coverage across your entire Django project, you don’t need to specify a source. Instead, simply run:</p><pre>coverage run manage.py test</pre><p>This command will collect coverage data for all executed code during the test run across all applications in your project.</p><p><strong>Generating the Coverage Report</strong></p><p>After running your tests with the coverage tool, you’ll want to generate a report to see the results. You can do this with:</p><pre>coverage report -m</pre><p>The -m option includes missing lines in the report, which is helpful for identifying exactly which lines of code were not executed during testing, thus guiding you where more tests may be needed.</p><h4>Example of the code coverage we just make:</h4><pre>(env) macos@Macs-MacBook-Pro-3 ppl-a5-project % coverage run --source=&#39;order&#39; manage.py test order<br><br>Found 16 test(s).<br>Creating test database for alias &#39;default&#39;...<br>System check identified no issues (0 silenced).<br>.<br>.<br>.<br>----------------------------------------------------------------------<br>Ran 16 tests in 17.988s<br><br>OK<br>Destroying test database for alias &#39;default&#39;...</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*gva2HPvAcAIfLEGNCYy2hg.png" /><figcaption>Code Coverage Report</figcaption></figure><p>As we can see the function we created is already covered by the tests, we can see that line 89–98 is not in the missing section which mean it’s already covered by the tests.</p><p>These coverage commands are an integral part of maintaining high standards in your software development process, particularly when following TDD principles. They provide valuable insights that help ensure your application is not only functioning as intended but also robustly tested.</p><h3>Benefits of Test-Driven Development</h3><h4>Improved Code Quality</h4><p>TDD encourages the creation of clearer, simpler code. By focusing on requirements before writing the code, you naturally avoid over-engineering. Tests cover every aspect of functionality, which tends to reduce bugs in production. This practice leads to a more maintainable and extensible codebase, as each component is built on a solid foundation of tests.</p><h4>Enhanced Documentation</h4><p>Tests written in TDD serve as living documentation for your project. Each test case clearly states the purpose and expected behavior of the code, which helps new developers understand the project quickly without sifting through traditional documentation.</p><h4>Facilitates Refactoring and Updates</h4><p>Since TDD ensures that each piece of your code is tested, developers can refactor and optimize the codebase with confidence. Changes are less risky because tests will immediately reveal any disruption caused by modifications.</p><h4>Faster, More Efficient Debugging</h4><p>When tests fail, they pinpoint exactly where things go wrong, which drastically cuts down on debugging time. This allows developers to fix issues much faster compared to traditional debugging methods that involve combing through potentially thousands of lines of code.</p><h4>Continuous Feedback</h4><p>TDD provides a continuous feedback loop during the development process. By immediately checking if the new code complies with the existing system and requirements, developers can adjust their approach quickly and efficiently.</p><h4>Better Designed, Cleaner Code</h4><p>TDD encourages developers to think through their design before coding, leading to better designed systems. It promotes smaller, more focused classes and methods, which typically result in cleaner, less complex implementations.</p><p>Implementing TDD requires discipline and commitment but the benefits, as demonstrated, are worth the effort. This methodology not only improves the quality of the software produced but also enhances the overall workflow within development teams. Whether you’re a seasoned developer or a newcomer, integrating TDD into your development practices can lead to producing higher quality software and achieving greater project success.</p><p><strong>Hope you all enjoy this article :D</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c265c5eeae4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ensuring Software Quality Assurance with SonarCloud: A Comprehensive Guide for GitLab Integration]]></title>
            <link>https://medium.com/@tommyraspati/ensuring-software-quality-assurance-with-sonarcloud-a-comprehensive-guide-for-gitlab-integration-1c168cb6fc9b?source=rss-77fa947366f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c168cb6fc9b</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[sonarcloud]]></category>
            <category><![CDATA[quality-assurance]]></category>
            <category><![CDATA[code-quality]]></category>
            <category><![CDATA[gitlab-ci]]></category>
            <dc:creator><![CDATA[TommyRaspati]]></dc:creator>
            <pubDate>Tue, 05 Mar 2024 15:10:23 GMT</pubDate>
            <atom:updated>2024-06-10T11:52:56.021Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*TWcvUkeHRpgigxbw7Mmm3g.png" /></figure><h3>Introduction</h3><p>In the ever-evolving landscape of software development, ensuring the quality and reliability of your code is essential. Software Quality Assurance (SQA) is a critical aspect of the development process, aimed at ensuring that the software meets the desired standards and requirements. This article will explore the importance of SQA and how tools like SonarCloud can be leveraged to maintain and improve code quality.</p><h3>Connecting a GitLab Repository to SonarCloud</h3><h3>Step 1: Setting Up SonarCloud</h3><p>There are several options for creating a project on SonarCloud. You can import it from your GitHub/GitLab repository, but you need to be the owner of the group or the repository. For this tutorial, we’ll create the project manually for greater flexibility.</p><ol><li>Create a SonarCloud account and set up a new project.</li><li>Go to “My Projects” in SonarCloud.</li><li>Click “Analyze new project.”</li><li>Click “Create a project manually.”</li><li>Create an organization if you haven’t already, or choose an existing one.</li><li>Fill in the display name of the project, and you can modify the project key if you wish. Select the project’s visibility.</li><li>Choose how you want to define new code, based on “Previous Version” or “Number of days.” You can find more details about the new code definition <a href="https://docs.sonarsource.com/sonarcloud/improving/new-code-definition/">here</a>.</li></ol><h3>Step 2: Configuring GitLab CI/CD</h3><ol><li>In your GitLab project, go to Settings -&gt; CI/CD -&gt; Variables, then click “Expand.”</li><li>Create a new variable by clicking “Add variable.” The first one should be named SONAR_LOGIN (the name is optional) for the key.</li><li>To obtain the value for this variable, go to your SonarCloud project that you already created. Click on one of the analysis methods, then choose the option you need. Copy the “Value of the environment variable” and paste it into the variable value in GitLab.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*k8-0M0dxkP3t_NzlBxsEow.png" /></figure><p>4. The second and third variables are called SONAR_ORGANIZATION and SONAR_PROJECT_KEY. To obtain the values of these two variables, we need to go to the SonarCloud project, then go to “Information,” and copy the project key to your SONAR_PROJECT_KEY value and the Organization key to your SONAR_ORGANIZATION value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f_sXe72xe07wHonxH29MFQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*rXrr_aV2vc1nU0Xpw7DkVQ.png" /><figcaption>Example of the variables that have been created</figcaption></figure><p>5. Create a file in your root repository directory called .gitlab-ci.yml. And this is the simple example for SonarCloud CI.</p><pre>stages:<br>  - sonarcloud-check<br>Sonarcloud-check:<br>  stage: sonarcloud-check<br>  image: <br>    name: sonarsource/sonar-scanner-cli:latest<br>    entrypoint: [&quot;&quot;]<br>  cache:<br>    key: &quot;${CI_JOB_NAME}&quot;<br>    paths:<br>      - .sonar/cache<br>  script: <br>    - sonar-scanner -Dsonar.projectKey=$SONAR_PROJECT_KEY -Dsonar.login=$SONAR_LOGIN -Dsonar.organization=$SONAR_ORGANIZATION -Dsonar.sources=. -Dsonar.host.url=https://sonarcloud.io/<br>  allow_failure: true</pre><p>6. Commit and push the changes to trigger the CI/CD pipeline.</p><h3>Step 3: Analyzing the Results</h3><ul><li>Access the SonarCloud dashboard to view the analysis results.</li><li>Identify and address any code quality issues or vulnerabilities.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VPkzxP24uD4TaBhK_XGbTQ.png" /><figcaption>Example summary of code quality</figcaption></figure><h3>Features of SonarCloud for Maintaining Code Quality</h3><ul><li><strong>Code Quality Metrics:</strong> SonarCloud provides a comprehensive set of metrics, including code smells, bugs, and vulnerabilities, to assess the quality of your code.</li><li><strong>Pull Request Analysis:</strong> Automatically analyze pull requests to detect and prevent the introduction of new issues.</li><li><strong>Security Analysis:</strong> Identify and fix security vulnerabilities in your codebase.</li><li><strong>Code Coverage:</strong> Track the percentage of your code covered by tests to ensure adequate testing.</li><li><strong>Custom Rules:</strong> Define custom rules to enforce specific coding standards or practices.</li></ul><h3>Advantages and Disadvantages of Using SonarCloud</h3><h3>Advantages</h3><ul><li><strong>Improved Code Quality:</strong> Regular analysis helps maintain high standards of code quality.</li><li><strong>Early Detection of Issues:</strong> Identify and address issues early in the development process.</li><li><strong>Security:</strong> Enhanced security through the detection of vulnerabilities.</li><li><strong>Integration:</strong> Easy integration with GitLab and other CI/CD tools.</li></ul><h3>Disadvantages</h3><ul><li><strong>Learning Curve:</strong> Some initial effort is required to set up and configure the tool.</li><li><strong>False Positives:</strong> Occasionally, the tool may flag false positives that need to be manually reviewed.</li><li><strong>Cost:</strong> While there is a free tier, larger projects may require a paid subscription.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c168cb6fc9b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enhancing Team Collaboration: Embracing Tools and Techniques for Better Efficiency]]></title>
            <link>https://medium.com/@tommyraspati/enhancing-team-collaboration-embracing-tools-and-techniques-for-better-efficiency-316cc7756e45?source=rss-77fa947366f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/316cc7756e45</guid>
            <category><![CDATA[commit]]></category>
            <category><![CDATA[teamwork]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[merge-request]]></category>
            <category><![CDATA[scrum-board]]></category>
            <dc:creator><![CDATA[TommyRaspati]]></dc:creator>
            <pubDate>Sun, 25 Feb 2024 14:55:53 GMT</pubDate>
            <atom:updated>2024-02-27T13:45:53.426Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/681/0*Uf2ml3xTrqyF1J81.png" /></figure><p>In the dynamic environment of today’s workplaces, teamwork stands as the backbone of successful projects and outcomes. The essence of working in a team lies not only in the collective effort but also in the meticulous use of tools and mechanisms that enhance efficiency, communication, and collaboration. This post aims to demystify how basic teamwork tools and methodologies can significantly improve team dynamics and project outcomes, focusing on merge requests, scrum boards, and effective commit messages.</p><h3><strong>Understanding the Tools of Teamwork</strong></h3><h4><strong>Merge Requests</strong></h4><p>At its core, a merge request is a method used in version control systems to integrate changes from one branch of a repository into another. It’s akin to proposing a collaboration, where team members can review, discuss, and ultimately incorporate changes into the main project. This tool fosters a culture of peer review and collective code ownership, ensuring quality and consistency. By utilizing merge requests, teams can avoid conflicts and ensure that every piece of code is scrutinized and optimized for the project’s benefit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MMYlS3Kp90p7nEcuFziUaA.png" /><figcaption>An example of my team merge request list</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ZjF9TIaWW_lUDppyi149A.png" /><figcaption>An example of my merge request on a project</figcaption></figure><h4><strong>Scrum Boards</strong></h4><p>Originating from the Agile methodology, scrum boards are visual tools that help teams track progress on various tasks and projects. A typical scrum board is divided into columns such as ‘To Do,’ ‘In Progress,’ and ‘Done,’ allowing team members to move tasks across these columns as they advance. This visual representation not only clarifies the current status of tasks but also promotes accountability and motivates team members by showing real-time progress. Scrum boards can be digital or physical, making them versatile tools for any team setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c9f1LWGlbiqnR4YfthH1Fg.png" /><figcaption>An example of a scrum board I created to track the progress of my team project</figcaption></figure><h4><strong>Commit Messages</strong></h4><p>In software development, every change made to the codebase is usually committed to a version control system with a message explaining the change. Effective commit messages are clear, concise, and informative, making it easier for team members to understand the history of changes and the reason behind each commit. This practice aids in troubleshooting and reviewing code, ensuring that team members can efficiently collaborate and build on each other’s work without confusion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NeBeZEQNikv1HcAKGLLv-g.png" /><figcaption>An example of a commit with a clear commit message</figcaption></figure><h3><strong>Leveraging Tools for Improved Teamwork</strong></h3><p>The integration of these tools into daily operations can dramatically improve a team’s ability to work cohesively towards common goals. Here’s how:</p><ul><li><strong>Foster Transparency</strong>: Tools like scrum boards and merge requests create an environment of openness, where every team member is aware of the work being done, who is doing it, and the current status. This transparency eliminates uncertainties and fosters a culture of trust.</li><li><strong>Enhance Communication</strong>: Effective commit messages and the discussion threads in merge requests provide platforms for clear and structured communication. Team members can offer feedback, suggest improvements, and clarify doubts without the need for constant meetings or emails.</li><li><strong>Boost Productivity</strong>: By streamlining the process of reviewing code (through merge requests) and tracking progress (via scrum boards), teams can minimize downtime and focus on accomplishing tasks efficiently.</li><li><strong>Promote Quality</strong>: Peer reviews in merge requests ensure that every line of code is vetted for quality before it becomes part of the main project. This collective responsibility towards quality can significantly reduce errors and enhance the overall standard of the project.</li></ul><p>Understanding and utilizing basic tools like merge requests, scrum boards, and commit messages can transform the way teams collaborate, communicate, and achieve objectives. These tools not only support but also enhance teamwork by making the processes more transparent, efficient, and quality-driven. Whether you’re a seasoned professional or new to team collaboration, embracing these tools can lead to more productive, cohesive, and successful team efforts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=316cc7756e45" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>