<?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 David Christianto on Medium]]></title>
        <description><![CDATA[Stories by David Christianto on Medium]]></description>
        <link>https://medium.com/@david.christianto05?source=rss-df4cd0818f03------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*pxz_RS2XXQP8KiZp</url>
            <title>Stories by David Christianto on Medium</title>
            <link>https://medium.com/@david.christianto05?source=rss-df4cd0818f03------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 18:04:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@david.christianto05/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[Team Development Tools]]></title>
            <link>https://medium.com/@david.christianto05/team-development-tools-343993b11c55?source=rss-df4cd0818f03------2</link>
            <guid isPermaLink="false">https://medium.com/p/343993b11c55</guid>
            <dc:creator><![CDATA[David Christianto]]></dc:creator>
            <pubDate>Mon, 27 Nov 2023 06:08:21 GMT</pubDate>
            <atom:updated>2023-11-27T06:08:21.880Z</atom:updated>
            <content:encoded><![CDATA[<h3>Version Control System (VCS)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZwmYT7oexAejmOShapumWQ.png" /><figcaption>Image source: <a href="https://www.documentlocator.com/resources/knowledge/what-is-version-control.htm">https://www.documentlocator.com/resources/knowledge/what-is-version-control.htm</a></figcaption></figure><p>Version control is a system used to track changes in source code or a collection of files over time. This VCS is commonly used by developers to check files on the server, make changes, and check the files again. The advantages of using VCS itself are quality (the team can review the code), acceleration (can branch and merge), and visibility. There are several types of VCS, namely</p><ul><li>A distributed version control system (DVCS) that allows users to access the repository from various locations.</li><li>A centralized version control system (CVCS) is a type of VCS where all users work with the same central repository. This central repository can be located on a server or on the developer’s local machine.</li><li>Lock-based: Lock-based version control systems use file locking to manage concurrent access to files and resources. File locking prevents two or more users from making conflicting changes to the same file or resource.</li><li>Optimistic: In an optimistic version control system, each user has their own private workspace. When they want to share their changes with other team members, they send a request to the server. The server then looks at all the changes and determines which changes can be safely merged.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mOIk-CCSHqz3U6UV.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v9Kbz6tVAISaRl7W.png" /></figure><p>What I do regarding this version control is use git commit, which will later be seen by other members regarding the commit history that I have done. Besides that, I also use the git log command to check my version control on my branch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*WtLD7pd9GR2EU_tq.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*roSgZVt7rz939ONr.jpeg" /></figure><h3>GIT</h3><p>Git is a version control system that allows developers to manage changes in their software source code. It enables collaboration in software development, tracking changes, and coordinating work between multiple developers.</p><p>Within Git, there are various categories of commands that can be used to perform various tasks. I divide them into three levels</p><p>1. Low-Level (Basic) Category:<br>- Committing: Validating changes and creating a permanent record of those changes in the project history.<br>Example: git commit, git commit -m “commit message”.<br>- Staging: Adding changes to the staging area before committing.<br>Example: git add, git add -A.<br>- Remote Repository Interaction: Interacts with a repository on a remote server.<br>Examples: git push, git pull, git fetch.<br>- Status and Log: Display the status of uncommitted changes and view the log of commits that have been made.<br>Examples: git status, git log, git diff.</p><p>2. Additional Categories (Optional):<br>- Tagging: Labeling certain commits to mark important points in the project’s history.<br>Examples: git tag, git tag -a v1.0 -m “Version 1.0”.<br>- Rebasing: Moving a branch to be based on another branch to avoid conflicts during a merge.<br>Examples: git rebase, git rebase master.</p><p>3. High-Level (More Complex) Category:<br>- Branching and Merging: Includes commands for creating, deleting, and managing branches and merging changes between branches.<br>Examples: git branch, git merge, git checkout.<br>- Stashing: Hiding changes temporarily to work on something else, then restoring them later.<br>Examples: git stash, git stash pop, git stash apply.</p><p>These commands form the foundation of Git and allow developers to perform most of the tasks required in project source code management. Learning these commands helps in effectively using Git to manage software development projects.</p><h3>Advantages and benefits of implementing git commands</h3><p>Performing Git commands has some significant advantages and benefits for software developers and development teams in general:</p><p>1. Efficient Version Control: Git allows developers to track every change in the source code. This makes it possible to go back to previous versions, compare changes, and understand the evolution of the code.</p><p>2. Better Collaboration: With Git, multiple developers can work on the same project without interfering with each other’s changes. They can work in different branches and merge changes when needed.</p><p>3. Easy Conflict Resolution: Git helps in handling conflicts while merging changes from multiple sources. It allows developers to decide how to merge conflicting changes.</p><p>4. Clear Change Monitoring: Through commit messages and logs, Git makes it possible to clearly see who made the changes, what was changed, and the reason behind each change.</p><p>5. Structured Project Management: With good branching and structuring, Git helps manage complex development workflows in a more structured and organized manner.</p><p>6. Code Testing and Review: Git facilitates code testing and review by allowing users to create a new branch for each feature or improvement, which can then be tested separately before being merged into the main code.</p><p>7. Code Recovery and Protection: With Git, if any problems or errors occur, you can revert back to a previous working version without losing change history.</p><h3>What have I done with advanced git commands?</h3><p>I also do git stash to temporarily store (hide) the changes in my uncommitted working directory when trying to make test coverage 100% on local, and git stash apply to take the changes stored in the stash and apply them back to the directory without deleting the stash.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*4DMm07zoxDnGgwMy.png" /></figure><p>Besides that, I also did a git reset — — hard (commit id in history) to restore and run my existing commit. I did this because there was a change in my group’s test database because one of my friends migrated to a different model. and the result is that my branch pipeline can return to green (success).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=343993b11c55" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[People Person]]></title>
            <link>https://medium.com/@david.christianto05/people-person-913c80cf6d6e?source=rss-df4cd0818f03------2</link>
            <guid isPermaLink="false">https://medium.com/p/913c80cf6d6e</guid>
            <dc:creator><![CDATA[David Christianto]]></dc:creator>
            <pubDate>Wed, 22 Nov 2023 05:59:50 GMT</pubDate>
            <atom:updated>2023-11-22T05:59:50.713Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lW_wIU8Z_GuaIn_5plyL-w.jpeg" /><figcaption>Image source: <a href="https://content.mycareersfuture.gov.sg/are-you-a-people-person-take-this-quiz-to-find-out-which-sector-suits-you-best/">https://content.mycareersfuture.gov.sg/are-you-a-people-person-take-this-quiz-to-find-out-which-sector-suits-you-best/</a></figcaption></figure><h3>Introduction</h3><blockquote>The ability to relate to others is at the core of human social life. Among us, there are individuals who naturally excel in this ability, known as “people people.” However, have you ever heard of the term people person? Some may wonder what it means. There is no standard definition, but some people think that a person refers to someone who is friendly to others. According to the Cambridge Dictionary, a people person is a term for someone who is friendly and enjoys meeting and interacting with others. So, according to my understanding and some of the sources I read related to people-person, I define people-person as a trait and characteristic of a person that refers to the ability to interact, relate, and cooperate with others well in a group, as well as having a friendly attitude and also having good self-control. People-person is also a concept that includes exceptional interpersonal skills, the ability to read and respond to other people’s emotions, and the ability to build deep and meaningful relationships.</blockquote><blockquote>A people person is someone who is good at socializing and communicating with others and can show empathy. People-person abilities will be very useful if used in inter- and intra-group cooperation because the person can build strong relationships between members, create strong potential for collaboration and mutual need, and create a comfortable and positive environment to perform a task. This will indirectly affect the quality of group work, because if someone feels comfortable in an environment, that person will be able to bring out their best potential and be able to develop themselves.</blockquote><h3>Characteristics of a People-Person</h3><p>A “people person” is someone who is able to create closeness and build strong relationships with various types of people. People-person’s communication skills are above average, not only in delivering messages clearly but also in active listening. They not only hear words but also read non-verbal cues, showing genuine interest in what others are saying.</p><p>Empathy is key to the character of a “people person”. They are highly sensitive to the feelings and needs of others, able to see issues through the eyes of others, and respond with understanding. With this ability, they become a source of support and courage for many people around them.</p><p>In addition to being an active listener and having a sense of empathy, a people person must also be able to demonstrate a humble attitude. Generally, people dislike someone who is constantly self-indulgent and selfish, which can lead to divisions within the group. Therefore, a people person must be able to prioritize the interests of the group over personal interests. Humility is recognizing the value of others and being interested in them. A humble attitude will also lead a person to a more open and humble mindset so that they are able and willing to listen to criticism and suggestions from others.</p><p>In addition, adaptability is one of the pillars of a “people person” trait. They are comfortable in various social situations, adjusting their communication style and behavior according to their environment. This flexibility allows them to establish close relationships with people from various walks of life, connecting people from different backgrounds and views. And perhaps the last characteristic of a people person is being able to remember important things. Since people-person are good listeners and tend to listen more than talk, a people-person should also be able to remember important things told by others in detail.</p><h3>Characteristics to avoid if you want to be a people person</h3><p>Being a “people person” is not just about having good communication and coordination skills. It involves attitudes and behaviors that support positive relationships with others. One of the things to avoid are attitudes that can hinder healthy interactions and affect relationships with others. Egoism is one of the things that needs to be avoided. When a person is too focused on their own interests without regard for the feelings or needs of others, it can hinder their ability to connect deeply with others. Empathy is also an important factor; a lack of empathy can make others feel ignored or unappreciated in interactions.</p><p>Other attitudes that can lead to not being a people person include not listening or focusing on one’s own talk, which can make others feel unappreciated. This can have an impact on making wrong decisions because they feel they are the most righteous, making a person’s perspective narrow and becoming insensitive to problems in the surrounding environment. In addition, being overly judgmental can also hinder positive relationships, as it can make others feel uncomfortable or underappreciated. Another attitude that causes a person to fail at being a people person is dishonesty or inconsistency, which can undermine trust and prevent healthy relationships from forming. Being rude, insensitive, or lacking sensitivity to emotional needs can also negatively affect relationships.</p><p>By avoiding these attitudes, one can strengthen the ability to be a “people person” and build healthier and deeper relationships with others. These are all important steps in forming honest, respectful, and supportive connections between individuals.</p><h3>Why Are People Person Skills Important?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*d1Uazqdw6oMqZzYXZGvPJA.jpeg" /><figcaption>Image source: <a href="https://stock.adobe.com/id/search/images?k=important+notice">https://stock.adobe.com/id/search/images?k=important+notice</a></figcaption></figure><p>The presence of a “people person” is invaluable in many aspects of life. In a group, they actively serve as the glue of the team, facilitate effective collaboration, and help reduce interpersonal conflict. In a social setting, they create strong bonds, support individuals in difficult moments, and bring a positive spirit into daily conversations and interactions. The abilities of a “people person” also play a big role in the development of good leadership, where they are able to understand and inspire others, build an inclusive environment, and lead by example in terms of forming healthy relationships.</p><h3>What do I do about People-Person?</h3><ul><li>Read a book by Stephen R. Covey entitled The 7 Habits of Highly Effective People.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*hSf4aZizn-L9YkfDYXAolg.png" /></figure><p>This book discusses the ability to interact with and relate to others, which is a vital aspect of personal and professional success. In his writing, Stephen R. Covey reveals seven important habits in the aspect of communication that not only change the outlook on life but also shape the character of an effective person in social interaction.</p><ol><li>First, being proactive is the first cornerstone for a person who is expected to be a “people person.” Choosing a conscious and considered response to any situation is the key to social interaction, which is significantly different from a knee-jerk reaction without considering its impact. Covey carries this concept through the image of the circle of care and influence, showing that focusing on what we can control is more productive than worrying about things that are out of our control.</li><li>Secondly, the concept of “Starting from the End” highlights the importance of having a clear view of our goals. By drawing a strong vision in our minds, we can face obstacles and decisions with unwavering confidence.</li><li>Next, “Put First Things First” and time management are at the core of the third habit. The ability to distinguish between what is important and what is not will only help us to focus on the essential, avoiding the clutter of daily activities.</li><li>“Win-Win Thinking” is the next pillar, emphasizing the importance of finding solutions that benefit all parties. This reflects the importance of harmonious relationships in the long run, where building mutual victories is the main focus.</li><li>The ability to “Understand Others Before Being Understood” is a cornerstone in building strong relationships. Covey highlights the importance of empathy and listening skills as the key to understanding and respecting each other.</li><li>Synergy and effective cooperation are the next principles, emphasizing the importance of collaboration in achieving common goals. In this case, good cooperation results in better and more efficient performance.</li><li>Finally, “Sharpening the Saw” emphasizes the importance of continuous personal growth, whether in physical, mental, social, or spiritual aspects. Covey asserts that through these aspects, one can become a more effective person in daily life.</li></ol><ul><li>Being a Product Owner who coordinates communication between the development team and stakeholders (Miss Aruni)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*f2znIYtzP-8I4vqpOcNc1Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*bqN3afeKnEIjwsRyG42NSA.png" /></figure><p>In this sprint 4, I was chosen to be the product owner of group 1. And so far, I have implemented the people person in sprint planning, where I, as a product owner, see and determine the remaining backlog from Group 1 to be worked on in Sprint 4. In yesterday’s sprint planning, I discussed the problems faced or unfinished backlogs from sprint 3 with all group members, and from the results, I finally decided what backlogs would be taken with different priorities. In addition, I also coordinated with group 2 regarding the module integration plan, and after discussing it with other group members and considering the time needed to integrate it, the two groups decided to integrate in week 2 after the UAT.</p><p>In addition, regarding the unresolved modules, I coordinated with the group members to solve the bug problems or implement the feedback this week at the latest by tomorrow, because our group also had to merge into production and deploy. As a product owner, I also communicate and coordinate the problems faced and ask for further explanations from stakeholders, which I do via WhatsApp until all requirements are clearly obtained.</p><p>Referrence</p><ul><li><a href="https://jilham-luthfi15.medium.com/the-way-to-be-a-people-person-4184d27682f4">The Way to Be a People Person</a></li><li><a href="https://books.google.co.id/books?id=ajLMLYUlAqcC&amp;printsec=copyright&amp;redir_esc=y#v=onepage&amp;q&amp;f=false">Be a People Person</a></li><li><a href="https://glints.com/id/lowongan/people-person/">Ingin Jadi Pusat Perhatian? Ikuti 4 Cara untuk Menjadi People Person</a></li></ul><p><a href="https://glints.com/id/lowongan/people-person-vs-people-pleaser/#:~:text=Dilansir%20dari%20Cambridge%20Dictionary%2C%20people,memiliki%20perkembangan%20karier%20yang%20pesat">https://glints.com/id/lowongan/people-person-vs-people-pleaser/#:~:text=Dilansir%20dari%20Cambridge%20Dictionary%2C%20people,memiliki%20perkembangan%20karier%20yang%20pesat</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=913c80cf6d6e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Teamwork with Tools]]></title>
            <link>https://medium.com/@david.christianto05/teamwork-with-tools-563a2de3f077?source=rss-df4cd0818f03------2</link>
            <guid isPermaLink="false">https://medium.com/p/563a2de3f077</guid>
            <dc:creator><![CDATA[David Christianto]]></dc:creator>
            <pubDate>Mon, 13 Nov 2023 06:31:00 GMT</pubDate>
            <atom:updated>2023-11-13T06:31:00.877Z</atom:updated>
            <content:encoded><![CDATA[<p>Teamwork:</p><p>In agile development, cooperation is key to completing tasks. With good cooperation, harmonious communication can be created. Specifically on the developer side, cooperation is needed because sometimes the tasks taken are dependent on each other, where aspects of ability, time, cost, and other resources must be considered and adjusted. In the teamwork aspect, my group mates and I agreed to take on tasks according to each other’s abilities. In addition, we used various tools to improve our group’s performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/309/0*mQYzbfrZVuT6lmLn.png" /></figure><ul><li>Use of discord for discussion and daily meetings: Group 1 used discord as a means of communication, where we had group discussions and also accessed any resources or announcements through the app. In addition, we also hold daily meetings that have been agreed upon through the Discord app via the voice channel feature. Usually, at these meetings, we each report what has been done and what obstacles have been encountered during the work.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XHwdTP0PAhtv0J1HC0n2Uw.png" /></figure><ul><li>Use of Trello: Group 1 also used the Trello tool as a replacement for Jira because the Jira subscription had run out. Trello has the same mechanism as Jira, where we use Trello to list the PBIs that our group will take in that sprint and break them down into tasks. We can also assign the tasks to group members and assign weight to each task. In addition, Trello also provides a description feature that is useful for writing down the details of the task. In addition, the board on Trello also allows our group to know what stage a task is at; for example, task 1 in sprint 3 is already at the deploy in development branch stage.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mGXjZW-iK-VX6sEQavk7KA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_cE51RZCx8Ky-tACIS0I4Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1IW0uI31LJdeBLuyo2I1qA.png" /></figure><ul><li>commit message:</li></ul><p>I also use a commit message when I push. The commit message lets other members know that I have made changes to the code in the branch. I wrote this commit message based on the guidelines in the ppl wiki, where the red label is for unsuccessful TDD, the green label is for successful TDD, the fix label is for fixing functional code, or the refactor label is for making structural changes to the code.</p><p>In addition, our group applies a merge request mechanism where, before merging to the development branch, the code to be merged must be reviewed by at least two group members to identify code smells or other deficiencies so that the code that is merged to the development branch is truly categorized as clean code and there are no problems or errors.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=563a2de3f077" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Software Quality Assurance: Sonarqube]]></title>
            <link>https://medium.com/@david.christianto05/software-quality-assurance-sonarqube-f14fe937e7ac?source=rss-df4cd0818f03------2</link>
            <guid isPermaLink="false">https://medium.com/p/f14fe937e7ac</guid>
            <dc:creator><![CDATA[David Christianto]]></dc:creator>
            <pubDate>Sun, 05 Nov 2023 16:57:00 GMT</pubDate>
            <atom:updated>2023-11-05T16:57:00.338Z</atom:updated>
            <content:encoded><![CDATA[<h3>Sonarqube</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/0*ALehnZJGqdYv1GE6.png" /><figcaption>Image source: <a href="https://wiki.eclipse.org/SonarQube">https://wiki.eclipse.org/SonarQube</a></figcaption></figure><h3>Introduction</h3><p>Sonarqube is an open-source platform used for continuous inspection of code quality that collects metrics about the quality of the analyzed code and places them in a dashboard. In addition, Sonarqube provides several tips to help make code better by performing static analysis, namely by identifying code smells, code style violations, code duplication, displaying bug details in more detail, and displaying code coverage.</p><p>Sonarqube supports various programming languages such as Python, Java, C, C++, Kotlin, Go, etc. Some of the main features of the Sonar Cube include:</p><ul><li>Static code analysis: Sonarqube does not actively run code but rather analyzes the source code without running it. This allows Sonarqube to identify potential issues and rule violations that may be present in the code.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*ICP0zRXbabFSqiZ4.png" /></figure><ul><li>Code quality monitoring: Sonarqube provides a comprehensive view of a project’s code quality, which includes reports on discovered issues such as code smells and bugs as well as the level of compliance with coding standards.</li><li>Integration with various tools: As Sonarqube is an open-source platform, it can be integrated with Gitlab via commands in CI/CD or integrated with other tools such as the Version Control System (VCS) for version management.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*V8bbJjQJCzmhuccx.png" /></figure><ul><li>Security Code Analysis: Sonarqube can indicate potential security issues in the integrated code; for example, there is an XSS (cross-site scripting) problem where a hacker inserts a malicious code script into a web page that can be seen by other users. Sonarqube will then notify you via the Security Hotspots feature and inform you of the risks involved and how to handle them.</li><li>Reports and Metrics: Sonarqube generates useful reports on code quality and security. It helps developers understand where improvements are needed and provides metrics to track changes in code quality over time.</li></ul><h3>What was implemented regarding Sonarqube</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*G3QFfJ79D0HyzCLI.png" /></figure><ul><li>First, I used Sonarqube from CSUI. The first step I took was to integrate Sonarqube with GitLab.</li></ul><p>link Sonarqube CSUI: <a href="https://sonarqube.cs.ui.ac.id/projects">Projects (ui.ac.id)</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PxKXYHR1eKUlDkyj.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*k0vSxeDrdLUmnYFr.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*dA48YCQrjItRjayC.png" /></figure><ul><li>Then, I chose the repository that I wanted to integrate. I also created a personal access token related to the repository.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/0*AIbCAzTkoJ3B-mUS.png" /></figure><ul><li>Next, I created a CI/CD command in.gitlab-ci.yml</li><li>Next, I created the sonar-projects.properties file as follows: (in this file, I write the host URL and source, including what is included and excluded related to the test that will be run later)</li></ul><pre># SonarScanner properties file<br>sonar.host.url=https://sonarqube.cs.ui.ac.id<br>## Project configuration<br>sonar.projectKey=ppl-fasilkom-ui_2023_ki-ganjil-2023-2024_group-1_back-end_drf-siasisten_AYrb9Y1v94kwVhMRxVkS<br>## Path to sources<br>sonar.sources=.<br>sonar.exclusions=**/migrations/*, manage.py<br>#sonar.inclusions=<br>## Path to tests<br>sonar.test.exclusions=helloworld/**/*,manage.py<br>sonar.test.inclusions=log<br>## Source encoding<br>sonar.sourceEncoding=UTF-8<br>## Branch analysis<br>## Python-specific configurations<br>sonar.python.coverage.reportPaths=coverage.xml</pre><ul><li>Then I did a git push and managed to make my pipeline green. And for Sonarqube CSUI itself, for now it can only identify the main branch which is the production branch, because our group is still in progress and has not merged into the main branch, our group’s Sonarqube still does not display analyses related to our group’s code.</li></ul><h3>Result</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/0*cqS0JG5AhrCsJgwV.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*gxV351SE4ogYo7p-.png" /></figure><p>The integration into Sonarqube itself has been successful, but in our group repository, we have not done a git push to the main branch, so now our group’s code coverage has not appeared on Sonarqube.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f14fe937e7ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Platform Monitoring: Monitoring and Profiling in Django]]></title>
            <link>https://medium.com/@david.christianto05/platform-monitoring-monitoring-and-profiling-in-django-0f3561f27cf7?source=rss-df4cd0818f03------2</link>
            <guid isPermaLink="false">https://medium.com/p/0f3561f27cf7</guid>
            <dc:creator><![CDATA[David Christianto]]></dc:creator>
            <pubDate>Tue, 31 Oct 2023 16:02:58 GMT</pubDate>
            <atom:updated>2023-10-31T16:02:58.885Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l2REWszAXZfx3e49C1QlFg.png" /><figcaption>Image source: <a href="https://scoutapm.com/blog/monitoring-a-django-app-with-scout">https://scoutapm.com/blog/monitoring-a-django-app-with-scout</a></figcaption></figure><h3>Introduction</h3><p>In the context of the Django app itself, there are two important concepts in checking and analyzing code in app development, namely Monitoring and Profiling.</p><p>Monitoring is usually done after deployment to monitor how the app is running. It is usually an analysis of memory usage, CPU performance, or disk usage. Monitoring itself can be defined as a process of monitoring the performance and availability of an application that is carried out continuously. The main purpose of monitoring is to analyze and identify problems quickly so as to ensure that the system is running properly. If this monitoring activity can be set up so that it runs automatically, then it will be very helpful for developers. And here are some examples of open-source tools for monitoring activities: Munin, Nagios, and MRTG</p><p>Profiling is usually done before deployment. Due to this difference, it is better to use different tools for monitoring and profiling. Profiling is usually used to measure performance (speed) by running code and recording how long each step takes. Profiling itself can be defined as a process that is done to analyze and identify the parts of the application code that need improvement and performance enhancement. This will help the process of identifying hotspots in the application that consume a lot of resources and slow down performance. Profiling also involves measuring resource usage and code execution time. One of the most commonly used profiling methods is to trace network routes, which also depend on the existing network and firewall.</p><h3>MONITORING</h3><p>The following are important aspects of the monitoring process:</p><ul><li>Performance Monitoring: The monitoring process will typically monitor performance metrics such as CPU usage, memory usage, number of HTTP requests, response time, and more.</li><li>Availability Monitoring: The monitoring process will usually monitor whether the application or service is operational or experiencing downtime.</li><li>Notifications: The monitoring process will also send notifications to the development team or administrators if problems occur or if certain limits are exceeded.</li><li>Logging: The logging aspect of the monitoring process serves to record important events or occurrences in the application for further analysis.</li></ul><h3>PROFILING</h3><p>The following are the types of profiling that are commonly used:</p><ul><li>CPU Profiling: This type of profiling is commonly used to measure CPU usage by functions in the application to identify functions that take up a lot of processing time. And after getting that data, developers can make code improvements to improve the performance of the application.</li><li>Memory Profiling: Memory profiling is commonly used to measure memory usage by applications and identify excessive memory allocation or memory leaks.</li><li>Database Profiling: This type of profiling will usually identify database queries that require optimization.</li></ul><h3>The Importance of Monitoring and Profiling</h3><p><strong><em>1. Optimizing Performance</em></strong><br>By profiling, developers can monitor the performance of platforms and applications in real-time, which is helpful in finding indications of code bottlenecks and ineffectiveness. That way, quick and precise optimizations can be made, which results in a more pleasant user experience when using the application.</p><p><strong><em>2. To prevent and minimize errors</em></strong><br>Monitoring and profiling the code makes it easier to track errors in real-time, which in turn prevents more complex and larger errors from occurring. With proper identification and correction, it will also save the developer time in developing the app.</p><p><strong><em>3. For business and commercial purposes</em></strong><br>The analysis data obtained as a report will be very useful in the business aspect of decision-making and consumer mapping. This is because the data analysis results include insights into platform usage, user demographics, and user engagement. This is very crucial for developers to customize the specifications of the applications they develop according to user preferences and needs.</p><h3>Main Differences Between Monitoring and Profiling</h3><p>The main differences between monitoring and profiling are</p><ul><li>Monitoring is a process that focuses on monitoring the overall performance (system health) of applications in real-time or continuously, while profiling is more focused on in-depth analysis of application code to identify performance and resource usage issues.</li><li>Monitoring generally focuses more on the overall system and application level, including availability levels, server load, and HTTP requests, while profiling focuses on the internal components of the application, such as functions and database requests that consume a lot of resources.</li><li>Monitoring is a useful tool to detect problems immediately and keep an eye on the overall health of the system, while profiling helps developers optimize code and improve application performance.</li></ul><h3>What Is Done Regarding Profiling</h3><p>I used Django Silk to do the profiling with the following steps:</p><ol><li>Install Django Silk using the command</li></ol><pre>pip install Django-silk</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LWkCqqvbwV4QNSmZbylTXQ.png" /></figure><p>2. Next is to add ‘silk.middleware.SilkyMiddleware’, to MIDDLEWARE and ‘silk’ to INSTALLED_APPS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*yOn52fD8Z7La8V2Qe9Z5RQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*uWCQNVrCBlrvbXIM0wyEiQ.png" /></figure><p>3. To enable access, we need to add the following code snippet to urls.py</p><pre>urlpatterns += [path(&quot;silk/&quot;, include(&quot;silk.urls&quot;, namespace=&quot;silk&quot;))]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*XwmRuY6TeFjz5KUNqpKIoA.png" /></figure><p>Before running silk, perform the python manage.py migrate and python manage.py collectstatic commands in the cmd.</p><p>4. Then turn on SILKY_PYTHON_PROFILER in settings.py with the following code snippet:</p><pre>SILKY_PYTHON_PROFILER = True</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*y5QjbXR95wTKGEmIUUW5NQ.png" /></figure><p>5. Add the <a href="http://twitter.com/silk_profile">@silk_profile</a>(name=’Get Log’) decorator to the function in views.py and import the module with the command from silk.profiling.profiler import silk_profile</p><pre>...<br>from silk.profiling.profiler import silk_profile<br>...<br><br><br><br><br>class LogsView(APIView):<br>...<br>    def get(self, request, pk=None):  # Tambahkan parameter pk dengan default None<br>        if pk is not None:<br>            log = Logs.objects.filter(pk=pk).first()<br>            if log is None:<br>                return Response({&quot;message&quot;: &quot;Log not found&quot;}, status=status.HTTP_404_NOT_FOUND)<br>            serializer = LogsSerializer(log)<br>            return Response(serializer.data)<br><br>        logs = Logs.objects.all()<br>        serializer = LogsSerializer(logs, many=True)<br>        return Response(serializer.data)<br>...</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*N-UXPQseMh3docbx-J55Ng.png" /></figure><p>6. Run the application with the command python manage.py runserver and type /api/silk. Don&#39;t forget to open your base app urls too before you open the /api/silk. So, the profiling result is below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*jgPHslG7IHkfTw7UYiNHLQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z6u1FvvhPhEP5RyTA9SS3w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*64BDLxmAweWwxL9kDhSN3Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f7eKkxesxGPyFpkN6kemUA.png" /></figure><h3>What Is Done Regarding Monitoring</h3><ol><li>Install Django-prometheus in cmd with the command</li></ol><pre>pip install django-prometheus</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hyIgS01eCgnXiS5hWKn65Q.png" /></figure><p>2. Next is to add django_prometheus.middleware to MIDDLEWARE and ‘django_prometheus’ to INSTALLED_APPS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*LYy47OTLc9SLHQlYljrHaA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*68LBRZysaCGeLu6MFyAkhw.png" /></figure><p>3. to add the metric, add the code snippet below to urls.py</p><pre>path(&#39;&#39;, include(&#39;django_prometheus.urls&#39;)),</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*awa6teCwHiuudwUQjpou-g.png" /></figure><p>4. Run the application with the python manage.py runserver command and type /api/metrics. The result is below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hGSgA3RBtwMlpYX4yHsliQ.png" /></figure><pre># HELP python_gc_objects_collected_total Objects collected during gc<br># TYPE python_gc_objects_collected_total counter<br>python_gc_objects_collected_total{generation=&quot;0&quot;} 1824.0<br>python_gc_objects_collected_total{generation=&quot;1&quot;} 653.0<br>python_gc_objects_collected_total{generation=&quot;2&quot;} 645.0<br># HELP python_gc_objects_uncollectable_total Uncollectable objects found during GC<br># TYPE python_gc_objects_uncollectable_total counter<br>python_gc_objects_uncollectable_total{generation=&quot;0&quot;} 0.0<br>python_gc_objects_uncollectable_total{generation=&quot;1&quot;} 0.0<br>python_gc_objects_uncollectable_total{generation=&quot;2&quot;} 0.0<br># HELP python_gc_collections_total Number of times this generation was collected<br># TYPE python_gc_collections_total counter<br>python_gc_collections_total{generation=&quot;0&quot;} 243.0<br>python_gc_collections_total{generation=&quot;1&quot;} 22.0<br>python_gc_collections_total{generation=&quot;2&quot;} 2.0<br># HELP python_info Python platform information<br># TYPE python_info gauge<br>python_info{implementation=&quot;CPython&quot;,major=&quot;3&quot;,minor=&quot;11&quot;,patchlevel=&quot;5&quot;,version=&quot;3.11.5&quot;} 1.0<br># HELP django_model_inserts_total Number of insert operations by model.<br># TYPE django_model_inserts_total counter<br># HELP django_model_updates_total Number of update operations by model.<br># TYPE django_model_updates_total counter<br># HELP django_model_deletes_total Number of delete operations by model.<br># TYPE django_model_deletes_total counter<br># HELP django_migrations_unapplied_total Count of unapplied migrations by database connection<br># TYPE django_migrations_unapplied_total gauge<br># HELP django_migrations_applied_total Count of applied migrations by database connection<br># TYPE django_migrations_applied_total gauge<br># HELP django_http_requests_before_middlewares_total Total count of requests before middlewares run.<br># TYPE django_http_requests_before_middlewares_total counter<br>django_http_requests_before_middlewares_total 3.0<br># HELP django_http_requests_before_middlewares_created Total count of requests before middlewares run.<br># TYPE django_http_requests_before_middlewares_created gauge<br>django_http_requests_before_middlewares_created 1.698767768627698e+09<br># HELP django_http_responses_before_middlewares_total Total count of responses before middlewares run.<br># TYPE django_http_responses_before_middlewares_total counter<br>django_http_responses_before_middlewares_total 2.0<br># HELP django_http_responses_before_middlewares_created Total count of responses before middlewares run.<br># TYPE django_http_responses_before_middlewares_created gauge<br>django_http_responses_before_middlewares_created 1.698767768627698e+09<br># HELP django_http_requests_latency_including_middlewares_seconds Histogram of requests processing time (including middleware processing time).<br># TYPE django_http_requests_latency_including_middlewares_seconds histogram<br>django_http_requests_latency_including_middlewares_seconds_bucket{le=&quot;0.01&quot;} 0.0<br>django_http_requests_latency_including_middlewares_seconds_bucket{le=&quot;0.025&quot;} 0.0<br>django_http_requests_latency_including_middlewares_seconds_bucket{le=&quot;0.05&quot;} 0.0<br>django_http_requests_latency_including_middlewares_seconds_bucket{le=&quot;0.075&quot;} 0.0<br>django_http_requests_latency_including_middlewares_seconds_bucket{le=&quot;0.1&quot;} 0.0<br>django_http_requests_latency_including_middlewares_seconds_bucket{le=&quot;0.25&quot;} 1.0<br>django_http_requests_latency_including_middlewares_seconds_bucket{le=&quot;0.5&quot;} 2.0<br>django_http_requests_latency_including_middlewares_seconds_bucket{le=&quot;0.75&quot;} 2.0<br>django_http_requests_latency_including_middlewares_seconds_bucket{le=&quot;1.0&quot;} 2.0<br>django_http_requests_latency_including_middlewares_seconds_bucket{le=&quot;2.5&quot;} 2.0<br>django_http_requests_latency_including_middlewares_seconds_bucket{le=&quot;5.0&quot;} 2.0<br>django_http_requests_latency_including_middlewares_seconds_bucket{le=&quot;7.5&quot;} 2.0<br>django_http_requests_latency_including_middlewares_seconds_bucket{le=&quot;10.0&quot;} 2.0<br>django_http_requests_latency_including_middlewares_seconds_bucket{le=&quot;25.0&quot;} 2.0<br>django_http_requests_latency_including_middlewares_seconds_bucket{le=&quot;50.0&quot;} 2.0<br>django_http_requests_latency_including_middlewares_seconds_bucket{le=&quot;75.0&quot;} 2.0<br>django_http_requests_latency_including_middlewares_seconds_bucket{le=&quot;+Inf&quot;} 2.0<br>django_http_requests_latency_including_middlewares_seconds_count 2.0<br>django_http_requests_latency_including_middlewares_seconds_sum 0.6246375999999145<br># HELP django_http_requests_latency_including_middlewares_seconds_created Histogram of requests processing time (including middleware processing time).<br># TYPE django_http_requests_latency_including_middlewares_seconds_created gauge<br>django_http_requests_latency_including_middlewares_seconds_created 1.698767768627698e+09<br># HELP django_http_requests_unknown_latency_including_middlewares_total Count of requests for which the latency was unknown (when computing django_http_requests_latency_including_middlewares_seconds).<br># TYPE django_http_requests_unknown_latency_including_middlewares_total counter<br>django_http_requests_unknown_latency_including_middlewares_total 0.0<br># HELP django_http_requests_unknown_latency_including_middlewares_created Count of requests for which the latency was unknown (when computing django_http_requests_latency_including_middlewares_seconds).<br># TYPE django_http_requests_unknown_latency_including_middlewares_created gauge<br>django_http_requests_unknown_latency_including_middlewares_created 1.698767768627698e+09<br># HELP django_http_requests_latency_seconds_by_view_method Histogram of request processing time labelled by view.<br># TYPE django_http_requests_latency_seconds_by_view_method histogram<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;0.01&quot;,method=&quot;GET&quot;,view=&quot;&lt;unnamed view&gt;&quot;} 0.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;0.025&quot;,method=&quot;GET&quot;,view=&quot;&lt;unnamed view&gt;&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;0.05&quot;,method=&quot;GET&quot;,view=&quot;&lt;unnamed view&gt;&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;0.075&quot;,method=&quot;GET&quot;,view=&quot;&lt;unnamed view&gt;&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;0.1&quot;,method=&quot;GET&quot;,view=&quot;&lt;unnamed view&gt;&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;0.25&quot;,method=&quot;GET&quot;,view=&quot;&lt;unnamed view&gt;&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;0.5&quot;,method=&quot;GET&quot;,view=&quot;&lt;unnamed view&gt;&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;0.75&quot;,method=&quot;GET&quot;,view=&quot;&lt;unnamed view&gt;&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;1.0&quot;,method=&quot;GET&quot;,view=&quot;&lt;unnamed view&gt;&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;2.5&quot;,method=&quot;GET&quot;,view=&quot;&lt;unnamed view&gt;&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;5.0&quot;,method=&quot;GET&quot;,view=&quot;&lt;unnamed view&gt;&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;7.5&quot;,method=&quot;GET&quot;,view=&quot;&lt;unnamed view&gt;&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;10.0&quot;,method=&quot;GET&quot;,view=&quot;&lt;unnamed view&gt;&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;25.0&quot;,method=&quot;GET&quot;,view=&quot;&lt;unnamed view&gt;&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;50.0&quot;,method=&quot;GET&quot;,view=&quot;&lt;unnamed view&gt;&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;75.0&quot;,method=&quot;GET&quot;,view=&quot;&lt;unnamed view&gt;&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;+Inf&quot;,method=&quot;GET&quot;,view=&quot;&lt;unnamed view&gt;&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_count{method=&quot;GET&quot;,view=&quot;&lt;unnamed view&gt;&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_sum{method=&quot;GET&quot;,view=&quot;&lt;unnamed view&gt;&quot;} 0.011953999999605003<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;0.01&quot;,method=&quot;GET&quot;,view=&quot;logs-list&quot;} 0.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;0.025&quot;,method=&quot;GET&quot;,view=&quot;logs-list&quot;} 0.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;0.05&quot;,method=&quot;GET&quot;,view=&quot;logs-list&quot;} 0.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;0.075&quot;,method=&quot;GET&quot;,view=&quot;logs-list&quot;} 0.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;0.1&quot;,method=&quot;GET&quot;,view=&quot;logs-list&quot;} 0.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;0.25&quot;,method=&quot;GET&quot;,view=&quot;logs-list&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;0.5&quot;,method=&quot;GET&quot;,view=&quot;logs-list&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;0.75&quot;,method=&quot;GET&quot;,view=&quot;logs-list&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;1.0&quot;,method=&quot;GET&quot;,view=&quot;logs-list&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;2.5&quot;,method=&quot;GET&quot;,view=&quot;logs-list&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;5.0&quot;,method=&quot;GET&quot;,view=&quot;logs-list&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;7.5&quot;,method=&quot;GET&quot;,view=&quot;logs-list&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;10.0&quot;,method=&quot;GET&quot;,view=&quot;logs-list&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;25.0&quot;,method=&quot;GET&quot;,view=&quot;logs-list&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;50.0&quot;,method=&quot;GET&quot;,view=&quot;logs-list&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;75.0&quot;,method=&quot;GET&quot;,view=&quot;logs-list&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_bucket{le=&quot;+Inf&quot;,method=&quot;GET&quot;,view=&quot;logs-list&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_count{method=&quot;GET&quot;,view=&quot;logs-list&quot;} 1.0<br>django_http_requests_latency_seconds_by_view_method_sum{method=&quot;GET&quot;,view=&quot;logs-list&quot;} 0.13127580000036687<br># HELP django_http_requests_latency_seconds_by_view_method_created Histogram of request processing time labelled by view.<br># TYPE django_http_requests_latency_seconds_by_view_method_created gauge<br>django_http_requests_latency_seconds_by_view_method_created{method=&quot;GET&quot;,view=&quot;&lt;unnamed view&gt;&quot;} 1.6987677705879524e+09<br>django_http_requests_latency_seconds_by_view_method_created{method=&quot;GET&quot;,view=&quot;logs-list&quot;} 1.6987677759001648e+09<br># HELP django_http_requests_unknown_latency_total Count of requests for which the latency was unknown.<br># TYPE django_http_requests_unknown_latency_total counter<br>django_http_requests_unknown_latency_total 0.0<br># HELP django_http_requests_unknown_latency_created Count of requests for which the latency was unknown.<br># TYPE django_http_requests_unknown_latency_created gauge<br>django_http_requests_unknown_latency_created 1.698767768627698e+09<br># HELP django_http_ajax_requests_total Count of AJAX requests.<br># TYPE django_http_ajax_requests_total counter<br>django_http_ajax_requests_total 0.0<br># HELP django_http_ajax_requests_created Count of AJAX requests.<br># TYPE django_http_ajax_requests_created gauge<br>django_http_ajax_requests_created 1.698767768627698e+09<br># HELP django_http_requests_total_by_method_total Count of requests by method.<br># TYPE django_http_requests_total_by_method_total counter<br>django_http_requests_total_by_method_total{method=&quot;GET&quot;} 3.0<br># HELP django_http_requests_total_by_method_created Count of requests by method.<br># TYPE django_http_requests_total_by_method_created gauge<br>django_http_requests_total_by_method_created{method=&quot;GET&quot;} 1.6987677705759711e+09<br># HELP django_http_requests_total_by_transport_total Count of requests by transport.<br># TYPE django_http_requests_total_by_transport_total counter<br>django_http_requests_total_by_transport_total{transport=&quot;http&quot;} 3.0<br># HELP django_http_requests_total_by_transport_created Count of requests by transport.<br># TYPE django_http_requests_total_by_transport_created gauge<br>django_http_requests_total_by_transport_created{transport=&quot;http&quot;} 1.6987677705759711e+09<br># HELP django_http_requests_total_by_view_transport_method_total Count of requests by view, transport, method.<br># TYPE django_http_requests_total_by_view_transport_method_total counter<br>django_http_requests_total_by_view_transport_method_total{method=&quot;GET&quot;,transport=&quot;http&quot;,view=&quot;logs-list&quot;} 1.0<br>django_http_requests_total_by_view_transport_method_total{method=&quot;GET&quot;,transport=&quot;http&quot;,view=&quot;prometheus-django-metrics&quot;} 1.0<br># HELP django_http_requests_total_by_view_transport_method_created Count of requests by view, transport, method.<br># TYPE django_http_requests_total_by_view_transport_method_created gauge<br>django_http_requests_total_by_view_transport_method_created{method=&quot;GET&quot;,transport=&quot;http&quot;,view=&quot;logs-list&quot;} 1.6987677757693686e+09<br>django_http_requests_total_by_view_transport_method_created{method=&quot;GET&quot;,transport=&quot;http&quot;,view=&quot;prometheus-django-metrics&quot;} 1.6987677874002252e+09<br># HELP django_http_requests_body_total_bytes Histogram of requests by body size.<br># TYPE django_http_requests_body_total_bytes histogram<br>django_http_requests_body_total_bytes_bucket{le=&quot;0.0&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;1.0&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;2.0&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;4.0&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;8.0&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;16.0&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;32.0&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;64.0&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;128.0&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;256.0&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;512.0&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;1024.0&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;2048.0&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;4096.0&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;8192.0&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;16384.0&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;32768.0&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;65536.0&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;131072.0&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;262144.0&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;524288.0&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;1.048576e+06&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;2.097152e+06&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;4.194304e+06&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;8.388608e+06&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;1.6777216e+07&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;3.3554432e+07&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;6.7108864e+07&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;1.34217728e+08&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;2.68435456e+08&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;5.36870912e+08&quot;} 3.0<br>django_http_requests_body_total_bytes_bucket{le=&quot;+Inf&quot;} 3.0<br>django_http_requests_body_total_bytes_count 3.0<br>django_http_requests_body_total_bytes_sum 0.0<br># HELP django_http_requests_body_total_bytes_created Histogram of requests by body size.<br># TYPE django_http_requests_body_total_bytes_created gauge<br>django_http_requests_body_total_bytes_created 1.698767768627698e+09<br># HELP django_http_responses_total_by_templatename_total Count of responses by template name.<br># TYPE django_http_responses_total_by_templatename_total counter<br>django_http_responses_total_by_templatename_total{templatename=&quot;None&quot;} 1.0<br># HELP django_http_responses_total_by_templatename_created Count of responses by template name.<br># TYPE django_http_responses_total_by_templatename_created gauge<br>django_http_responses_total_by_templatename_created{templatename=&quot;None&quot;} 1.6987677758415508e+09<br># HELP django_http_responses_total_by_status_total Count of responses by status.<br># TYPE django_http_responses_total_by_status_total counter<br>django_http_responses_total_by_status_total{status=&quot;404&quot;} 1.0<br>django_http_responses_total_by_status_total{status=&quot;200&quot;} 1.0<br># HELP django_http_responses_total_by_status_created Count of responses by status.<br># TYPE django_http_responses_total_by_status_created gauge<br>django_http_responses_total_by_status_created{status=&quot;404&quot;} 1.6987677705879524e+09<br>django_http_responses_total_by_status_created{status=&quot;200&quot;} 1.6987677759001648e+09<br># HELP django_http_responses_total_by_status_view_method_total Count of responses by status, view, method.<br># TYPE django_http_responses_total_by_status_view_method_total counter<br>django_http_responses_total_by_status_view_method_total{method=&quot;GET&quot;,status=&quot;404&quot;,view=&quot;&lt;unnamed view&gt;&quot;} 1.0<br>django_http_responses_total_by_status_view_method_total{method=&quot;GET&quot;,status=&quot;200&quot;,view=&quot;logs-list&quot;} 1.0<br># HELP django_http_responses_total_by_status_view_method_created Count of responses by status, view, method.<br># TYPE django_http_responses_total_by_status_view_method_created gauge<br>django_http_responses_total_by_status_view_method_created{method=&quot;GET&quot;,status=&quot;404&quot;,view=&quot;&lt;unnamed view&gt;&quot;} 1.6987677705879524e+09<br>django_http_responses_total_by_status_view_method_created{method=&quot;GET&quot;,status=&quot;200&quot;,view=&quot;logs-list&quot;} 1.6987677759001648e+09<br># HELP django_http_responses_body_total_bytes Histogram of responses by body size.<br># TYPE django_http_responses_body_total_bytes histogram<br>django_http_responses_body_total_bytes_bucket{le=&quot;0.0&quot;} 0.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;1.0&quot;} 0.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;2.0&quot;} 0.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;4.0&quot;} 0.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;8.0&quot;} 0.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;16.0&quot;} 0.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;32.0&quot;} 0.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;64.0&quot;} 0.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;128.0&quot;} 0.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;256.0&quot;} 0.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;512.0&quot;} 0.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;1024.0&quot;} 0.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;2048.0&quot;} 0.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;4096.0&quot;} 1.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;8192.0&quot;} 1.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;16384.0&quot;} 1.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;32768.0&quot;} 2.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;65536.0&quot;} 2.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;131072.0&quot;} 2.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;262144.0&quot;} 2.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;524288.0&quot;} 2.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;1.048576e+06&quot;} 2.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;2.097152e+06&quot;} 2.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;4.194304e+06&quot;} 2.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;8.388608e+06&quot;} 2.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;1.6777216e+07&quot;} 2.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;3.3554432e+07&quot;} 2.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;6.7108864e+07&quot;} 2.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;1.34217728e+08&quot;} 2.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;2.68435456e+08&quot;} 2.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;5.36870912e+08&quot;} 2.0<br>django_http_responses_body_total_bytes_bucket{le=&quot;+Inf&quot;} 2.0<br>django_http_responses_body_total_bytes_count 2.0<br>django_http_responses_body_total_bytes_sum 29852.0<br># HELP django_http_responses_body_total_bytes_created Histogram of responses by body size.<br># TYPE django_http_responses_body_total_bytes_created gauge<br>django_http_responses_body_total_bytes_created 1.698767768627698e+09<br># HELP django_http_responses_total_by_charset_total Count of responses by charset.<br># TYPE django_http_responses_total_by_charset_total counter<br>django_http_responses_total_by_charset_total{charset=&quot;utf-8&quot;} 2.0<br># HELP django_http_responses_total_by_charset_created Count of responses by charset.<br># TYPE django_http_responses_total_by_charset_created gauge<br>django_http_responses_total_by_charset_created{charset=&quot;utf-8&quot;} 1.6987677705879524e+09<br># HELP django_http_responses_streaming_total Count of streaming responses.<br># TYPE django_http_responses_streaming_total counter<br>django_http_responses_streaming_total 0.0<br># HELP django_http_responses_streaming_created Count of streaming responses.<br># TYPE django_http_responses_streaming_created gauge<br>django_http_responses_streaming_created 1.698767768627698e+09<br># HELP django_http_exceptions_total_by_type_total Count of exceptions by object type.<br># TYPE django_http_exceptions_total_by_type_total counter<br># HELP django_http_exceptions_total_by_view_total Count of exceptions by view.<br># TYPE django_http_exceptions_total_by_view_total counter</pre><h3>Source</h3><ul><li><a href="https://medium.com/kami-people/profiling-in-django-9f4d403a394f">Profiling in Django</a></li><li><a href="https://medium.com/@jovian.marvin/monitoring-profiling-a-django-application-76d15877e4b0">Monitoring &amp; Profiling a Django Application</a></li><li><a href="https://stackoverflow.com/questions/24441687/what-is-the-difference-between-monitoring-and-profiling">What is the difference between monitoring and profiling?</a></li><li><a href="https://serverfault.com/questions/446956/whats-difference-between-monitoring-tracing-and-profiling">What&#39;s difference between monitoring, tracing and profiling?</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0f3561f27cf7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Refactoring Code: Layered Architecture]]></title>
            <link>https://medium.com/@david.christianto05/refactoring-code-layered-architecture-8f2422df4918?source=rss-df4cd0818f03------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f2422df4918</guid>
            <dc:creator><![CDATA[David Christianto]]></dc:creator>
            <pubDate>Mon, 16 Oct 2023 04:11:16 GMT</pubDate>
            <atom:updated>2023-10-16T04:11:16.381Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*9gS7dxj0cSeM7ixnKXS73w.png" /><figcaption>Image source: <a href="https://www.geeksforgeeks.org/7-code-refactoring-techniques-in-software-engineering/">https://www.geeksforgeeks.org/7-code-refactoring-techniques-in-software-engineering/</a></figcaption></figure><h3>Introduction</h3><p>Refactoring code is a systematic process or method used in software development to restructure and improve the quality of code that has been created without changing the functional and external behavior of the code itself. This refactoring process aims to make the code more readable, easier to understand, increase extensibility and maintainability, and also make the code easier to fix.</p><h3>A Suitable Time to Do Refactoring</h3><p>According to Martin Fowler, the Father of Refactoring, the right time to do code refactoring is if you find indications of code smells. This is expressed in the book he wrote entitled “Refactoring: Improving the Design of Existing Code”. Also, the recommended time to refactor a code is before updating or adding new features to the existing code. Refactoring at this stage will make it easier for developers to build on existing code because they will go back and simplify the code, making it easier to read and understand.</p><p>Here are some indications that are right for refactoring code:</p><ol><li>If you find code duplication: Duplication of code makes the code difficult to read; in addition to writing the same code repeatedly, this will make the code performance slower than it should be. Therefore, the duplicated code should be converted into a single entity that can be called and reused, for example, by making it inside a function that can be called when needed.</li><li>Functions that are too complex to understand: If a function is too complex and lengthy for the development team to understand, this is one of the indications for refactoring. In this case, refactoring is done by breaking down the long and complex function into several smaller functions that are easier to understand. This refactoring can help simplify code structure and documentation.</li><li>If you often make major changes when making updates or adding features: Major changes to code can be time-consuming because they change most of the code structure, and it is not uncommon for errors to arise that require hours of debugging. So in cases like this, refactoring is one of the solutions that can be implemented to change the code structure to increase code flexibility.</li></ol><h3>Techniques Used in Code Refactoring</h3><p>In refactoring code, developers can use several techniques to increase the effectiveness of the work. Currently, there are more than 70 refactoring techniques that can be used. Here are some techniques that are commonly used in refactoring:</p><ul><li>Extract Method: This method will divide a long function that has several tasks into several smaller functions that have more specific tasks. Or in other words, it breaks the code into smaller parts and then moves those parts to other methods. The fragmented code is replaced with calls to new methods.</li><li>Replacing Variables with Functions: Replaces variables used in repetitive expressions with functions that will return the required value.</li><li>Replacing duplicate code with functions: Duplication of code is writing code that has the same function repeatedly. Therefore, developers can encapsulate the same code in a function or method so that if you need the function, you can call the previously defined function with a more concise syntax.</li><li>Green-red: This refactoring method is widely used in Agile development. In the process, this green-red technique involves three steps. First, the developer will determine what aspects need to be developed. The second step is that the developer will make the project pass testing. The last step, the third step, is the developer refactoring the code to make improvements.</li><li>Inline: This technique will focus on simplifying the code by removing unnecessary elements.</li></ul><h3>Benefits of Refactoring</h3><p>The main benefit of refactoring is removing code smells to reduce technical debt. Clean code is easier to read, both for the coder and other developers who may work on it in the future, making it easier to maintain and add features in the future. Less complex code can also improve source code maintainability, making the internal architecture more expressive.</p><p>Here are some more specific uses and benefits of refactoring:</p><ul><li>Improving Code Quality: Refactoring helps eliminate unnecessary code, reduce code duplication, and make code cleaner and easier to understand.</li><li>Reduces Bug Fixing pressure: By identifying and fixing structural issues in the code, refactoring can help prevent more serious bugs and errors.</li><li>Reduces Change Overhead: Cleaner, well-structured code is easier to modify, reducing the time and effort required for changes.</li><li>Improves Team Productivity: Teams working with clean and understandable code can work more efficiently and effectively.</li><li>Improves Code Understanding: Refactoring makes code easier to understand, both for the current team and for future teams that may work on the same project.</li></ul><h3>Difficulties that may be faced while refactoring</h3><ul><li>Lost Time: Refactoring takes time and resources, and it can sometimes be challenging to convince stakeholders that it is a worthwhile investment.</li><li>Risk of New Bugs: When refactoring code, there is a risk of new bugs emerging. To prevent this from happening, developers need to do good and thorough testing.</li><li>Understanding Existing Code: Sometimes the legacy code that needs to be refactored is not well-documented, so understanding its parts can be a challenge.</li></ul><h3>What Has Been Done regarding Refactoring</h3><p>A brief explanation of the layers used and their flow</p><ol><li>Model Layer: This layer contains definitions of data entities, such as database tables in Django. The model defines the data structure, relationships between entities, and data validation.</li><li>Serializer Layer: This layer is used to convert data, usually in JSON form, into Python objects that can be transferred via the API. This layer also serves to perform data validation</li><li>View Layer: This layer serves as a bridge between HTTP requests and application business logic. Usually this layer is used to define how HTTP requests will be handled, such as which HTTP methods will be used (GET, POST, PUT, DELETE) and how data will be retrieved, stored, or changed.</li><li>Service Layer: This is an additional layer that can be used to place more complex application business logic. This layer serves as a place to organize operations that involve several business models or transactions so that it helps keep the view lightweight and focused on tasks related to HTTP requests.</li><li>Repository Layer: A layer used to access or manipulate data in a data store (e.g., database) in isolation from business logic and views. This layer makes it possible to separate database operations from other layers, maintain clean code, and allow the replacement of data stores without affecting other layers.</li><li>DTO (Data Transfer Object) Layer: A layer that serves to define the objects used to transfer data between different parts of the application and manage the data to be displayed or received through the API.</li></ol><p>I did a refactoring called Layered Architecture with the aim of separating different responsibilities in the application. This will be useful in maintaining clean code, making it easy to manage, and improving scalability.</p><h4>At Views Layer</h4><p>I made changes to views.py where in the previous version the view directly accessed the database, but now I moved all the logic to the service layer and accessed or manipulated the data in the repository layer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*C1OVbbpVmy5uwy7dKZaTfg.png" /><figcaption>Code in views.py before refactoring</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*Owz-1F6u_DNRIKBEekqbAQ.png" /><figcaption>code in view.py after refactoring</figcaption></figure><h4>At the Service Layer</h4><p>I redefined the Log.Objects.all() and serializer.save methods in views.py that access the database directly in the service layer.</p><p>The findAllLogs() function is used to retrieve all log data from the data store (database) and return it in the form of a LogData object. The first step will call the repo.findAllLogs() function in the repository layer, which is responsible for retrieving all log data from the data store. Once the log data is retrieved, the service layer iterates through each log in the all_logs list received. For each log entity, the service layer creates a LogData object that describes the log data with the appropriate attributes. This LogData object is then inserted into the new_logs list, and eventually, the new_logs list contains all the log data that has been converted into LogData objects. The result is a LogData list that contains log data from the data store in a format that is easier for the views layer to use and understand.</p><p>The saveLog(data: LogData) function is used to save log data to the data store after receiving a LogData object from the views layer. This function creates a Logs object that conforms to Django’s model with values derived from the LogData object. Next, this function calls repo.saveLog(log) to save the Logs object to the data store (database) using the repository layer. After successful saving, the category and id objects in the LogData object received as parameters are also filled with the corresponding values from the Logs object that was just saved. Finally, the function returns an updated LogData object with the new category and id values.</p><pre>## Service.py<br><br>from .dto import LogData<br>from . import repository as repo<br>from typing import List<br>from .models import Logs<br><br><br>def findAllLogs() -&gt; List[LogData]:<br>    all_logs = repo.findAllLogs()<br>    new_logs = []<br>    for log in all_logs:<br>        new_log = LogData(<br>            course=log.course,<br>            semester=log.semester,<br>            year=log.year,<br>            dosen=log.dosen,<br>            mahasiswa=log.mahasiswa,<br>            datetime=log.datetime,<br>            start_time=log.start_time,<br>            end_time=log.end_time,<br>            duration=log.duration,<br>            category=log.category,<br>            description=log.description,<br>            status=log.status,<br>            operation=log.operation,<br>            honor_name=log.honor_name,<br>            id=log.id<br>        )<br>        new_logs.append(new_log)<br>    return new_logs<br><br>def saveLog(data: LogData) -&gt; LogData:<br>    log = Logs(<br>        course=data.course,<br>        semester=data.semester,<br>        year=data.year,<br>        dosen=data.dosen,<br>        mahasiswa=data.mahasiswa,<br>        datetime=data.datetime,<br>        start_time=data.start_time,<br>        end_time=data.end_time,<br>        duration=data.duration,<br>        category=data.category,<br>        description=data.description,<br>        status=data.status,<br>        operation=data.operation,<br>        honor_name=data.honor_name<br>    )<br>    repo.saveLog(log)<br>    data.category = log.category<br>    data.id = log.id<br>    return data</pre><h4>At the Repository Layer</h4><p>The repository.py file plays a role in providing functions to retrieve all existing log data in the database and to save new log data to it.</p><p>The findAllLogs() function is used to retrieve all log data from the Logs table in the database. Logs.objects.all() is a Django ORM method used to retrieve all rows (records) from the Logs table resulting in a collection of Logs model objects. This function returns a list of Logs objects, representing all the log data in the database.</p><p>The saveLog(log: Logs) function is used to save Logs objects to the Logs table in the database. log.save() is the method used to save Logs objects to the database using the Django ORM. This function does not return a value (None) because its main purpose is to save data to the database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*amTO58dU-VMrjbJxj_M1zw.png" /></figure><h4>At DTO Layer</h4><p>DTOs are used to combine data that will be sent or received by the views, service, or repository layers. In other words, it facilitates the transfer of data between layers without the need to reveal certain details of the data structure or application model. My DTO layer contains a Data Transfer Object (DTO) definition named LogData which is a data class with several attributes. In this case I use the <a href="http://twitter.com/dataclass">@dataclass</a> decorator to declare that LogData is a data class that will have these attributes as class attributes. Some attributes, such as duration and id, have an optional data type (Optional[int]) which means they can contain values or None.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*s-b5F_JNxXAFGzUiKulAXQ.png" /></figure><h3>Result</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pmFQUjXNa_5Ag-rE_HfCMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mIGLn0OVym9NKop-PwG2Ew.png" /></figure><p>I have successfully started the server, added logs, and displayed the previously created logs.</p><h3>Source</h3><ul><li><a href="https://www.techtarget.com/searchapparchitecture/definition/refactoring">What is Refactoring (Code Refactoring)?</a></li><li><a href="https://www.bmc.com/blogs/code-refactoring-explained/">What is Code Refactoring? How Refactoring Resolves Technical Debt</a></li><li><a href="https://www.geeksforgeeks.org/refactoring-introduction-and-its-techniques/">Refactoring - Introduction and Its Techniques - GeeksforGeeks</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f2422df4918" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Software Testing: Mock Testing]]></title>
            <link>https://medium.com/@david.christianto05/software-testing-mock-testing-76f572b58936?source=rss-df4cd0818f03------2</link>
            <guid isPermaLink="false">https://medium.com/p/76f572b58936</guid>
            <dc:creator><![CDATA[David Christianto]]></dc:creator>
            <pubDate>Wed, 11 Oct 2023 05:38:40 GMT</pubDate>
            <atom:updated>2023-10-11T05:40:56.467Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*uVzMRIqHK1u0OC96N__frg.jpeg" /><figcaption>Image source: <a href="https://www.indiamart.com/proddetail/online-mock-test-software-21795514612.html">https://www.indiamart.com/proddetail/online-mock-test-software-21795514612.html</a></figcaption></figure><h3>Introduction</h3><blockquote>Mocking Test is a technique or method used in testing within the scope of software testing by replacing the original object (dependent object) with a mock object. The mock object created can simulate the behavior of the dependent object that is temporarily replaced. Testing in mock testing focuses on the unit being tested without involving or depending on other units by isolating the object to be tested.</blockquote><blockquote>In Python, we can create mock tests using the library that has been provided, namely by importing the module “from unittest.mock import patch”. The patch() decorator is used to handle patching modules and class-level attributes in the test scope and sentinel to create unique objects.</blockquote><h3>The difference between “Mock Testing” and “Regular Testing”</h3><p>The main difference between mock testing and regular testing is that in mock testing, external resources will be replaced with fake objects so that testing will run faster, more consistently, and iteratively without having to interact with real resources. Whereas in regular tests, the tests carried out will usually pick up actual external resources, for example, calling objects or data in the database, which allows testing to be slow, inconsistent, and dependent on the external environment.</p><h3>Benefits of Using Mock Testing</h3><ul><li><strong><em>Controls the behavior of the code during testing:</em></strong></li></ul><p>For example, when testing to make an HTTP request to an external service, usually the test will only be executed to the extent that the service behaves as expected. Under certain conditions, temporary changes in the behavior of an external service can cause periodic failures in your test suite. Therefore, it’s better to test code in a controlled environment. In the context of the Django Rest Framework (DRF), mocking tests can be used to replace HTTP requests, database calls, or external service calls with fake objects.</p><p>This makes it possible to test business logic or API behavior without actually interacting with actual external resources. Replacing real requests with mock objects will make it possible to simulate external service outages and successful responses in a predictable way.</p><ul><li><strong><em>Speed of development and testing:</em></strong></li></ul><p>Mocking tests enable faster testing and efficient development. We can determine the source of failure and isolate the potential source of failure so that we can run unit tests without relying on external resources, thus enabling parallel testing. This will certainly speed up the overall software development process, which can be considered a key aspect of keeping developers interested in running tests and ensuring smooth development.</p><ul><li><strong><em>Iterative testing and reduced testing costs:</em></strong></li></ul><p>The mock objects created can be used to test a test scenario iteratively without having to rely on external resources, which sometimes require special preparation or complex configuration. And because it minimizes or even eliminates dependence on external resources, developers can reduce costs, especially in terms of using paid resources such as external web services or databases.</p><h3>Relationship between Mock Testing and Stubs</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*fA2lP_BswPnDzXwzuRMLzA.png" /><figcaption>Image source: <a href="https://medium.com/develaper/mock-dan-stub-63f488b11a2c">https://medium.com/develaper/mock-dan-stub-63f488b11a2c</a></figcaption></figure><p>A stub is a type of fake object that provides a static response. The stub usually has very simple behavior and usually only returns a certain value when called. The purpose of using a stub is to provide a predefined response to the unit being tested without involving complicated and complex operations or without examining the way the unit being tested interacts with other components.</p><p>According to the sources that I read (<a href="https://medium.com/develaper/mock-dan-stub-63f488b11a2c">https://medium.com/develaper/mock-dan-stub-63f488b11a2c</a>), the cycle difference between Mock testing and stub lies in the cycle that is owned, where in mock testing has a stage to determine expectations.</p><h4>Stages of Mock Testing</h4><p>Initialization --&gt; Set expectations --&gt; Practice -&gt; Verification.</p><h4>Stub Stages</h4><p>Initialization -&gt; Exercise -&gt; Verification</p><p>The relationship between mock testing and stubs is that mock objects can act as stubs in some situations. In this case, mock objects used in mock testing can function as stubs when they only return certain values and do not monitor how they are called.</p><h3>Application of Mock Testing on Projects</h3><p>I tried to apply the mock testing I learned to the code I created in test.py, where I used the “unittest.mock import patch” library provided by python.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*1XbBWJ5ybES5-dVfyYPEjw.png" /></figure><p>The code I created uses the <a href="http://twitter.com/patch">@patch</a> decorator, where <a href="http://twitter.com/patch">@patch</a>(‘log.models.LogCategory.objects.create’) and <a href="http://twitter.com/patch">@patch</a>(‘log.models.Logs.objects.create’) function to replace the create method of the LogCategory and Logs models with a mock object during testing. The code above will replace the create method of the LogCategory and Logs models with a mock object that returns an object. Then the code will make a POST request and will check the response to the previous request. And finally, the code will check the number of logs created, which results in an output of 0 because no actual object was created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*TkcHY3h7kmHje4wlwktsVw.png" /></figure><p>In my code, I used the decorator <a href="http://twitter.com/patch">@patch</a>(‘log.models.Logs.objects.get’) to replace the GET method of the Logs model with a mock object during testing. In the test case above, I specify an invalid id with a value of 999 that does not exist in the database and replace the GET method with a mock object that will return a Logs.DoesNotExist exception when called. Then the code will perform a GET request that will return invalid_id and will check to make sure the response has a 404 (Not Found) status code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*Ko4EkaYmX-3WsSsvUEtOog.png" /></figure><p>The code above uses the <a href="http://twitter.com/patch">@patch</a>(‘log.models.Logs.objects.update’) and <a href="http://twitter.com/patch">@patch</a>(‘log.models.Logs.objects.get’) decorators to replace the update and get methods of the Logs model with mock objects during testing. This will return a Logs.DoesNotExist exception when called, meaning that the log with the specified ID is not found in the database. In addition, the code will return a value of 0, indicating that no updates were made. Next, the code will make a request and check the response, which will return a 404 (Not Found) status code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*9KiCWrUVq3cH6D8XwVbO8Q.png" /></figure><p>In the code above I used the <a href="http://twitter.com/patch">@patch</a>(‘log.models.Logs.objects.update’) decorator to replace the update method of the Logs model with a mock object during testing. This code will return a value of 0, indicating that no changes have occurred. The next step is to make a PUT request and check the response, which will return a status code of 400 (bad request).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*iQkJ-i8NMgzI4a7x-23lPA.png" /></figure><p>In this code case, I used the <a href="http://twitter.com/patch">@patch</a>(‘log.models.Logs.objects.get’) decorator to replace the get method of the Logs model with a mock object during testing. First, I specify log_id with a value of 999, which is an ID that does not exist in the database, and then the replacement with a mock object will return Logs.DoesNotExist when called. Next is to make a request and check the response, which will return a 404 (Not Found) status code.</p><h3>Result</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*jPFhT-XAY7FgHObxGraEeQ.png" /></figure><p>I ran the command coverage run manage.py test on the CommandPrompt to execute the tests that I had made before, and the results of all existing tests including tests using mock testing were successful.</p><h3>Source</h3><p><a href="https://www.radview.com/glossary/what-is-mock-testing/#:~:text=Mock%20Testing%20provides%20you%20the,dependent%20objects%20with%20mock%20objects">https://www.radview.com/glossary/what-is-mock-testing/#:~:text=Mock%20Testing%20provides%20you%20the,dependent%20objects%20with%20mock%20objects</a>.</p><ul><li><a href="https://docs.python.org/3/library/unittest.mock.html">unittest.mock - mock object library</a></li><li><a href="https://realpython.com/python-mock-library/">Understanding the Python Mock Object Library - Real Python</a></li><li><a href="https://www.toptal.com/python/an-introduction-to-mocking-in-python">An Introduction to Mocking in Python | Toptal®</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76f572b58936" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[IR3: Sonarqube, Team Development Tools, and People Person]]></title>
            <link>https://medium.com/@david.christianto05/ir3-sonarqube-team-development-tools-and-people-person-99358c1376c6?source=rss-df4cd0818f03------2</link>
            <guid isPermaLink="false">https://medium.com/p/99358c1376c6</guid>
            <dc:creator><![CDATA[David Christianto]]></dc:creator>
            <pubDate>Mon, 02 Oct 2023 04:39:23 GMT</pubDate>
            <atom:updated>2023-10-02T04:39:23.821Z</atom:updated>
            <content:encoded><![CDATA[<h3>Sonarqube</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*_rJiB4NKt9Qjt8X6zJrCvA.png" /><figcaption>Image source: <a href="https://wiki.eclipse.org/SonarQube">https://wiki.eclipse.org/SonarQube</a></figcaption></figure><h4>Introduction</h4><p>Sonarqube is an open-source platform used for continuous inspection of code quality that collects metrics about the quality of the analyzed code and places them in a dashboard. In addition, Sonarqube provides several tips to help make code better by performing static analysis, namely by identifying code smells, code style violations, code duplication, displaying bug details in more detail, and displaying code coverage.</p><p>Sonarqube supports various programming languages such as Python, Java, C, C++, Kotlin, Go, etc. Some of the main features of the Sonar Cube include:</p><ul><li>Static code analysis: Sonarqube does not actively run code but rather analyzes the source code without running it. This allows Sonarqube to identify potential issues and rule violations that may be present in the code.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CfavhtDWTXRKq9wZ009Ptg.png" /></figure><ul><li>Code quality monitoring: Sonarqube provides a comprehensive view of a project’s code quality, which includes reports on discovered issues such as code smells and bugs as well as the level of compliance with coding standards.</li><li>Integration with various tools: As Sonarqube is an open-source platform, it can be integrated with Gitlab via commands in CI/CD or integrated with other tools such as the Version Control System (VCS) for version management.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qTjHu0SrWeOO_0JZ6YXMlA.png" /></figure><ul><li>Security Code Analysis: Sonarqube can indicate potential security issues in the integrated code; for example, there is an XSS (cross-site scripting) problem where a hacker inserts a malicious code script into a web page that can be seen by other users. Sonarqube will then notify you via the Security Hotspots feature and inform you of the risks involved and how to handle them.</li><li>Reports and Metrics: Sonarqube generates useful reports on code quality and security. It helps developers understand where improvements are needed and provides metrics to track changes in code quality over time.</li></ul><h4>What was implemented regarding Sonarqube</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0rV3r3zQEoC4cLq_BQSMyw.png" /></figure><ul><li>First, I used Sonarqube from CSUI. The first step I took was to integrate Sonarqube with GitLab.</li></ul><p>link Sonarqube CSUI: <a href="https://sonarqube.cs.ui.ac.id/projects">Projects (ui.ac.id)</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fl6-oN8juwbgFuTZXcUi0Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BDYboX0o0NQzAxZ5sUWi7w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9iDIlS5Y1-IQTb1TxBaRGg.png" /></figure><ul><li>Then, I chose the repository that I wanted to integrate. I also created a personal access token related to the repository.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*zMblbg5RGoea0xWfJcemAw.png" /></figure><ul><li>Next, I created a CI/CD command in.gitlab-ci.yml</li><li>Next, I created the sonar-projects.properties file as follows: (in this file, I write the host URL and source, including what is included and excluded related to the test that will be run later)</li></ul><pre># SonarScanner properties file<br>sonar.host.url=https://sonarqube.cs.ui.ac.id<br>## Project configuration<br>sonar.projectKey=ppl-fasilkom-ui_2023_ki-ganjil-2023-2024_group-1_back-end_drf-siasisten_AYrb9Y1v94kwVhMRxVkS<br>## Path to sources<br>sonar.sources=.<br>sonar.exclusions=**/migrations/*, manage.py<br>#sonar.inclusions=<br>## Path to tests<br>sonar.test.exclusions=helloworld/**/*,manage.py<br>sonar.test.inclusions=log<br>## Source encoding<br>sonar.sourceEncoding=UTF-8<br>## Branch analysis<br>## Python-specific configurations<br>sonar.python.coverage.reportPaths=coverage.xml</pre><ul><li>And after that, I tried to do a git push on my branch, but there was an error when the CI command was run in Gitlab. This is related to the command Dsonar.branch.name=$CI_COMMIT_REF_NAME, which if each branch is specified to show the code coverage, an error will occur.</li></ul><p>error message:</p><pre>$ sonar-scanner -Dsonar.login=$SONARQUBE_TOKEN -Dsonar.branch.name=$CI_COMMIT_REF_NAME -Dsonar.branch.target=staging<br>INFO: Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties<br>INFO: Project root configuration file: /builds/ppl-fasilkom-ui/2023/ki-ganjil-2023-2024/group-1/back-end/drf-siasisten/sonar-project.properties<br>INFO: SonarScanner 4.6.2.2472<br>INFO: Java 11.0.14 Alpine (64-bit)<br>INFO: Linux 5.15.0-79-generic amd64<br>INFO: User cache: /opt/sonar-scanner/.sonar/cache<br>INFO: Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties<br>INFO: Project root configuration file: /builds/ppl-fasilkom-ui/2023/ki-ganjil-2023-2024/group-1/back-end/drf-siasisten/sonar-project.properties<br>INFO: Analyzing on SonarQube server 8.9.2<br>INFO: Default locale: &quot;en_US&quot;, source code encoding: &quot;UTF-8&quot;<br>INFO: Load global settings<br>INFO: Load global settings (done) | time=203ms<br>INFO: Server id: FB4B1083-AXiyACNLHXLylbnb2KAB<br>INFO: User cache: /opt/sonar-scanner/.sonar/cache<br>INFO: Load/download plugins<br>INFO: Load plugins index<br>INFO: Load plugins index (done) | time=60ms<br>INFO: Load/download plugins (done) | time=3898ms<br>INFO: Process project properties<br>INFO: Process project properties (done) | time=9ms<br>INFO: Execute project builders<br>INFO: Execute project builders (done) | time=2ms<br>INFO: ------------------------------------------------------------------------<br>INFO: EXECUTION FAILURE<br>INFO: ------------------------------------------------------------------------<br>INFO: Total time: 7.222s<br>INFO: Final Memory: 6M/120M<br>INFO: ------------------------------------------------------------------------<br>ERROR: Error during SonarScanner execution<br>ERROR: Validation of project reactor failed:<br>  o To use the property &quot;sonar.branch.name&quot; and analyze branches, Developer Edition or above is required. See https://redirect.sonarsource.com/doc/branches.html for more information.<br>ERROR: <br>ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.<br>Cleaning up project directory and file based variables<br>00:01<br>ERROR: Job failed: exit code 1</pre><ul><li>So for now, I temporarily removed the command in CI and made the Gitlab pipeline work, but an important note is that Sonarqube CSUI can currently only refer to the main branch, so code coverage from other branches cannot be displayed before merging into the main branch.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*p8eIyoojFwxZaf2GFxV1Vg.png" /></figure><h4>Steps taken to resolve the error</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*aQm2l5tLcIySeEnmNpMSSA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yZfPQ1BF9VunOhUG_lQC6g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QwtZOzT4xEHx6xnsR6sRHQ.png" /></figure><p>I have contacted three teaching assistants regarding the error. I tried to request access using <a href="https://pmpl.cs.ui.ac.id/sonarqube">https://pmpl.cs.ui.ac.id/sonarqube</a> because through the information I got, pmpl can be used by specifying the branch name in Gitlab. However, the teaching assistants suggested using local code coverage first before pushing to main.</p><h4>Result</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hnLKcilqseKTK2NUijx7aQ.png" /></figure><p>The integration into Sonarqube itself has been successful, but in our group repository, we have not done a git push to the main branch, so now our group’s code coverage has not appeared on Sonarqube.</p><h3>Team Development Tools</h3><h4>Discord</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/285/1*Hhnz9nAmTEG0r14zLFAK8w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/309/1*ZT0ehsk36Xr-d7H29jaiew.png" /></figure><p>In this aspect, our group uses Discord as the main communication for the coding team. We usually get together on a voice call and discuss the problem at hand. We also do share screen to debug problematic code or just help with a task.</p><h4>Jira</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*9TouggaBN3Pw7WKQ7Pw1rQ.png" /><figcaption>Image source: <a href="https://jedangoding.com/mengetahui-lebih-jauh-tentang-jira-software-sebagai-perangkat-lunak-manajemen-proyek-populer">https://jedangoding.com/mengetahui-lebih-jauh-tentang-jira-software-sebagai-perangkat-lunak-manajemen-proyek-populer</a></figcaption></figure><p>We also use the Jira tool as support for our tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hSu8XEwCfLMhrszZFn3vnw.png" /></figure><p>In Jira, there are features such as a time line that are useful for showing the target time for completing sprint tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u_zg1VbiLnykMZADhUdn7Q.png" /></figure><p>Next is the backlog, where we break down the PBIs that have been created into smaller tasks and include details for code implementation. Not only that, we also use this feature to assign tasks to group members and determine the weight of the task. For determining the weight of the task itself we use planning poker (<a href="https://planningpokeronline.com/gTaygxvKE5gMjGw3CFlz/">https://planningpokeronline.com/gTaygxvKE5gMjGw3CFlz/</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DvZKvvDy47sX0QO1N0gTpA.png" /></figure><p>In addition, there is a board feature that can make it easier for each group member to know the extent of the work on a task from each member. This also makes it easier for the scrum master to control the scrum so that the scrum master and fellow group members can remind each other if there are pending tasks.</p><h4>Version Control System (VCS)</h4><p>Version control is a system used to track changes in source code or a collection of files over time. This VCS is commonly used by developers to check files on the server, make changes, and check the files again. The advantages of using VCS itself are quality (the team can review the code), acceleration (can branch and merge), and visibility. There are several types of VCS, namely</p><ul><li>A distributed version control system (DVCS) that allows users to access the repository from various locations.</li><li>A centralized version control system (CVCS) is a type of VCS where all users work with the same central repository. This central repository can be located on a server or on the developer’s local machine.</li><li>Lock-based: Lock-based version control systems use file locking to manage concurrent access to files and resources. File locking prevents two or more users from making conflicting changes to the same file or resource.</li><li>Optimistic: In an optimistic version control system, each user has their own private workspace. When they want to share their changes with other team members, they send a request to the server. The server then looks at all the changes and determines which changes can be safely merged.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5gw7P0y12p9dQ_qmgmiAQA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z0FvIshXQtvKBf8-jMu_eA.png" /></figure><p>What I do regarding this version control is use git commit, which will later be seen by other members regarding the commit history that I have done. Besides that, I also use the git log command to check my version control on my branch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gipvW8hakZKpTZvJ7xD-gw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ljfNH5qsGKIXW8b7LESTCg.jpeg" /></figure><p>I also do git stash to temporarily store (hide) the changes in my uncommitted working directory when trying to make test coverage 100% on local, and git stash apply to take the changes stored in the stash and apply them back to the directory without deleting the stash.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hR9zCVVLzpR-Q5EA4IEBOw.png" /></figure><p>Besides that, I also did a git reset — — hard (commit id in history) to restore and run my existing commit. I did this because there was a change in my group’s test database because one of my friends migrated to a different model. and the result is that my branch pipeline can return to green (success).</p><h3>People Person</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a8_7dO2m7sklI1laB3v81A.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ml8Jyk-jQoa06d-gQlQQEg.jpeg" /></figure><p>On this competency, around <em>Friday, September 29th 2023</em>, Jovian, Ghazian, and I went to visit one of our friends in the PPL class who was experiencing a disaster, namely Aldo. Aldo suffered a broken arm on his right hand. We visited Aldo to encourage him and to see his current condition after his surgery. We were happy because it turned out that the operation went well, and little by little, Aldo was able to start recovering and was able to start attending college. In addition, we also told him the latest news about assignments and other information about lectures. In addition, because Aldo took care of the group 2 database, which had been successful, I also coordinated so that the database for our group test could be successful. During the visit, we also worked together on tasks related to people, namely managing merge requests and merge conflicts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99358c1376c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[IR 2: TDD, Development (OOP and SOLID Principles) and Teamwork]]></title>
            <link>https://medium.com/@david.christianto05/ir-2-tdd-development-oop-and-solid-principles-and-teamwork-fdfbde22a6c3?source=rss-df4cd0818f03------2</link>
            <guid isPermaLink="false">https://medium.com/p/fdfbde22a6c3</guid>
            <dc:creator><![CDATA[David Christianto]]></dc:creator>
            <pubDate>Mon, 25 Sep 2023 05:17:14 GMT</pubDate>
            <atom:updated>2023-09-25T05:17:14.255Z</atom:updated>
            <content:encoded><![CDATA[<h3>Test-Driven Development (TDD)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*jFw7ZZMoVcsEYM_fS33DBA.gif" /><figcaption>Image Source: <a href="https://medium.com/@rinae/tdd-test-driven-development-%EB%A5%BC-%EC%97%B0%EC%8A%B5%ED%95%98%EB%A9%B4%EC%84%9C-%EC%B0%B8%EA%B3%A0%ED%95%98%EA%B8%B0-%EC%A2%8B%EC%9D%80-%ED%8C%81-10%EA%B0%80%EC%A7%80-d8cf46ae1806">https://medium.com/@rinae/tdd-test-driven-development-%EB%A5%BC-%EC%97%B0%EC%8A%B5%ED%95%98%EB%A9%B4%EC%84%9C-%EC%B0%B8%EA%B3%A0%ED%95%98%EA%B8%B0-%EC%A2%8B%EC%9D%80-%ED%8C%81-10%EA%B0%80%EC%A7%80-d8cf46ae1806</a></figcaption></figure><h4>Introduction</h4><p>Test-driven development, commonly known as TDD, is a software development process in which the development team creates unit tests first before creating a program. Of course, the test must fail first, so make sure we include all the possibilities that can be thought of for the input and output of the test. TDD consists of 3 main stages, namely: writing tests (test first), writing code (code next), and refactoring code (refactoring). TDD itself is an application of the concepts of Agile and Extreme programming, where the application of TDD is useful for ensuring that the application made is running according to the requirements and is able to handle various cases (reducing bugs in the program).</p><h4>Steps in implementing TDD</h4><ol><li>Writing Tests (Test First): The development team writes unit tests first that will test the functions or components to be created before coding. In creating this test, make sure to include all possibilities that can be thought of as input and output of the unit test, so that the code created can handle all possible errors. This test usually fails at first because the function or component does not yet exist.</li><li>Writing Code (Code Next): After the test is run and fails, the development team will write code based on the error message received. Writing this code aims to make the previous failed test successful (until the working code meets the expectations of the test created).</li><li>Refactor Code (Refactor): After the code successfully meets the expectations of the test, the developer can refactor the code created if he feels that the code is messy. This ensures that the code remains clean and efficient, as well as easy to read and understand.</li></ol><h4>What is done related to TDD in Tasks on Sprint</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fG9EmzDukgMLzNwKhHR6MA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rCTxXczXZzV1BeIDrSaGKg.png" /></figure><p>In this sprint, I got the task of creating create_log and update_log functions on the backend. First, I created a LogAPITestcase class to isolate each test into a different method, which makes each test method independent of the initial conditions of the test method. Next, I thought of possible cases that could occur in the create and update log functions and ran the test by failing first because it didn’t have a function yet in views.py.</p><p>Here is the code in my test.py</p><pre>from django.test import TestCase<br>from rest_framework.test import APIClient<br>from rest_framework import status<br>from django.urls import reverse<br>from .models import Logs<br>from .serializer import LogsSerializer<br>from rest_framework.test import APITestCase<br><br>class LogsAPITestCase(TestCase):<br><br>    def setUp(self):<br>        self.client = APIClient()<br><br>    def test_create_log(self):<br>        # Define the data you want to send in the POST request<br>        data = {<br>            &quot;course&quot;: &quot;Example Course&quot;,<br>            &quot;semester&quot;: &quot;Spring&quot;,<br>            &quot;year&quot;: 2023,<br>            &quot;dosen&quot;: &quot;John Doe&quot;,<br>            &quot;mahasiswa&quot;: &quot;Alice&quot;,<br>            &quot;category&quot;: &quot;Category&quot;,<br>            &quot;description&quot;: &quot;Log description&quot;,<br>            &quot;status&quot;: &quot;Status&quot;,<br>            &quot;operation&quot;: &quot;Operation&quot;,<br>            &quot;honor_name&quot;: &quot;Honor Name&quot;<br>        }<br><br>        # Get the URL for the create-log endpoint<br>        url = reverse(&#39;logs-list&#39;)<br><br>        # Send a POST request to create the log<br>        response = self.client.post(url, data, format=&#39;json&#39;)<br><br>        # Check if the request was successful (status code 201)<br>        self.assertEqual(response.status_code, status.HTTP_201_CREATED)<br><br>        # Check if the log was created in the database<br>        self.assertEqual(Logs.objects.count(), 1)<br><br>        # Check if the log attributes match the data sent in the request<br>        log = Logs.objects.get()<br>        self.assertEqual(log.course, data[&#39;course&#39;])<br>        # Add more assertions for other attributes as needed<br><br>    def test_update_log(self):<br>        # Create a log object to update<br>        log_data = {<br>            &quot;course&quot;: &quot;Example Course&quot;,<br>            &quot;semester&quot;: &quot;Spring&quot;,<br>            &quot;year&quot;: 2023,<br>            &quot;dosen&quot;: &quot;John Doe&quot;,<br>            &quot;mahasiswa&quot;: &quot;Alice&quot;,<br>            &quot;category&quot;: &quot;Category&quot;,<br>            &quot;description&quot;: &quot;Log description&quot;,<br>            &quot;status&quot;: &quot;Status&quot;,<br>            &quot;operation&quot;: &quot;Operation&quot;,<br>            &quot;honor_name&quot;: &quot;Honor Name&quot;<br>        }<br>        log = Logs.objects.create(**log_data)<br><br>        # Define the data you want to send in the PUT request for update<br>        updated_data = {<br>            &quot;course&quot;: &quot;Updated Course&quot;,<br>            &quot;semester&quot;: &quot;Updated Semester&quot;,<br>            &quot;year&quot;: 2024,<br>            &quot;dosen&quot;: &quot;Updated Dosen&quot;,<br>            &quot;mahasiswa&quot;: &quot;Updated Mahasiswa&quot;,<br>            &quot;category&quot;: &quot;Updated Category&quot;,<br>            &quot;description&quot;: &quot;Updated Description&quot;,<br>            &quot;status&quot;: &quot;Updated Status&quot;,<br>            &quot;operation&quot;: &quot;Updated Operation&quot;,<br>            &quot;honor_name&quot;: &quot;Updated Honor Name&quot;<br>        }<br><br>        # Get the URL for the update-log endpoint (replace {pk} with the log&#39;s primary key)<br>        url = reverse(&#39;log-detail&#39;, args=[log.pk])<br><br>        # Send a PUT request to update the log<br>        response = self.client.put(url, updated_data, format=&#39;json&#39;)<br><br>        # Check if the request was successful (status code 200)<br>        self.assertEqual(response.status_code, status.HTTP_200_OK)<br><br>        # Refresh the log object from the database<br>        log.refresh_from_db()<br><br>        # Check if the log attributes match the updated data sent in the request<br>        self.assertEqual(log.course, updated_data[&#39;course&#39;])<br>        self.assertEqual(log.semester, updated_data[&#39;semester&#39;])<br>        self.assertEqual(log.year, updated_data[&#39;year&#39;])<br>        self.assertEqual(log.dosen, updated_data[&#39;dosen&#39;])<br>        self.assertEqual(log.mahasiswa, updated_data[&#39;mahasiswa&#39;])<br>        self.assertEqual(log.category, updated_data[&#39;category&#39;])<br>        self.assertEqual(log.description, updated_data[&#39;description&#39;])<br>        self.assertEqual(log.status, updated_data[&#39;status&#39;])<br>        self.assertEqual(log.operation, updated_data[&#39;operation&#39;])<br>        self.assertEqual(log.honor_name, updated_data[&#39;honor_name&#39;])<br><br>    def tearDown(self):<br>        # Clean up any objects created during the test (if necessary)<br>        Logs.objects.all().delete()</pre><p>In the create log case, I created a test to test the endpoint’s ability to create a new log entry in the database via the POST method. The system checks if the POST request will return a 201 code (HTTP_CREATED), indicating that the log was successfully created. Successfully created logs in the database are checked by counting the number of log objects before and after the test.</p><p>In the case of log updates, I created a test to examine the endpoint’s ability to update an existing log entry in the database via the PUT method. If it successfully updates an existing log in the database, the PUT request returns a status code of 200 (HTTP_OK), indicating that the update was successful.</p><pre>from django.shortcuts import render<br>from .models import Logs<br>from .serializer import LogsSerializer<br>from rest_framework import status<br>from rest_framework.decorators import api_view<br>from rest_framework.views import APIView<br>from . models import *<br>from rest_framework.response import Response<br>import json<br><br>class LogsView(APIView):<br>     <br>    def post(self, request):<br>        serializer = LogsSerializer(data=request.data)<br>        if serializer.is_valid():<br>            serializer.save()<br>            return Response(serializer.data, status=status.HTTP_201_CREATED)<br>        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)<br><br>    def get(self, request, pk=None):<br>        if pk is not None:<br>            log = Logs.objects.filter(pk=pk).first()<br>            if log is None:<br>                return Response({&quot;message&quot;: &quot;Log not found&quot;}, status=status.HTTP_404_NOT_FOUND)<br>            serializer = LogsSerializer(log)<br>            return Response(serializer.data)<br>        <br>        logs = Logs.objects.all()<br>        serializer = LogsSerializer(logs, many=True)<br>        return Response(serializer.data)<br><br>    def put(self, request, pk):<br>        try:<br>            log = Logs.objects.get(pk=pk)<br>        except Logs.DoesNotExist:<br>            return Response({&quot;message&quot;: &quot;Log not found&quot;}, status=status.HTTP_404_NOT_FOUND)<br><br>        request_data = request.data<br>        print(&quot;Received PUT data:&quot;, json.dumps(request_data, indent=4))<br><br>        serializer = LogsSerializer(log, data=request_data)<br>        if serializer.is_valid():<br>            serializer.save()<br>            return Response(serializer.data, status=status.HTTP_200_OK)<br>        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)<br>    def delete(self, request):<br>        None</pre><p>And after creating the test, I created a function in views.py that matches the existing test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nC42LP-U079s9RKlss_W0Q.png" /></figure><p>Through Command Prompt, I again ran the python manage.py test command, and it returned an OK status. So in this aspect, I have learned about TDD and its implementation and successfully implemented it up to the stage where the tests run successfully.</p><h3>Development (SOLID Principle and OOP)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Xxe_AazjPY3tny9aCb1oDQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*zlffjyR8TINzJ2D1CNSkng.jpeg" /></figure><h4>Introduction OOP</h4><p>Object-oriented programming, commonly called OOP, is an object-oriented programming method. The purpose of using OOP is to help developers organize their code in the form of objects that represent entities or concepts that already exist in the real world.</p><p>OOP itself has four basic principles, namely</p><ol><li>Encapsulation: This is the concept of packaging or binding interconnected attributes (variables) and methods (functions) into classes. The class itself can be analogized as a template or blueprint for existing objects. The purpose of using encapsulation is to make it easier to read the code because the internal implementation details of the object are not displayed.</li><li>Inheritance: This is a concept of OOP that allows inheritance of properties and methods from other classes. Through this concept, we recognize the existence of superclasses and sub-classes, where the subclass will inherit the properties of the superclass. This concept itself implements a hierarchical system, which, in addition to allowing for code reuse, has an impact on the further down the sub-class is, the less similar its functions are.</li><li>Abstraction: Is a concept that allows developers to command a function without having to know exactly how the function works. This hides the implementation details and exposes only the important features of the object.</li><li>Polymorphism: Is a concept where objects of different classes can be accessed through the same interface. It allows the use of methods with the same name on objects of different classes with behavior appropriate to that class.</li></ol><h4>Introduction to the SOLID Principle</h4><p>The SOLID Principle stands for five software design principles proposed by Robert C. Martin. The goal of the SOLID principle is to help developers create code that is easy to read and understand, as well as easy to manage.</p><p>Five principles of the SOLID principle</p><ol><li>Single Responsibility Principle (SRP): This principle states that every class should have a single, clearly defined responsibility, or in other words, only have one job, so that a class only has one reason to change. To clarify this principle, it can be seen that only one potential change (database logic, logging logic, etc.) in the software specification can affect the class specification.</li><li>Open/Closed Principle (OCP): This principle says that software entities (e.g., classes or modules) should be open for extension but closed for modification. Modification means changing the code of an existing class, and extension means adding new functionality. This can be achieved by applying polymorphism and abstraction.</li><li>Liskov Substitution Principle (LSP): This principle states that an object of a subclass should be able to be used as a substitute for an object of a superclass without affecting the correctness of the program. Supposing we have two classes, namely class A and class B, If class B is a subclass of class A, then the object of class B must be able to be passed to any method that expects an object from class A and does not raise an error.</li><li>Interface Segregation Principle (ISP): This principle states that clients should not be forced to implement unused methods. This principle encourages the creation of specific and separate interfaces for each client.</li><li>Dependency Inversion Principle (DIP): This principle expresses that high-level modules should not depend on low-level modules, where modules should depend on interfaces or abstract classes.</li></ol><h4>What Is Done in Terms of OOP and SOLID Principle Related to The Task Taken</h4><pre>## views.py<br>class LogsView(APIView):<br>     <br>    def post(self, request):<br>        serializer = LogsSerializer(data=request.data)<br>        if serializer.is_valid():<br>            serializer.save()<br>            return Response(serializer.data, status=status.HTTP_201_CREATED)<br>        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)<br><br>    def get(self, request, pk=None):  # Tambahkan parameter pk dengan default None<br>        if pk is not None:<br>            log = Logs.objects.filter(pk=pk).first()<br>            if log is None:<br>                return Response({&quot;message&quot;: &quot;Log not found&quot;}, status=status.HTTP_404_NOT_FOUND)<br>            serializer = LogsSerializer(log)<br>            return Response(serializer.data)<br>        <br>        logs = Logs.objects.all()<br>        serializer = LogsSerializer(logs, many=True)<br>        return Response(serializer.data)<br><br>    def put(self, request, pk):<br>        try:<br>            log = Logs.objects.get(pk=pk)<br>        except Logs.DoesNotExist:<br>            return Response({&quot;message&quot;: &quot;Log not found&quot;}, status=status.HTTP_404_NOT_FOUND)<br><br>        request_data = request.data<br>        print(&quot;Received PUT data:&quot;, json.dumps(request_data, indent=4))<br><br>        serializer = LogsSerializer(log, data=request_data)<br>        if serializer.is_valid():<br>            serializer.save()<br>            return Response(serializer.data, status=status.HTTP_200_OK)<br>        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)<br>    def delete(self, request):<br>        None<br><br><br>## serializer.py<br><br>class LogsSerializer(serializers.ModelSerializer):<br>    class Meta:<br>        model = Logs<br>        fields = &#39;__all__&#39;</pre><ul><li>Apply the concept of OOP by creating the LogsView class and LogsSerializer class.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*yK8ekEIMBDmQ8hk64_JlbA.png" /></figure><ul><li>Implementing encapsulation by using a serializer to encapsulate logic about data processing (converting JSON data into readable python objects), that hides the implementation details of how data is serialized and stored.</li><li>Implementing Inherintance. Through some of the Django Rest Framework-related resources I’ve read and understood, an example of applying the concept of inheritance to my code is using the APIView class as a superclass in my logsView class. In the DRF itself, APIView is a class that provides basic functionality for creating API views. So with the inheritance from APIViews, the LogsView class that I created can access the get, post, put, and delete methods.</li><li>Polymorphism: I defined various methods like put, get, post, and delete in the LogsView class. This allows uniform method invocation based on the HTTP request type despite having the same name (defining four methods with the same name as methods recognized by DRF to handle different HTTP request types).</li></ul><p><strong><em>Related SOLID Principles</em></strong></p><ul><li>Single Responsibility Principle (SRP): The LogsView class I created basically has one responsibility, which is to handle log-related requests. Defining methods like post and put only narrows the scope of the task being performed.</li><li>Open/Closed Principle (OCP): The code I created is open for expansion, mainly due to the use of the APIView class and overridable method definitions.</li><li>Liskov Substitution Principle (LSP): In LogsAPITestCase, you create a log object and use it according to the contract defined by the Logs class.</li></ul><h3>Screenshot of successful program run</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J_L3JZKEkmm_9H-cuzSwFg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X-rcYkle8wH0GJenWVZYHA.png" /></figure><h3>Teamwork</h3><p>Teamwork:</p><p>In the aspect of teamwork, my groupmates and I agreed to take on tasks according to our respective abilities. In addition, we used various tools that could support coordination within the group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/309/1*ZT0ehsk36Xr-d7H29jaiew.png" /></figure><ul><li>Use of discord for discussion and daily meetings: Group 1 used discord as a means of communication, where we had group discussions and also accessed any resources or announcements through the app. In addition, we also hold daily meetings that have been agreed upon through the Discord app via the voice channel feature. Usually, at these meetings, we each report what has been done and what obstacles have been encountered during the work.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jsiKZsvWc9z8V66DpDGVnQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NtYLFnsd0HroKhYUEaGSwA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yWwV0fPF7BGzh-dQZuswgw.png" /></figure><ul><li>Use of Jira: Group 1 also uses Jira tools in detailing a backlog, and assigning a backlog is done through Jira. Furthermore, Jira is also used in creating a backlog timeline and using the board feature to track the status of the task.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gtJfW8ToIKvI8VILwqtu3w.png" /></figure><ul><li>commit message: I also apply the commit message in accordance with the wiki guidelines, where I clearly include the flag of a commit and other information that makes it easy to identify the task.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fdfbde22a6c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tasks Handled during Pre-Sprint: PRD, little Part on SDS, PBI]]></title>
            <link>https://medium.com/@david.christianto05/tasks-handled-during-pre-sprint-prd-little-part-on-sds-pbi-b0810ebc0264?source=rss-df4cd0818f03------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0810ebc0264</guid>
            <dc:creator><![CDATA[David Christianto]]></dc:creator>
            <pubDate>Wed, 20 Sep 2023 05:27:21 GMT</pubDate>
            <atom:updated>2023-09-20T05:27:21.077Z</atom:updated>
            <content:encoded><![CDATA[<p>In the last pre-sprint, we were divided into smaller groups of two. My friend Jovian and I handled PBI, PRD, a small part of SDS, and the Backend server. As well as offline meetings in class, my group and I worked together on Persona, where we discussed what characters and needs we should have as our characters to see the various needs from various perspectives. And the finishing and editing for Persona were done by Amar and Fiqo’s group.</p><h3>PBI (Product Backlog)</h3><p>link:</p><p><a href="https://docs.google.com/spreadsheets/d/1PunCzlNs-LA2_atIQZZcJ3cKXezhQDnBzYQBs4TrVFM/edit#gid=0">Group1-PBI</a></p><h4>Preview:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jvZm21BP-SMT_SvZiO80Kg.png" /></figure><blockquote>At this stage, Jovian and I made a list of the modules that our group was working on and noted all the features that were needed. After the creation, we made a presentation in front of the Stakeholder (Miss Aruni) regarding the backlog, whether it was appropriate or not. And we also made revisions related to some features according to Stakeholder requests. Then I also coordinated with the finance department (Miss Afifa) regarding several related backlogs so that all product backlogs listed were approved.</blockquote><h3>PRD (Product Requirements Documents)</h3><p>link:</p><p><a href="https://docs.google.com/document/d/1jH0h2e4or07O0uMFlQg6_1jWHPOtOwGL/edit">Group1-PRD.docx — Google Dokumen</a></p><h4>Preview:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*nnvvXq2SUn-7ax14C02t4A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*wRXh5ZrnFpDdjcy-kr2luQ.png" /></figure><p>In working on this PRD, I made objective goals, a rough description of the features to be implemented in each sprint, and also defined in detail the related features based on PBI. I also created about 20 diagrams as user flow design, this will provide an overview of how each feature is executed so that users understand what to do according to their role. In addition, Jovian and I created indicators and an analysis of the drinking requirements that must be achieved (point 5). And we also discussed what features can be added or developed in the SiaSisten application in the future.</p><h3>SDS (<strong>System Design Specification)</strong></h3><p>link:</p><p><a href="https://docs.google.com/document/d/1fDSM3FFwqBxZTxP3v7sBBxinkkjPgpYs/edit">sds ppl 2023.docx — Google Dokumen</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*tuosaBcHwL8XA25McwMu3g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*4bOs8hPkrPf_RnWT5CEqJg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*Ag1sy_fBAL-j7QgzqsVonA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*kg9pjzbIKTXQxJCNqfyNew.png" /></figure><blockquote>In SDS, Jovian and I worked on the Data section where we answered how to migrate data and what can be done regarding privacy policies for those who gain access to the database.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0810ebc0264" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>