<?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 Rico Tadjudin on Medium]]></title>
        <description><![CDATA[Stories by Rico Tadjudin on Medium]]></description>
        <link>https://medium.com/@rico098098?source=rss-c08d5dd215f5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qsmIQ7eKSsjfnjDtUVSqXA.jpeg</url>
            <title>Stories by Rico Tadjudin on Medium</title>
            <link>https://medium.com/@rico098098?source=rss-c08d5dd215f5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 18:56:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rico098098/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[Deploy Your Django Project]]></title>
            <link>https://medium.com/@rico098098/deploy-your-django-project-a89fd7d478b4?source=rss-c08d5dd215f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/a89fd7d478b4</guid>
            <category><![CDATA[django]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[ppl2022]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[heroku]]></category>
            <dc:creator><![CDATA[Rico Tadjudin]]></dc:creator>
            <pubDate>Wed, 15 Jun 2022 17:27:16 GMT</pubDate>
            <atom:updated>2022-06-17T07:44:52.118Z</atom:updated>
            <content:encoded><![CDATA[<p>Deploying your Django project to Heroku with continuous integration and continuous deployment</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EmsBpvVnEw-hKHQW.png" /><figcaption>Source: <a href="https://www.djangoproject.com/s/img/logos/django-logo-positive.png">https://www.djangoproject.com/s/img/logos/django-logo-positive.png</a></figcaption></figure><blockquote>This article is written for the purposes of an individual review for CSUI’s Software Engineering Project Course 2022.</blockquote><h3>Introduction</h3><p>After working hard for a few months, you finally finished your first Django project! It’s beautifully made with a lot of thought put into every page and every element. But, you can only open it in your local machine, probably at http://localhost:8000. If it’s like this, you won’t be able to brag about it to your friends without your laptop! What travesty!! 😤</p><p>😄 Of course it’s not about bragging, but really, how can you deploy your Django project into a real server that can be accessed by others? In this article I’ll explain how with Gitlab and Heroku using a CI/CD pipeline.</p><p><strong>Note</strong>: to prevent this article from being too long, I’ll assume that you already know the basics of Django and Git, and also you’ve already finished your Django project and are using Gitlab as the file repository for your project. If you use Github, it should be similar with these steps, but of course it needs a few adjustments.</p><h3>1. Setting Up Heroku</h3><p>First of, you will need to register (if you haven’t) to Heroku <a href="https://signup.heroku.com/">here</a>. After registering, you will need to go to <strong>Dashboard </strong>and then <strong>New</strong> &gt; <strong>Create New App</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JJkaWLhHQ0JRrLWSeqQC9w.png" /></figure><p>Then choose a name for the app and the region of the server. The name of the app will determine the domain name of your website. So for example, if I put example into the name of the app, then later I can access my website on example.herokuapp.com. Then click create app.</p><p>After that, you can go to the <strong>Settings </strong>tab, then go to the <strong>Convig Vars</strong> section and click the <strong>Reveal Convig Vars</strong> button. In there, add a variable named HEROKU_APP_NAME which is the name of your Heroku app you filled before (in my case example098). Then, add a variable named SECRET_KEY with a value of a key generated by the <a href="https://djecrety.ir/">Djecrety</a> site.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5CljQUzDsi_EzkRQDG7kLw.png" /></figure><p>The last thing we need from Heroku is your Heroku account API key. This is needed so that Gitlab can deploy your Django project to your Heroku App. This API key can be found in your <a href="https://dashboard.heroku.com/account">Heroku account settings</a> in the “API Key” section. Save it now for later use, but be careful to not leak this API key to anyone or anywhere.</p><p>With this, we’re done setting up Heroku.</p><h3>2. Setting Up Gitlab for Deployment to Heroku</h3><p>In Gitlab repository of your Django project, go to <strong>Settings &gt; CI/CD </strong>in the left side-bar. Then go to the <strong>Variables</strong> section. In there, add a variable named HEROKU_API_KEY and add your Heroku API Key as the value. Then, add another variable named HEROKU_APP_NAME which will have your Heroku app’s name (for me it’s example098).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eGcVOPF4DV3OMKEvQhsbYA.png" /></figure><h3>3. Making a .gitlab-ci.yml for CI/CD</h3><p>Now this is the most crucial (and probably the most excruciating) part of deploying with a CI/CD pipeline, making the .gitlab-ci.yml file as the YAML file where you configure specific instructions for GitLab CI/CD.</p><p>Here’s a really simple .gitlab-ci.yml file to deploy your Django project to Heroku:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ddc11b65def2c9d490ca668c2756f000/href">https://medium.com/media/ddc11b65def2c9d490ca668c2756f000/href</a></iframe><p>You can see that there are only one stage, that is deploy. By this line,</p><pre>rules:<br>    - if: &#39;$CI_COMMIT_REF_NAME == &quot;master&quot;&#39;</pre><p>the stage deploy will only be run when you commit and push to the ‘master’ branch. You can change this as you needed, for example if your main branch is named ‘main’.</p><p>Then, before we run the script, we will run these commands:</p><pre>before_script:<br>    - gem install dpl<br>    - wget -qO- <a href="https://cli-assets.heroku.com/install-ubuntu.sh">https://cli-assets.heroku.com/install-ubuntu.sh</a> | sh</pre><p>The first line of code will install <a href="https://github.com/travis-ci/dpl">dpl</a> which is a deploy tool made for continuous deployment that’s developed by Travis CI, but can also be used with GitLab CI/CD. The second line is getting a script from Heroku for installing Heroku in ubuntu (you can see the script <a href="https://cli-assets.heroku.com/install-ubuntu.sh">here</a>).</p><p>After that, in the script section, you’ll see this:</p><pre>script:<br>    - dpl --provider=heroku --app=$HEROKU_APP_NAME --api-key=$HEROKU_API_KEY<br>    - heroku run --app $HEROKU_APP_NAME migrate</pre><p>The first line is to use dpl which we already installed to deploy the Django project to Heroku. We need to specify heroku as provider, specify api_key and specify the app . Because we already setup all the variables needed in Gitlab on point 2, you could just copy and paste the code above and it’s all good! For the second line, it’s to tell heroku to run migrate. This is because dpl doesn’t run migrate on your Django migrations.</p><p>Put this .gitlab-ci.yml file in your project folder and push your code to your Gitlab repository. After that, you can check the <strong>Pipelines</strong> on your Gitlab project. If all is done correctly, then your Django project will be successfully deployed to Heroku and can be accessed in HEROKU_APP_NAME.herokuapp.com. (for example mine isexample098.herokuapp.com )</p><h3>4. (Additional) Adding Automated Unit Testing and Coverage to CI/CD</h3><p>To add automated unit testing and coverage report to CI/CD, you will need to add more code to your .gitlab-ci.yml file as follows.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b584a6c2518b6866c6fbb7d687f5fab4/href">https://medium.com/media/b584a6c2518b6866c6fbb7d687f5fab4/href</a></iframe><p>Of course you will need to make the unit tests yourself in your project files. After you update the yml file, you will see a Unit Test section in your pipeline.</p><p>If you want Gitlab to know the coverage that was the output from a pipeline job, you will need this line of code in the .yml for UnitTest:</p><pre>coverage: &#39;/^TOTAL.*\s+(\d+\%)$/&#39;</pre><h3>Conclusion</h3><p>With that, now you know how to deploy your Django project to Heroku with Gitlab and using a CI/CD pipeline. This is essential for web developers to know how to deploy your application, not just make/write it.</p><h3>References and Resources</h3><ul><li><a href="https://docs.gitlab.com/ee/ci/quick_start/">Tutorial: Create and run your first GitLab CI/CD pipeline | GitLab</a></li><li><a href="https://docs.gitlab.com/ee/ci/examples/deployment/">Using Dpl as a deployment tool | GitLab</a></li><li><a href="https://docs.gitlab.com/ee/ci/caching/">Caching in GitLab CI/CD | GitLab</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a89fd7d478b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Load Testing with Python]]></title>
            <link>https://medium.com/@rico098098/load-testing-with-python-fea13369af43?source=rss-c08d5dd215f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/fea13369af43</guid>
            <category><![CDATA[ppl2022]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[load-testing]]></category>
            <dc:creator><![CDATA[Rico Tadjudin]]></dc:creator>
            <pubDate>Wed, 15 Jun 2022 15:20:50 GMT</pubDate>
            <atom:updated>2022-06-15T15:26:25.846Z</atom:updated>
            <content:encoded><![CDATA[<p>Test your website’s capability with Python</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9qf0dZ5H625TaHX4" /><figcaption>Photo by <a href="https://unsplash.com/@odiin?utm_source=medium&amp;utm_medium=referral">Erik Odiin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote><em>This article is written for the purposes of an individual review for CSUI’s Software Engineering Project Course 2022.</em></blockquote><h3>Introduction</h3><p>Once before, I’ve been tasked to make a simple website for a committee in my university. This simple website consists of a few static pages and some pages that showcase submitted photos, videos, and such. The thing is, I’ve been told that at one point in the future, there will be a lot of people who will be directed to this website. To be exact, it’s around 1000 users at the same time accessing the website. The unexperienced me was reasonably panicked. Will the server that is going to host the website be enough for 1000 consecutive users? How should I know that?</p><p>In the end, I did what I had to do. I bought a mid-tier hosting service from a hosting provider (which wasn’t cheap 😭) because I didn’t know any better. Of course in hindsight, I’ve messed up real bad. I could’ve used cheaper alternatives like using Google Cloud Platform’s virtual machines, AWS, or even picking more affordable hosting services from those hosting providers. So, how can I know my server’s (and my application’s) capability of serving X amount of requests? <strong>The answer to that is doing a load test on your website.</strong></p><h3>Contents</h3><ol><li>Types of Load Testing</li><li>Load Testing with Python</li></ol><h3>1. Types of Load Testing</h3><p>Besides finding out our server’s capability to handle requests, load testing is also used to measure your website’s quality of service performance, like finding out if there are errors popping up after some load of requests, or if the response time is too long despite no failed requests, and many other useful things. With that in mind, there are 4 main types of performance load testing as follows.</p><h4>a. Load Testing</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*vylgyAgdatwOn0ZyXj8WpA.png" /><figcaption>Visualization of Load Testing</figcaption></figure><p>Load testing is used to determine how an application performs based on a <strong>certain volume of users</strong>. Usually the volume of users, the rate of increase (and decrease) of said users, and the time of the tests <strong>is given as needed by the tester</strong>.</p><h4>b. Stress Testing</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*dyrsK-uyeG0N7tDR0DuXSw.png" /><figcaption>Visualization of Stress Testing</figcaption></figure><p>Stress testing is very similar to load testing, except they are specifically designed to test the system’s performance with the <strong>maximum</strong> capacity of requests. This is done to determine at what point a system breaks down, and to verify that the system will be able to continue to work under such capacity.</p><h4>c. Endurance Testing</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*CtRQh9cGZX2fKTQ85KSNew.png" /><figcaption>Visualization of Endurance Testing</figcaption></figure><p>Endurance testing is a way to test your application with a typical load<strong> over a period of time (usually a long time) </strong>to determine the behavior and endurance of a system during normal use.</p><h4>d. Custom Performance Testing</h4><p>Of course the three types before this does not encapsulate every kind of performance testing. Other custom made performance testing can be made to mimic real-user behavior and gather data points like response time and latency. This can be done in any way required by you or the tester.</p><h3>2. Load Testing with Python</h3><p>For this article, I’ll be using a library for Python to do load testing, which is named <a href="https://pypi.org/project/locust/">Locust</a> and we’ll do the testing from our local computers. First of, we need to install Locust with pip. It’s recommended to install Locust in a virtual environment such as env, venv, or any other virtual environment.</p><p>To make a virtual environment (in this example venv), run this code in your command prompt in the folder which you want to work on.</p><pre>python -m venv venv</pre><p>Then, you need to activate the virtual environment.</p><pre># For windows<br>venv\Scripts\activate</pre><pre># For Mac/Linux<br>source venv/bin/activate</pre><p>If successful, (venv)will appear in your cmd/terminal prompt. (ps. if you want to deactivate the virtual environment, run deactivate on the terminal)</p><p>After you have activated the virtual environment, you will need to install Locust with pip by running:</p><pre>pip install locust</pre><p>After locust is installed, you will need to write a locust file inside that folder. Here’s a basic locust file to do a load test:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e2506e4b78bee83e303ce50b40e5ca1c/href">https://medium.com/media/e2506e4b78bee83e303ce50b40e5ca1c/href</a></iframe><p>So there are a few things that will need to be explained.</p><ul><li>wait_time</li></ul><p>wait_time is the amount of time the program waits after each request. With constant(0), then the program won’t wait at all after each request. If you use between(1,5) for example, then the program will wait a random number from 1 to 5 seconds after each request.</p><ul><li>Host</li></ul><p>host is the host of your website (the load test target).</p><ul><li>@task</li></ul><p>Methods decorated with @task are the core of the locust file, which will be run as requests to the host. On the example code above, I have 3 functions that are decorated with @task which will test the GET, POST, and PUT methods of URI path /articles/. The number five on @task(5) is the task’s weight. It means that that particular task is 5 times more likely to be picked rather than other tasks when Locust is randomly picking tasks to be executed.</p><ul><li>def on_start(self)</li></ul><p>def on_start(self) is a method that will be called for each virtual user when they start. This can be used if a user needs to do something like login first before doing the defined tasks.</p><p>After you save the locust file, you could run the program with this command (note that I’ll be using the command for CLI or without the browser’s interface as it’s more likely to be used this way in servers that don’t have access to web browsers):</p><pre>locust -f locust.py --headless -u 10000 -r 50 -t 1h --html report.html</pre><p>With the parameter — headless , locust will start immediately without the web interface. This is preferable especially if you’re doing this on a server (with ssh) and not on your local computer with browsers available. Then for the other parameters, the -u parameter is the maximum number of consecutive users that will do the requests, the -r parameter is the rate to spawn users at users per second, the -t parameter which is the time of the test, and lastly — html parameter which will store a HTML report to the file path specified.</p><p>These reports will look like these (these are just examples):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9O4mGTcYGp4yIjs5OFeXQQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*37Eq9iHQWdwlkKtmqfdGEg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3xEhSOEq1CfvZSZapNQ0QQ.png" /></figure><p>You can analyze all the data and statistics of the report for your conclusion of your load tests.</p><h4>Three Types of Load Tests in Python</h4><p>To do the three types of load tests, we can just play around with the parameters that we can set (and of course the locust file itself if it’s needed).</p><ul><li>Load Testing</li></ul><p>To do the usual load testing, you just need to determine every parameter as you need it. For example, you want to know if your server can take 100 consecutive users in a span of 30 minutes, you would write this command:</p><pre>locust -f locust.py --headless -u 100 -r 10 -t 30m --html report.html</pre><ul><li>Stress Testing</li></ul><p>For stress testing, you would want to write a really big number for parameter -u. This is because we want to try the maximum number of users and try to break the application. This is to find out our website’s limit and how it reacts to it. So you could put a ridiculous number like 1 million for the parameter -u, and parameter -r that is somewhat large too so it doesn’t take too long. The -t parameter can be whatever you want as long as you can see the result of the stress testing.</p><pre>locust -f locust.py --headless -u 1000000 -r 50 -t 30m --html report.html</pre><ul><li>Endurance Testing</li></ul><p>For endurance testing, the most important thing is to set the parameter -t to a long time, for example for 3 days or 1 week. This is to test if your website can handle these constant requests for a prolonged amount of time. The number of users can be set to a normal/expected load for your website.</p><pre>locust -f locust.py --headless -u 100 -r 10 -t 3d --html report.html</pre><h3>References and Resources</h3><ul><li><a href="https://docs.locust.io/en/stable/installation.html">Installation - Locust 2.9.0 documentation</a></li><li><a href="https://docs.locust.io/en/stable/writing-a-locustfile.html">Writing a locustfile - Locust 2.9.0 documentation</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fea13369af43" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Caching and Load Balancing with NGINX]]></title>
            <link>https://medium.com/@rico098098/caching-and-load-balancing-with-nginx-b1a1a3b52b8d?source=rss-c08d5dd215f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1a1a3b52b8d</guid>
            <category><![CDATA[load-balancing]]></category>
            <category><![CDATA[cache]]></category>
            <category><![CDATA[ppl2022]]></category>
            <category><![CDATA[nginx]]></category>
            <dc:creator><![CDATA[Rico Tadjudin]]></dc:creator>
            <pubDate>Wed, 15 Jun 2022 11:40:51 GMT</pubDate>
            <atom:updated>2022-06-15T15:33:29.819Z</atom:updated>
            <content:encoded><![CDATA[<p>Scale your website with NGINX’s caching and load balancing</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AD4jvnqYq3Ta65Sx" /><figcaption>Photo by <a href="https://unsplash.com/@kelvin1987?utm_source=medium&amp;utm_medium=referral">Kelvin Ang</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote>This article is written for the purposes of an individual review for CSUI’s Software Engineering Project Course 2022.</blockquote><h3>Introduction</h3><p>So you’ve already made a beautiful website for someone or something. It’s working flawlessly and nothing went wrong at all. After a couple of weeks, your website blew up and became viral! Everyone wants to go to your website tens of times a day! What great news right? RIGHT?? You’d think this is the case for a few moments, until your website can’t be accessed anymore and an error page came up after that. 😱</p><p>After that incident, you’ve realized that the (dreaded) time has come. Time for you to finally acknowledge what your mentors or seniors may have said time and time again. <strong>You need to plan on scaling your website!</strong></p><h3>Contents</h3><ol><li>Basics of NGINX</li><li>Reverse Proxy with NGINX</li><li>Caching with NGINX</li><li>Load Balancing with NGINX</li></ol><h3>Solving The Problem</h3><p>One of the ways you could scale your website is by configuring your servers so that it can serve more requests more quickly, resulting in better website performance. Now of course this is not the only way, scaling your website also includes planning to scale on the application level (web framework or language you’re using). But in this article, I’ll be explaining scaling in servers, particularly with NGINX.</p><p>This article will use this simple FastApi code as an example website that is stored on your server.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6b06819b9f292925b16f8ed0139be3a9/href">https://medium.com/media/6b06819b9f292925b16f8ed0139be3a9/href</a></iframe><h3>1. Basics of NGINX</h3><p>First of all, you need to install NGINX on your server. You will need to ssh into your server to do this. To install NGINX, run the commands below:</p><pre>sudo apt update<br>sudo apt install nginx</pre><p>After the installation is done, you could check if NGINX is actually installed and running by running this command:</p><pre>sudo systemctl status nginx</pre><p>If something happens and your NGINX stops running, you can run this command to start it back up:</p><pre>sudo systemctl start nginx</pre><p>And if you want to restart NGINX or reload it, you can run these commands:</p><pre>sudo systemctl restart nginx # Restart NGINX<br>sudo systemctl reload nginx  # Reload NGINX (if some config changed)</pre><p>All Nginx configuration files are located in the <strong>/etc/nginx</strong> directory and can be considered as NGINX home directory. NGINX main configuration file is in <strong>/etc/nginx/nginx.conf</strong> as global configuration settings. You’ll rarely edit this file as usually you will need to edit configurations files elsewhere (these files will be included in <strong>nginx.conf</strong> automatically).</p><p>I’ll spare you with the rest of the details as you could search it on your own.</p><h3>2. Reverse Proxy with NGINX</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xZ-Qu_pAXGK9Sb1y.png" /><figcaption>Source: <a href="https://en.wikipedia.org/wiki/Reverse_proxy">en.wikipedia.org</a></figcaption></figure><p>Essentially, a reverse proxy is a middle-man for your web server and the client requesting your files. By itself, reverse proxy just forwards any requests there are from clients to your server and forwards any response by your server to the client. So, what’s it’s purpose? Well there are a bunch of ways to use this, but in our case, we’ll be using this middle-man to do caching and load balancing.</p><p>To make a NGINX server as reverse proxy, you just need to edit configuration file <strong>/etc/nginx/sites-available/default </strong>. You could use vi or vim or any other tools to edit this configuration file. Put this code in that config file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4d76b0b52fa18a4eb79881cf3f289b17/href">https://medium.com/media/4d76b0b52fa18a4eb79881cf3f289b17/href</a></iframe><p>After you’ve saved the file, reload or restart NGINX so it can apply these new configuration.</p><p>With this done, now the NGINX server will be acting as a proxy server. Your clients will need to requests to the NGINX server (by IP or domain name), and you will forward that request to whatever you put in the proxy_pass. In this case, the request will be forwarded to http://example.com .</p><p>For further explanation, you can see that location / {} means that every url request to the NGINX server will be forwarded to the web server, while something like location /test {} will only pass the request if the request to the NGINX server is prefixed by /test . I’ve found this great article about NGINX proxy path translations <a href="https://tarunlalwani.com/post/nginx-proxypass-server-paths/">here</a>.</p><h3>3. Caching with NGINX</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ycVcj0Pb6YNIh7CB" /><figcaption>Photo by <a href="https://unsplash.com/@markuswinkler?utm_source=medium&amp;utm_medium=referral">Markus Winkler</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In our case, caching means that the NGINX server will save the web server’s response on the NGINX server itself. Then, when the same request which will result in the same response come to the NGINX server, the NGINX server does not need to forward this request. The NGINX server will simply respond right away to the client with the saved response from before. This will result on less work for the web server, and faster response time.</p><p>To do this, we will be further editing the <strong>/etc/nginx/sites-available/default </strong>configuration file as follows.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11cc8200bc42e2f7a13e47bd2706f5e2/href">https://medium.com/media/11cc8200bc42e2f7a13e47bd2706f5e2/href</a></iframe><p>First of, proxy_cache_path is the path which will be used to save whatever will be cached. So in this case, the cache will be saved to path /var/cache/nginx. levels sets the number of subdirectory levels in cache, while keys_zone=cache:10m is defining a shared memory zone named cache with maximum size 10 MB. inactive in proxy_cache_path just means that an unused cache will be deleted after that amount of time.</p><p>After that, you can see there is a new location which is location ~ /read/(.*)+/(.*)$ . This means that only requests that satisfy the regex /read/(.*)+/(.*)$ will be passed to this particular code block. In other words. only path /read/{student_id}/{trx_id} (idempotent URI) will be cached. Then there are proxy_cache, proxy_cache_valid, and add_header. proxy_cache declares to use the caching, proxy_cache_valid sets cached data to be stale after an amount of time, and lastly, add_header will add an attribute X-Proxy-Cache to the header of the request response.</p><p>Then as usual, after you’ve saved the config file, you can reload the NGINX to apply these new configurations. You can test this by accessing the website (don’t forget to access the NGINX server which acts as a reserve proxy, not the web server itself). If you access the cached URI /read/{student_id}/{trx_id}, you will be able to see X-Proxy-Cache attribute in the header of the response.</p><p>I’ve done some stress load testing for my FastAPI code that is hosted on Google Cloud Platform’s virtual machine. Here’s the comparison between accessing /read/{student_id} (not cached) and /read/{student_id}/{trx_id} (cached).</p><h4>Not Cached</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lTy8-1b2ZjcurP2_8ktnMQ.png" /><figcaption>Stress Load Testing for uncached ‘/read/{student_id}&#39;</figcaption></figure><h4>Cached</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jv3UvGd4A_EsDj_6Vw1y2w.png" /><figcaption>Stress Load Testing for cached ‘/read/{student_id}/{trx_id}&#39;</figcaption></figure><p>You could see that before the spike on the cached URI, the URI that is not cached has a median response time hovering on 340 ms, while the URI that is cached has a median response time on the 200s ms. The spike of the 95th percentile on the cached URI is probably due to the NGINX server not keeping up with the stress testing. And to add to that, my NGINX server and my website is hosted on the same server but with different ports. That is why that the difference of response time is not that significant. <strong>Imagine if you host your website on another separate server, the caching will fasten your response time considerably more.</strong></p><p>Notes: if you’re interested on how I do my stress testing, you could see my other story titled <a href="https://medium.com/@rico098098/load-testing-with-python-fea13369af43">‘Load Testing With Python’</a>.</p><h3>4. Load Balancing with NGINX</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1Um7bPTRDhiS4fKe" /><figcaption>Photo by <a href="https://unsplash.com/@coltonsturgeon?utm_source=medium&amp;utm_medium=referral">Colton Sturgeon</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Load balancing is a practice that is done by balancing requests to several identical web servers for better performance on heavy load. For this example, I’ll be doing a load balancing with Round Robin algorithm. Essentially it will alternate between given hosts one by one for every request it received. You can search up on your own about other load balancing algorithms.</p><p>To do this, we will be further editing the <strong>/etc/nginx/sites-available/default </strong>configuration file as follows.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7072eee170abcbdc3ed725278594d3f0/href">https://medium.com/media/7072eee170abcbdc3ed725278594d3f0/href</a></iframe><p>See that now you have an ‘upstream’ block with several hosts. These hosts needs to be identical for load balancing so every request will be treated the same (Client will not know the difference and does not know about the existence of multiple hosts).</p><h3>Conclusion</h3><p>Wow! It’s not hard right? You’ve tried caching and load balancing with NGINX just like that. I know that these things can be intimidating for beginners and someone new to web development, but I hope this article can help you by showing how to accomplish it. I feel that these are necessary knowledge for us to make a better and smoother website not just for you and your friends, but for a lot of other people as well.</p><h3>References and Resources</h3><ul><li><a href="https://nginx.org/en/docs/">nginx documentation</a></li><li><a href="https://tarunlalwani.com/post/nginx-proxypass-server-paths/">Understanding Nginx proxy_pass and url path translations</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1a1a3b52b8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The 4 Clean Code Principles in Django]]></title>
            <link>https://medium.com/better-programming/clean-code-principles-in-django-b0563a4e12f5?source=rss-c08d5dd215f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0563a4e12f5</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Rico Tadjudin]]></dc:creator>
            <pubDate>Tue, 10 May 2022 19:49:27 GMT</pubDate>
            <atom:updated>2022-05-18T15:43:56.707Z</atom:updated>
            <content:encoded><![CDATA[<h4>Clean (your) code in Django</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BGPvvDjJXFdFyG3G" /><figcaption>Photo by <a href="https://unsplash.com/@jeshoots?utm_source=medium&amp;utm_medium=referral">JESHOOTS.COM</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote><em>This article is written for the purposes of an individual review for CSUI’s Software Engineering Project Course 2022.</em></blockquote><h3>Introduction</h3><p>Cleaning is probably not your favorite pastime activity, and it’s certainly not mine. Whether it’s cleaning your room or cleaning your code, it’s probably not going to be a good time. But both of them have something in common. It’s very important.</p><h3>Contents</h3><ol><li><a href="https://medium.com/@rico098098/clean-code-principles-in-django-b0563a4e12f5#810d">Some of Clean Code’s Principles</a></li><li><a href="https://medium.com/@rico098098/clean-code-principles-in-django-b0563a4e12f5#7ed5">KISS in Django</a></li><li><a href="https://medium.com/@rico098098/clean-code-principles-in-django-b0563a4e12f5#f190">DRY in Django</a></li><li><a href="https://medium.com/@rico098098/clean-code-principles-in-django-b0563a4e12f5#c86c">YAGNI in Django</a></li></ol><h3>1. Some of Clean Code’s Principles</h3><p>As you may have known already, clean code is not about computers or compilers, it’s about humans. For computers, how you write your code doesn’t matter one bit as long as it’s syntax is right and it’s logically right. But humans are not computers. Your fellow co-workers and other programmers may not necessarily be able to read your code, especially if you didn’t write clean code.</p><p>Some of the most well known Clean Code principles are:</p><ol><li>KISS (Keep It Simple (and) Stupid)</li><li>DRY (Don’t Repeat Yourself)</li><li>YAGNI (You Aren’t Gonna Need It)</li></ol><p>In the following parts, I’ll try to show examples of these principles in Django.</p><h3>2. KISS in Django</h3><p>KISS (Keep It Simple (and) Stupid) is basically telling you to keep your code short, simple, and easy to read by others.</p><h4>Use Django Forms, Serializers, Permissions, and Decorators Rather Than Manual Alternatives</h4><p>When learning Django, you’ve probably learned Django forms, serializers, and many other things, as I did a long time ago.</p><p>But sometimes, I find myself questioning the benefit of using these things. Couldn’t you just write a few lines of HTML codes for forms? Or write more lines of code in the views instead of making serializers or permissions?</p><p>Yes, you can do just that to do the same thing. But because you can do it, doesn’t mean you SHOULD do it.</p><p>First thing is, manual HTML Forms is not safe! By using Django forms, your forms will be safer because it uses a CSRF Token as Cross-Site Request Forgery protection. You can search this on your own, but from clean code’s perspective, it’s also not good for manual HTML forms. Look at the comparison here:</p><p>Without Django Forms:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f54e17c10c9b0e00d04162e8b3f1e5f/href">https://medium.com/media/0f54e17c10c9b0e00d04162e8b3f1e5f/href</a></iframe><p>With Django Forms:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc185719a54a63e39d70a64ff9f77286/href">https://medium.com/media/cc185719a54a63e39d70a64ff9f77286/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/db395e67f485a3ecba9ec5e9dce328cd/href">https://medium.com/media/db395e67f485a3ecba9ec5e9dce328cd/href</a></iframe><p>You may think, “wait a minute, isn’t the code with Django forms longer?”. Yes, it’s longer if you include the forms.py file. But if you compare only the views.py file, you’ll see that the one with Django forms will be much simpler and easy to read than without Django forms. This is because even when the code (combined) is longer on the first snippet, it’s separated neatly. This means that you can infer what is supposed to do more easily.</p><p>This is the essence of KISS principle. You need to make the code simple and easy to read for others, even if you end up writing more code or have to think about it more. The most important thing to take away from this is make simple and readable code for others.</p><h4>Use Class-Based Views Rather Than Function-Based Views</h4><p>Use Class-Based Views instead of Function-Based Views when necessary. This is because even though Function-Based views is more flexible than its counterpart, Class-Based Views will be more readable on long and redundant functions/views.</p><p>I won’t go far in explaining this as most people probably have known about Class Based Views, but you can check out my other story about refactoring in Django <a href="https://betterprogramming.pub/refactors-you-need-to-know-to-for-your-django-project-8a56b0dee34f">here</a>. One of the sections there goes a little bit further on Class-Based Views in Django REST Framework.</p><h3>3. DRY in Django</h3><p>DRY or Don’t Repeat Yourself is a principle that explains itself. You shouldn’t repeat yourself in your code. Some things that you can do in Django to reduce redundancies are:</p><h4>Use Decorators for Restricting Access to Views</h4><p>If you haven’t used decorators before, you’ve probably written this in your views before:</p><pre>if request.user.is_authenticated:</pre><p>And if you have multiple views in one file, it might look just like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/da08a43541de1ba6352afaf0c933b723/href">https://medium.com/media/da08a43541de1ba6352afaf0c933b723/href</a></iframe><p>Well, what if I tell you there’s a better way that doesn’t involve copy-pasting and repeating yourself over and over again? Here’s how with decorators:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5627a2edcd923145429a9b6fe859eca6/href">https://medium.com/media/5627a2edcd923145429a9b6fe859eca6/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5379e93bb063a94f873a7f4f6d33cdfa/href">https://medium.com/media/5379e93bb063a94f873a7f4f6d33cdfa/href</a></iframe><p>Wow! Cool right? You can also see that in the decorator, you could write any custom code you want. So it’s not only for restricting access to views or redirecting you somewhere. You can save things to user’s session like referer URL paths before they go to the view or many other things you can imagine. The sky is the limit!</p><h4>Put Frequently Used Codes to Separate Helper Functions and in a Separate File</h4><p>This is another one where it’s really easy to implement for all of us! Extract frequently used code to a separate helper function and put it in utils.py file.</p><p>Example of sending emails without helper functions:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/112244cfdd88979aef27a39fde14c4c6/href">https://medium.com/media/112244cfdd88979aef27a39fde14c4c6/href</a></iframe><p>Example of sending emails with helper functions:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0ebae30341c8561bdcc05e9db5e1efa0/href">https://medium.com/media/0ebae30341c8561bdcc05e9db5e1efa0/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/993b7afe90230063d122825ef5902099/href">https://medium.com/media/993b7afe90230063d122825ef5902099/href</a></iframe><p>The difference is quite stark, to be honest and it would be much more needed for more complicated and complex functions.</p><h3>4. YAGNI in Django</h3><p>YAGNI or You Aren’t Gonna Need It is a principle that tells us to not get ahead of ourselves. Sometimes I and maybe some of you would write code for the ‘future’. Maybe we’ll need this or that later on, so might as well write it now right? Nope! It’s really a bad habit for clean code because most often than not, <strong>you aren’t gonna need that code</strong>.</p><p>For example, I’ll go back to the decorators that we’ve discussed before. Maybe after learning that we can make @login_required decorators, we would like to make another one for users who are qualified.</p><p>Well, we’ve not really implemented this qualified thing, but maybe we’ll write it now for the ‘future’.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0aca41500b984df6a35c258a39436dec/href">https://medium.com/media/0aca41500b984df6a35c258a39436dec/href</a></iframe><p>Well….. it’s done.</p><p>2 years later…</p><p>“What’s this ‘qualified’ decorator thing?”</p><p>Yes, you’ve probably forgotten about it and never used it. That’s because you probably didn’t need it in the first place. So, the takeaway from this is you should not add functionality or any other code until it is deemed necessary unless you want a bloated and messy codebase for your projects.</p><h3>References and Resources</h3><ul><li><a href="https://docs.djangoproject.com/en/4.0/ref/csrf/">Cross Site Request Forgery protection | Django documentation | Django</a></li><li><a href="https://docs.djangoproject.com/en/4.0/topics/email/">Sending email | Django documentation | Django</a></li><li><a href="https://docs.djangoproject.com/en/4.0/topics/http/decorators/">View decorators | Django documentation | Django</a></li><li><a href="https://docs.djangoproject.com/en/4.0/topics/class-based-views/">Class-based views | Django documentation | Django</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0563a4e12f5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/clean-code-principles-in-django-b0563a4e12f5">The 4 Clean Code Principles in Django</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git Flow: Develop Code With Others using Git]]></title>
            <link>https://medium.com/@rico098098/git-flow-develop-code-with-others-using-git-cdd94ec9a0b6?source=rss-c08d5dd215f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/cdd94ec9a0b6</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[gitlab]]></category>
            <dc:creator><![CDATA[Rico Tadjudin]]></dc:creator>
            <pubDate>Mon, 11 Apr 2022 12:38:37 GMT</pubDate>
            <atom:updated>2022-04-11T12:38:37.323Z</atom:updated>
            <content:encoded><![CDATA[<p>How to develop code with others correctly using Git from my own experience</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DyvfFcIFhcYlRMIc" /><figcaption>Photo by <a href="https://unsplash.com/@pankajpatel?utm_source=medium&amp;utm_medium=referral">Pankaj Patel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong><em>** This article is written for the purposes of an individual review for CSUI’s Software Engineering Project Course 2022. **</em></strong></p><h3>Introduction</h3><p>If you clicked on this article, you most probably have known or used Git before. Git is a free and open source distributed version control system that developers or software engineers will likely be familiar with. Despite this fame and its apparent usefulness, beginners who want to dive deeper on using Git can feel a little intimidated, just as I did when I started using Git. This usually happens when beginners want to incorporate more Git features and/or use them on a project with a large number of people involved. Things can get scary when you could accidentally delete your teammates work or ruin something you don’t understand.</p><p>In this article, I’ll try to explain my experience of using Git and how I incorporate it into my team’s workflow.</p><h3>1. My Team’s Git Branches and Flow</h3><p>In my team for my <em>Software Engineering Project Course, </em>we’ve decided on using a Git flow as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rVfoSX4_OTMy_c8MFFn5UQ.png" /><figcaption>My Team’s Git Flow Illustration</figcaption></figure><p>It’s maybe a bit confusing if you’ve never seen an illustration of Git Flow before, but bare with me here for a little bit. Later I’ll explain how you implement this flow in the real world, but first I’ll explain all the branches that my team are using.</p><ul><li><strong>Master/Main branch</strong><br>This branch will be the main branch that contains deployable and production environment ready source code. In other words, anything in this branch is the code that runs our production application.</li><li><strong>Staging branch</strong><br>This branch will be the main branch for our development. This branch contains the accumulation of all the work each team member has done. The application that runs from the code in this branch can be used for development testing purposes or showcasing what you’ve done to select client/consumer.</li><li><strong>Feature branch</strong><br>These feature branches will be the branches where me and my team members works on. Each feature will have their own branch where one or more team member will have the responsibility to work on it.</li><li><strong>HotFix branch</strong><br>HotFix branch is used when there is a bug or an error in the master/main branch and we’ll need to fix it ASAP. After the bug is fixed, this branch can me merged again to the master/main branch. This is illustrated in the picture above (a.)</li><li><strong>ColdFix branch</strong><br>ColdFix branch is used when there is a feature rollback needed on staging branch. This can happen because of changing requirements, client rejection of the implementation, or other things. This is illustrated in the picture above (b.)</li></ul><p>With these branches and flow, my team can work more fluidly without bothering the works of other team members. But how exactly do we implement this Git flow?</p><h3>2. Implementing the Git Flow</h3><p>So in this part, I will try to explain all the steps I usually take when doing my work in my team. I’ll assume that you already know the basics of Git, how to initiate remote/local repository, etc. Also, in these steps I’ll be talking about Gitlab as my devops platform because that is what I use with my team.</p><h4>- First, Create New Branches</h4><p>After initiating the repository, I will need to make all the necessary branches (if hasn’t been done yet). I can do this by inserting this in the terminal:</p><pre>git checkout -b NameOfBranch</pre><p>The tag -b here signify that I want to create a new branch. For example if I want to make a new feature branch for liking a post named ‘feature-10-liking_a_post’, I’ll write:</p><pre>git checkout -b feature-10-liking_a_post</pre><p>This line will take me to a new branch that is based of the previous branch that I’m in. When I want to go back to another branch, for example my staging branch, I can do checkout without the b tag:</p><pre>git checkout staging</pre><h4>- Do Your Work</h4><p>After you’ve successfully created a new branch, you can do whatever work you needed on that branch. You can commit (of course with a clear commit message so others can understand what is the purpose of your commit) and push (to the same branch) as much as you like.</p><h4>- But, what if my other team members are working and modifying the code at the same time as me?</h4><p>Relax, this is where git merging comes in. Your work and your teammate’s work can be merged safely without problem as long as you and your teammate didn’t work on the same code.</p><p>BUT, If you and your teammate are working on the same code, then there might be a conflict from both of your work. For example, if initially code.py is like this:</p><pre># code.py</pre><pre>var = &quot;a variable&quot;<br>print(var)</pre><p>And then you changed the value of var to “not a variable” and at the same time your teammate changed its value to “blablabla”, Git wouldn’t know which change it should implement on the merged version. So, a conflict arises. This conflict must be resolved manually by you or your teammate to see which change is to be implemented on the merged version.</p><h4>- Git Pull to Resolve Conflicts</h4><p>To resolve conflicts as soon as possible before trying to merge, I recommend you to always pull (git pull) from the main developer branch (or the base branch where you create your new branch from) before you want to merge your work. This is to ensure that you get all updates to the code locally in your computer first before trying to merge on the remote repository.</p><p>When you do git pull, you will see if there is any conflict between your work and your other teammates work. If there is any, you can go to those files with the conflict and resolve it manually by deleting or changing the code as to how it should be in the merged version. After doing this, you can push one last time to the remote repository (still on the same branch).</p><h4>- Merge Request</h4><p>Before knowing Merge Request (MR), you may have done merging by merging locally first and then pushing the resulting merge to the remote repository. But merging like this is not good if you work with other people. A better way is to use merge requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B9sIpM8RrA4JfY_p67B7Dg.png" /><figcaption>One of My Merge Requests</figcaption></figure><p>With Merge Request, you can request a merge from a source branch (the branch you’ve been working on) to a target branch (usually staging, etc.) and let other members review, comment, and approve your code. This adds a layer of quality checking on your code by your teammates.</p><h4>- Code Review via Merge Request</h4><p>As previously explained, with Merge Request you can have others review your code. This is one of the most important step in my team. Every Merge Request we request on Gitlab, we’ll need 3 other members to approve our changes before we can merge it to the staging branch. This is done to reduce error detection time (as more people is checking and reviewing), increase quality code that are actually merged, increase shared knowledge between team members, and many other advantages. Because of all the benefits I’ve seen from doing this, I recommend your teams to do this practice as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M86IiWOUBgpAYirTqb_XAA.png" /><figcaption>Example of me commenting on my teammate’s work (in Indonesian)</figcaption></figure><p>After 3 team members approves my work, then I can merge my code to the staging branch.</p><h4>- Rinse and Repeat</h4><p>After that, I would repeat the process for other features I’m tasked on. This process and flow is done by each of the team members and it must be done seriously by everyone for maximum results. I myself really feel the benefits of this process and flow on my team. Because of it, our workflow is smoother, causes less problem from conflicts, and ensure us to write better, cleaner quality code.</p><h3>3. Conclusion</h3><p>Using Git with a lot of contributors can be really intimidating for some. It’d be much easier if you’re the only one who is pushing code to the repository right? But obviously we can’t always work alone and must work well in a team. The things I’ve written above are my own experience on how to use Git with other people, specifically on my team’s project for <em>CSUI’s Software Engineering Project Course 2022</em>. I hope this article can enlighten and inspire you to use Git with your own team.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cdd94ec9a0b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3 Refactoring Techniques To Keep a Clean, Simple, and Readable, and Django Codebase]]></title>
            <link>https://medium.com/better-programming/refactors-you-need-to-know-to-for-your-django-project-8a56b0dee34f?source=rss-c08d5dd215f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a56b0dee34f</guid>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Rico Tadjudin]]></dc:creator>
            <pubDate>Sat, 09 Apr 2022 16:21:03 GMT</pubDate>
            <atom:updated>2022-04-16T13:32:04.512Z</atom:updated>
            <content:encoded><![CDATA[<h3>3 Refactoring Techniques To Keep a Clean, Simple, and Readable Django Codebase</h3><h4>Using Django? You’ll need to refactor these things!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZmhOjR2a84IEZrzY" /><figcaption>Photo by <a href="https://unsplash.com/@cdr6934?utm_source=medium&amp;utm_medium=referral">Chris Ried</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote>This article is written for the purposes of an individual review for CSUI’s Software Engineering Project Course 2022.</blockquote><h3>Introduction</h3><p>Refactoring is one of the most important practices you must do for all of your projects. Even when your projects are relatively small and simple, refactoring code is always encouraged and is the best practice for more readable, simple, and cleaner code. In this article, I’ll be showing you some things that can be refactored when you’re using Django (especially Django REST Framework) as your framework of choice! Let’s go!</p><h3>Table of Contents</h3><pre>1. <a href="#9754">(Django Models) Custom Model Manager</a><br>2. <a href="#fd3d">(Django Models) Select Related and Prefetch Related</a><br>3. <a href="#7a88">(Django REST Views) Class Based Views with Mixins and Generics</a><br><a href="#4376">Conclusion</a></pre><p>In these examples, I’ll be using these models that I’ve made for my Software Engineering Project Course 2022.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f30fcb70910de17a710e936e49858399/href">https://medium.com/media/f30fcb70910de17a710e936e49858399/href</a></iframe><h3>1. Django Models — Custom Model Manager</h3><blockquote>According to <a href="https://docs.djangoproject.com/en/4.0/topics/db/managers/">Django Documentations</a>, “Model Managers in Django is an interface through which database query operations are provided to Django models.”</blockquote><p>You might not realize this, but you probably have used Django’s model manager when using Django Models. When you write Term.objects.all(), the ‘objects’ in the middle of the default manager are provided to all models by Django.</p><p>Here’s where things get interesting: you can make your own custom model manager that can do other things convenient to you and your model.</p><p>For example, if I want to get all courses in a specific term (i.e., term “2021/2022–1”), and I want them to be ordered by the course’s name, then normally we’d probably write this:</p><pre>Course.objects.filter(term__name=&quot;2021/2022-1&quot;).order_by(&quot;name&quot;)</pre><p>To be honest with you, there is no big problem with this, but if you’ll be using this exact filtering and ordering multiple times in your code, you’ll see that you’re going to repeat the code over and over again. This long filter and ordering can reduce the readability of your code. Things can improve if you use a custom model manager and QuerySet, like this for example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65010cdff4c79cf63ccf67d52017947a/href">https://medium.com/media/65010cdff4c79cf63ccf67d52017947a/href</a></iframe><p>Don’t forget to assign the new custom manager to the model. You can overwrite the default ‘objects’ manager or create a new custom manager with a different name. For this, I’ll be overwriting the default ‘objects’ manager.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a8da29caa7f91f49b7c06873fb601856/href">https://medium.com/media/a8da29caa7f91f49b7c06873fb601856/href</a></iframe><p>With this, you can do the same thing as before by writing this:</p><pre>Course.objects.get_by_term_name_with_ordered_name(&quot;2021/2022-1&quot;)</pre><p>You could see that it’s more readable than the code before, and it’s simpler without repeating the .filter and .order_by. Sure, this example may not seem to improve the code much, but you can use custom managers for whatever you want and need. This can significantly improve your code readability and prevent you from repeating your code.</p><h3><strong>2. Django Models Select Related and Prefetch Related</strong></h3><p>You may not know yet about select_relatedand prefetch_related, but these functions provided by Django are really useful. In my opinion, a must-have for improved database query performance. This is because when you have already queried a bunch of objects to a QuerySet, and then you want to access its foreign key object’s attribute, Django will query the database again for every foreign key attribute of every object you’re calling.</p><p>Take a guess: if the code below is executed, how many queries does Django make to the database?</p><pre>courses = Course.objects.filter(credit=4) #for example returns 2 obj</pre><pre>for course in courses:<br>  print(course.term.name)</pre><p>You may think that it should be one, right? It should query the database when Course.objects.filter is executed? I’m sorry, but that answer is incorrect. The right answer is there will be three database query calls.</p><p>How? Obviously, the first query is on the filter. After that, because there are two Course objects in queryset, courses, and the code asks for a foreign key’s attribute, (course.term.name), then for every iteration of the for loop, Django will make an additional query call to the database.</p><p>This is because the initial Course.objects.filter does not have the information of the term’s name. Imagine if you’re doing 1,000 iterations or more. You’ll be querying the database 1,000 times for this alone.</p><p>To prevent this from happening, you can use select_relatedand prefetch_relatedto get those foreign key attributes on the initial filter query. You can search for the differences between the two, but in short, you use select_relatedwhen the object attribute is a single object (like OneToOneField or a ForeignKey), whereas you use prefetch_relatedwhen you’re going to get more than a single object or a set of things (ManyToManyFieldsor reverse ForeignKey’s).</p><pre>courses = Course.objects.filter(credit=4).select_related(&quot;term&quot;)</pre><pre>for course in courses:<br>  print(course.term.name)</pre><p>By adding select_related(&quot;term&quot;), you will query all the information of the foreign key “term” of courses objects in the first query. Because of that, Django would not need to query the database for every iteration of the for loop.</p><p>This will significantly improve your database query performance (more like preventing massive amounts of database querying), and I personally think it makes your code more readable by explicitly telling readers you will need these attributes of a certain foreign key later.</p><h3><strong>3. Django REST Views — Class-Based Views with Mixins and Generics</strong></h3><blockquote>Note: I’ll be discussing class-based views for the Django REST Framework. Class-based views for Django are a bit different, and you can see the <a href="https://docs.djangoproject.com/en/4.0/topics/class-based-views/">Django documentation</a> for more information</blockquote><p>Class-based views are probably already well known by many Django users. But in my opinion, you should use class-based views in moderation. For complex views, I think class-based views might lower readability (for those who are not fluent in class-based views) and lacks flexibility.</p><p>But for simple views, particularly REST views in Django REST Framework (DRF), you definitely should use class-based views with the provided mixins and generics as it’s significantly more simple, needs less code, and improves readability (for others who already know class-based views).</p><p>For example, with function-based views, I would write GetAndDeleteTermViews like this, keeping in mind that you should make the serializer for your model first for serializing the data. In this case, I’ve named mine TermSerializer:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6b88d541eef32745a0d24010d77df515/href">https://medium.com/media/6b88d541eef32745a0d24010d77df515/href</a></iframe><p>There’s no big problem functionally with the above code. It should work fine as it’s supposed to. But you can see with more complex logic, it would get a lot messier. There would be a lot more lines of code, and/or a lot more ifs and elifs. This would lower the readability of your code. Here’s the same functionality with class-based views, mixins, and generics:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c0f70160069b319aa0bae3be3bc2ee3/href">https://medium.com/media/9c0f70160069b319aa0bae3be3bc2ee3/href</a></iframe><p>As you can see, it is a lot more simple and readable. One other advantage is all the errors that may happen (like 404 when the object does not exist) are already handled by Django. This will take less development time and improve readability for readers who have a basic understanding of class-based views.</p><h3>Conclusion</h3><p>I think these are essential refactors that you must consider in your Django projects. These are definitely not all the things that you need to refactor. You should search for more things that need refactoring, but I find a lot of people new to Django are not aware of things — like model manager and select_related/prefetch_related in Django.</p><p>All the effort you put in refactoring code will definitely pay off with a more clean, simple, readable, and improved code.</p><h3>References</h3><ul><li><a href="https://docs.djangoproject.com/en/4.0/topics/db/managers/">Managers | Django documentation | Django</a></li><li><a href="https://docs.djangoproject.com/en/4.0/ref/models/querysets/#select-related">QuerySet API reference | Django documentation | Django</a></li><li><a href="https://www.django-rest-framework.org/tutorial/3-class-based-views/">3 - Class based views - Django REST framework</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a56b0dee34f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/refactors-you-need-to-know-to-for-your-django-project-8a56b0dee34f">3 Refactoring Techniques To Keep a Clean, Simple, and Readable, and Django Codebase</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Test Driven Development, Should You or Should You not?]]></title>
            <link>https://medium.com/@rico098098/test-driven-development-should-you-or-should-you-not-ddbd266b686?source=rss-c08d5dd215f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/ddbd266b686</guid>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-testing]]></category>
            <dc:creator><![CDATA[Rico Tadjudin]]></dc:creator>
            <pubDate>Mon, 21 Mar 2022 10:41:33 GMT</pubDate>
            <atom:updated>2022-03-21T11:03:15.392Z</atom:updated>
            <content:encoded><![CDATA[<p>My take on the practice of Test Driven Development and how I use it with React in my project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dovZDNdInmxrr2sI" /><figcaption>Photo by <a href="https://unsplash.com/@sigmund?utm_source=medium&amp;utm_medium=referral">Sigmund</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong><em>** This article is written for the purposes of an individual review for CSUI’s Software Engineering Project Course 2022. **</em></strong></p><h3>Introduction</h3><p>If you learn software development and it’s practices on a university or an academic organization, you’ve probably heard of TDD or Test Driven Development. Some might be inclined to ignore this practice, others might defend it with all the strength they can muster. Nevertheless, the instructors and teachers that I’ve met seemed to have a favorable impression of TDD, while some of my fellow students did not so much think so. So, is the practice of TDD really worth your time? Or is it just an annoying formal exercise that you have to do to get your grades?</p><p>In this article, I’ll be writing about TDD as a practice of software development based on my experience. In addition, at the time of writing this article, I’m taking one of my university’s courses which is a Software Engineering Project Course. In this course, I and 6 other members of my team were assigned to develop a software with correct and efficient development processes according to industry standards. Although my grades depend on this course — which by the way requires my team to use TDD, I will try to be unbiased and write my true and honest opinion on TDD as a practice of software development, especially using it with React which is what my team are using right now for the course.</p><h3>Contents</h3><ol><li>What is TDD?</li><li>What is it’s positives and it’s negatives?</li><li>My take on TDD as a practice</li><li>How I use it with React in my project</li><li>Conclusion</li></ol><h3>1. What is TDD?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8Lp_j3GPzqLYGIZS" /><figcaption>Photo by <a href="https://unsplash.com/@homajob?utm_source=medium&amp;utm_medium=referral">Scott Graham</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Before we discuss Test Driven Development, you will need to understand about the basics of Testing in Software Development. If you’re not familiar with this topic, then you can read one of my other medium article titled <a href="https://medium.com/@rico098098/a-short-intro-to-testing-in-software-development-for-beginners-f9adccb9be6f">‘<em>A Short Intro to Testing in Software Development for beginners</em>’</a>. Now, we can discuss about TDD.</p><p>TDD or Test Driven Development is a practice used in software development to make quality, neat, and errorless code, especially when there is change bound to happen later on. As the name suggests, TDD is a way to do development that is driven by tests rather than just writing code willy-nilly.</p><h4>How to do it</h4><p>So, before you write any code that implement functionality or features, you will have to write tests first. These tests will be the foundation of your implementation code later on. So be careful with what you write in your test codes, as you need to implement functionality and features according to them later. In my project, I was taught to do this by separating tests and implementation codes to different commits in <a href="https://git-scm.com/">Git</a>. First, I would have to write the tests for a functionality or feature that I’m about to work on. Then I would have to commit the tests with a message that says “[RED] commit_message” where the ‘commit_message’ is your intended commit message for that commit. Then after doing that, you can implement the functionality or feature which you have made tests for and commit it with the message “[GREEN] commit_message”. The color red and green is inspired from the color of failed and passing of tests in DevOps platforms that uses git, like <a href="https://about.gitlab.com/">Gitlab</a>, <a href="https://github.com/">Github</a>, and many others. Do these 2 steps every time you want to add functionality or features. But what if you just want to refactor code to make it more readable or perform better? Then just implement the refactor and commit it with the message “[REFACTOR] commit_message”. But remember to only refactor code that is already implemented and is already tagged GREEN as in all tests were executed successfully.</p><h3>2. What is it’s positives and it’s negatives?</h3><p>So, what is good about TDD and what’s not so good about it? Here is what I think after using it in several of my projects.</p><p><strong>Positives</strong></p><ol><li>TDD helps me to envision and plan my implementation code carefully and correctly. It enforces me to think and make scenarios for my implementation, and forces it to be explicit and not just abstract ideas.</li><li>TDD makes cleaner code, more maintainable code, and make development process smoother, especially when there’s a lot of people working on it.</li><li>With TDD, I won’t code carelessly and put temporary/messy code everywhere. With the extra planning when making the tests, I would find it easier to implement the functionality/features that I want.</li><li>TDD helps to keep coverage of my project at 100%. While 100% coverage doesn’t mean it is necessarily bug-free, it helps minimize errors in lines of code that I or my teammates might have forgotten to test.</li></ol><p><strong>Negatives</strong></p><ol><li>It is really a steep learning curve for beginners. Especially with new programming language or framework that you are using.</li><li>TDD takes a lot of time and manpower in a software development environment.</li><li>TDD is really easy to be cheated and ignored by developers. As you can see from the explanation above, developers can just make the implementation first and then make the tests after the implementation is done. This accomplishes the same thing on the outside, but inside, your project won’t get much of the positive value of doing TDD in the first place.</li></ol><h3>3. My take on TDD as a practice</h3><p>There’s a few things I want to say and add about TDD from my experience.</p><h4>It’s really good and beneficial when used properly</h4><p>The keyword here is ‘properly’. As you can imagine, practicing TDD in the real world is really hard. You and your team might not have enough time, enough manpower, or enough determination to do TDD properly. Without you abiding to the rules of TDD, the benefits of doing it is reduced significantly, and you might be better off not doing it entirely. But if you do it earnestly and properly, you will get the benefits abundantly and you will be able to make better code and software than you’ve ever managed to before.</p><h4>If I don’t even know how to print a string, how am I going to make tests for codes?</h4><p>This is one of the most frustrating thing one might experience when trying to do TDD. It is when the developer needs to code in a new programming language and/or framework, but he/she also needs to implement TDD on the project. How would one expect someone to know testing — which needs the developer to know the ins and outs of the framework, when he/she doesn’t know anything about the programming language or the framework itself? This is one of the situations where I think it’s better to pick one or the other. Either don’t do TDD, or use a programming language or framework that you’re familiar with to maximize the outcome of your project. When you’ve learned more about the programming language or framework in question, then you can try again to implement TDD with it on another project.</p><h4>Is it really being used professionally?</h4><p>Well, here’s the thing, I wouldn’t call myself an expert of the professional world of software development, because I’m really not. But, what I’ve heard from others is that TDD might not be used as often as you might think in the professional world. And you’re right to say that I don’t have reliable sources on this, but I really could see why this could be true, especially with how fast change is in this day and age.</p><p>Ideally, TDD is necessary to maintain a clean code, maintainable, and smoother development process. But in reality, growth metrics, user acquisition, and revenue generation are also necessary for businesses to grow. Since both take time, manpower, and commitment to do properly, companies might need to prioritize one over the other. This makes it that some — but not all — companies prioritize something else over TDD. But of course testing is still needed in these companies, but it just might be that they don’t follow a strict rule like the implementation of TDD.</p><h4>So, should we use it? And when to use it?</h4><p>In my opinion, yes, you definitely should use it even when you don’t necessarily need it. Because TDD is the best practice for developers to make clean and maintainable code. But, also think about the positives and the negatives that you’re going to gain from using TDD. In my opinion, when writing code in a new programming language or framework, you should not use TDD as you might be bogged down by writing tests and learning the tools needed for it. This will likely causes you to miss deadlines and other such problems. Otherwise, you should switch to other preferred languages or frameworks that you already mastered if you still want to use TDD on your project. Or, the other option would be to extensively learn the language and framework you’re going to use first before you start working on the project.</p><h3>4. How I use it with React in my project</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QCmJTFSIkiKzxYMM" /><figcaption>Photo by <a href="https://unsplash.com/@lautaroandreani?utm_source=medium&amp;utm_medium=referral">Lautaro Andreani</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In my team’s project, we use React as a front-end and Django as the back-end of our website. In React, we mainly implement TDD by making unit tests with Jest.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mfYrNjbGZ6CxhLiXtvM-qg.png" /><figcaption>Example of tagging commits with RED and GREEN tag</figcaption></figure><p>For pages in my React app, I usually just test if it renders correctly without errors and expect its elements to be rendered as well if there’s any. This ensures that my page does not cause errors when rendered and render each elements correctly. As an example, I worked on the Layout page of the website. As TDD requires, I first wrote the tests for the page first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Spr-0sJQ2VUZHtvR3T_Yg.png" /><figcaption>Test for Layout Page</figcaption></figure><p>This test expect and ensures that the page is rendered correctly without errors, and that there will be a children passed on to the page to be rendered. The test expects that the given children that is given an attribute of data-testid=&quot;test-content-of-layout&quot; will also be rendered as a result. After writing the test, I will implement the Layout Page as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*KJ31D-Z2rtHuDzIrKZTgJw.png" /><figcaption>This is my main code for the Layout Page</figcaption></figure><p>You can see that my code uses 2 other components, that is Header and Footer (the other components are from a library or I already defined it on the same page). These components can be considered as dependencies to the Layout Page and are already fully tested by my team members who made them in the first place. These dependencies can be mocked if I don’t want them to be rendered with the Layout Page, but I see no strong reason to mock them because it’s working fine in my testing environment and my team members already made unit tests for the individual component Header and Footer.</p><h3>5. Conclusion</h3><p>At the end of the day, it’s your choice to take up and try TDD or not for your project. But from this article, I hope now you know more about TDD as a practice in software development. It is a practice that is driven by tests made first by developers. This practice is good because using it will create cleaner and more maintainable code for your project. But, TDD can be hard to pull off correctly, especially if you’re just learning the programming language or the framework you’re using. You should gauge the positives and the negatives for your project and decide yourself whether to use TDD or not. For me, as long as I know enough about the tools that I’m going to use and there’s enough time and resources in my hands, I will always use TDD as the best practice of writing code in software development.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ddbd266b686" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Short Intro to Testing in Software Development for beginners]]></title>
            <link>https://medium.com/@rico098098/a-short-intro-to-testing-in-software-development-for-beginners-f9adccb9be6f?source=rss-c08d5dd215f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9adccb9be6f</guid>
            <category><![CDATA[sofware-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Rico Tadjudin]]></dc:creator>
            <pubDate>Mon, 21 Mar 2022 08:55:38 GMT</pubDate>
            <atom:updated>2022-03-21T09:03:40.718Z</atom:updated>
            <content:encoded><![CDATA[<h4>Testing in Software Development for complete beginners</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MaA1CXcgHWTjDP8y" /><figcaption>Photo by <a href="https://unsplash.com/@ilyapavlov?utm_source=medium&amp;utm_medium=referral">Ilya Pavlov</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>If you are new to software development or programming itself, you may have heard something about testing. You might ask yourself what is testing in software development? What form of testing can we do as programmers/developers? And why should we care and practice it? Is it a necessary step for you to learn as a beginner in computer science?</p><p>In this article, I’ll try to share my experience with testing in software development as a computer science student myself. What is it really? Why should you care about it? And why should you start learning it now? Let’s go!</p><h3>Contents:</h3><ol><li>What is Testing in Software Development?</li><li>The Basics</li><li>Why should you care about it?</li><li>Why should you learn about it now?</li><li>Conclusion</li></ol><h3>1. What is Testing in Software Development?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9whoYNE8u-wL7LwD" /><figcaption>Photo by <a href="https://unsplash.com/@hansreniers?utm_source=medium&amp;utm_medium=referral">Hans Reniers</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Testing in software development is not that much different from testing in other fields or your daily life. We are tasked to make a set of rules or assertions on what our code should be doing or what value should be returned to ensure that our code is working correctly.</p><p>In programming, there are 2 approach to testing your code. There is <strong>manual testing</strong> and <strong>automatic testing</strong>. As the name suggests, manual testing must be done manually by people with a list of things that you want to test. This is not much different from testing in other fields. However, the difference between programming and other fields may lie in automatic testing. In automatic testing, the tests will be run automatically by a computer rather than manually. For this article, I’ll be focusing on automatic testing, specifically these 2 methods that are widely known and used, <strong>Unit Testing </strong>and <strong>Integration Testing</strong>.</p><h3>2. The Basics</h3><h4>Integration Testing</h4><p>Integration Testing is a type of testing on a software where you will be testing multiple components of your code at the same time. This means that many components will be tested at once with relatively less time and effort. But the problem with this kind of testing is that if a problem/error occurs, it would be hard to find the source of the problem, as everything is running and is being tested at the same time. So is there a better way to do this?</p><h4>Unit Testing</h4><p>Different from integration testing, unit testing is a type of testing on a software where individual units or components of a software are tested individually. Individually is the key word here. In unit testing, your goal is to test only that unit or component without including any other units or components.</p><p>For example, if you are testing a function named <em>calculateSomething()</em> that needs to fetch data from an API (an Application Programming Interface), then you don’t need to include tests for fetching that data from that API. What you should do is make another test that specifically tests your code for fetching that data. This is because in unit testing, you’re only supposed to tests individual units (in this case it’s the <em>calculateSomething() </em>function), and assume that other dependencies that are needed by that function to be working perfectly well. This can be done because as I’ve said before, you should have already created a different unit test for that particular dependency, which make it safe to assume that all dependencies that one function might need will be working perfectly well.</p><p>But, if the function <em>calculateSomething() </em>is called in testing, wouldn’t the fetching of data from the API will be called as well? Doesn’t this mean that the test is running codes outside of the unit? And what are we going to do with dependencies that might not be available in testing and make it blasts errors into our console? If those are the case, <strong>mocking</strong> will be your best friend!</p><h4>Mocking</h4><figure><img alt="Unit Test with Mock" src="https://cdn-images-1.medium.com/max/428/0*AdSgV87Y8_rfUMw6.png" /><figcaption>Source: <a href="https://www.oreilly.com/library/view/distributed-computing-in/9781787126992/be5a9dff-1e4d-4167-9ea6-d48411a86f86.xhtml">O’REILLY</a></figcaption></figure><p>As you can find in the dictionary, one of the definition of the word <strong><em>mock</em> </strong>is ‘<em>not real but appearing or pretending to be exactly like something</em>’. That is essentially what we are going to do when we use mocks in unit testing. As discussed before, a function or an object under test may have dependencies that are not supposed to be tested by that function/object’s unit test. So, to isolate the function/object from their dependencies, you will have to replace the dependencies with mocks that simulate the behavior of the real dependencies. This is really useful and is often needed in unit testing.</p><h4>Coverage</h4><p>Coverage is a number or percentage that represents how many lines, branches, functions, etc. of implementation code that you have covered with your unit testing. This is essentially a metric of how well is your test codes covering your implementation codes. But beware that a 100% coverage doesn’t necessarily mean that your code doesn’t have bugs or work 100% correctly as intended. It just means that your tests has run all the lines of your implementation code and it is passing the tests that you made yourself. There is still a probability of some logic error on certain situations or maybe you’ve written a bad test code.</p><h4>Bad Test Code</h4><p>Here’s an example (just pseudocode) of a bad test code in python.</p><pre># Bad Test Code</pre><pre>x = 2<br>y = 3</pre><pre>def test_sum():<br>    assert (x + y == x + y), &quot;it should be 5&quot;</pre><p>With the above code, of course the test will always pass. That is because x + y will always equal to x + y and the test will never fail. The correct way to write the test is as follows.</p><pre># Better Test Code</pre><pre>x = 2<br>y = 3</pre><pre>def test_sum():<br>    assert (x + y == x + y), &quot;it should be 5&quot;</pre><p>With the above code, you can always feel assured that x + y will always output 5, because if it doesn’t output 5, the test will fail and you will know about it. Of course this is a really oversimplification of how to really use tests, but I hope you got the picture of how and why tests are used in programming.</p><h3>3. Why should you care about it?</h3><p>If you manage to reach this section, congratulations! You have managed to read all the really basic stuff about testing in software development. Then, why should we care about it? Isn’t it a little bit too tedious to do? What good is it for?</p><p>You can see that tests make sure that some or all of our code is always functioning as we envisioned it to function. As you grow as a programmer, you will be working on more complex and bigger sized code. Moreover, you most probably will not work alone all the time and you will have to work with other people in a team. This will definitely make you feel that the code is not fully under your own control, because other people will be able to change and modify any code on your project with his/her own style and way of writing code.</p><p>These different people who are contributing, modifying, and changing the code will fasten the development time, but in return, it could produce different implementation and misunderstandings in the code itself. Some code that you’ve written before might break after others modify something on the project. This is really hard to detect by yourself as you can’t really check everything manually every time someone modify the code. This is where automated testing like Unit Testing comes in!</p><p>With automated testing, you could just run the test every time you are merging your code with others, or when you are about to deploy your application, or whenever you want to detect any errors that might have occurred in your code.</p><h3>4. Why should you learn about it now?</h3><p>In my opinion, everything in computer science should be learned as soon as possible by anyone interested. There is no downside to learning it early rather than pushing it to a later date. This is especially true for testing. Yes, testing might really be needed only on complex and big projects. And yes maybe you are only making small projects with your friends and messing around a bit. But is it not your goal to be making bigger and more influential programs and application in the future? If your answer is yes, then it is the right time to learn and accustomed yourself with the practice of testing. It’ll be too late to learn testing later when you’re asked to make and contribute to complex and big projects.</p><p>In addition, testing a program correctly will also strengthen your understanding of your code and the language you’re using. This is because to test your code, you must understand what it does first and how does it work. If you’re able to master the practice of testing your code, then most likely you’ve also mastered and understood your code fully.</p><h3>5. Conclusion</h3><p>In conclusion, testing in software development is a practice where we’re trying to make a set of assertions on what our code should be doing to ensure that our code is working correctly. There are manual and automated testing in software development, with Unit Testing and Integration Testing as examples of automated testing that you can use. Testing in software development can help you make quality and errorless code even in complex and big projects with other people working on it. And lastly, I think it’s never too early to learn this skill for yourself. Because the time you’ll need it will probably come in the future, and the more you know about testing, the more you will understand about your code and the language that you’re using.</p><h3>References:</h3><p><a href="https://realpython.com/python-testing/">Getting Started With Testing in Python - Real Python</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9adccb9be6f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Be A Great Team Member]]></title>
            <link>https://medium.com/@rico098098/how-to-be-a-great-team-member-273d7cdab27a?source=rss-c08d5dd215f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/273d7cdab27a</guid>
            <category><![CDATA[teamwork]]></category>
            <category><![CDATA[team]]></category>
            <category><![CDATA[productive]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[self-awareness]]></category>
            <dc:creator><![CDATA[Rico Tadjudin]]></dc:creator>
            <pubDate>Sun, 20 Mar 2022 18:51:33 GMT</pubDate>
            <atom:updated>2022-03-21T03:45:20.317Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to be your best self as a team member in any situation and environment to make a productive team</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vNPL8o9L8crlvlyc" /><figcaption>Photo by <a href="https://unsplash.com/@marvelous?utm_source=medium&amp;utm_medium=referral">Marvin Meyer</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong><em>** This article is written for the purposes of an individual review for CSUI’s Software Engineering Project Course 2022. **</em></strong></p><h3>Introduction</h3><p>Without a single shred of doubt in my mind, you most probably have worked in a team before. Whether it’s a team of students working on an assignment or a team full of professionals working on a project, most people have worked in a team before with other people. And like it or not, these other people can be very diverse in terms of culture and other aspects of a person, such as their personality, nature, and many other things. Because of this, many hasn’t been shy to speak of their disdain for working with other people — especially with others who they don’t like. But as you all know, working as a team is inevitable in most field of work. So you will have to put up with it, right? Besides, isn’t this the job of a team leader to solve rather than us the ‘powerless’ team members?</p><p>No. I strongly say no to those 2 last questions/statements. You don’t have to put up with it because you can do something about it and it is not just the team leader’s responsibility to solve every interpersonal problems in a team.</p><p>Before we continue, I’ll introduce myself to describe my situation and clarify where I’m coming from as I write this article. My name is Rico, I am a student of the Faculty of Computer Science at the University of Indonesia at the time of writing this. As a student studying Computer Science, I’m sure to find some courses that require teamwork on assignments and projects. Therefore, I have some experience working together with other people in a team, both as a leader and as a member.</p><p>With that said, this article is written based on my opinion and my understanding alone. So after reading this, you can formulate your own thoughts and opinions and reply them to me. And by no means this article should be considered as facts or something that is objectively right, because a kid sitting all day in front of a computer is the one who wrote this article 😅. And lastly, don’t misunderstand and think that I am a kind and generous kid who is doing all the things that I wrote here religiously. No, now and probably for a long time, I’m still struggling to try to do and implement all of the things I wrote. We as human beings are not perfect, and I’m certainly not judging anybody. But I sincerely believe in my heart that these are the things we should do to become a great team member and develop a productive team.</p><p>With all that out of the way, here’s how to be a great team member in my humble opinion.</p><h3>Contents</h3><ol><li><strong>Team Leader’s Job?</strong></li><li><strong>You need to put up with bad team members?</strong></li><li><strong>A Great Team Member</strong></li><li><strong>My Own Experience</strong></li><li><strong>Conclusion</strong></li></ol><h3>1. Team Leader’s Job?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Md5IvlGsIU_3wFbg" /><figcaption>Photo by <a href="https://unsplash.com/@huntersrace?utm_source=medium&amp;utm_medium=referral">Hunters Race</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In the middle of thinking about this problem, I thought “wait, isn’t this the team leader’s job? To solve all these problems in a team and team members just have to hope and pray and all problems will be magically solved?”. No, of course not. Yes, it is true that technically team dynamics and interpersonal problems lie in the responsibility of a team leader. But that is not what I’m trying to say. If we look at it realistically, not every problem will be able to be solved by the team leader, and these problems will be put on your plate as a team member, especially problems involving other team members. In a team, there is only one team leader with many other team members interacting everyday and tirelessly working to reach the same goal of the team. So it’s your job too as a team member to make these problems into positive learning moments and improve your team’s productiveness.</p><p>Besides, in my opinion, team members are the ones that is the heart of the team, not the team leader. A team leader should be a servant to the team. Their job is to serve the team as a leader who represent and maintain the team and it’s work. There should be no feeling of boundless superiority in a team leader, but endless humility that understands his team and it’s members. So as the heart of the team, without team member’s cooperation, these problems will find no solutions no matter how hard a team leader tries to find it.</p><p>So no, this is not just the job of a team leader, but you as a team member must be responsible for it and take action too as an individual.</p><h3><strong>2. You need to put up with bad team members?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qDuQNfbLwgdvx220" /><figcaption>Photo by <a href="https://unsplash.com/@heylagostechie?utm_source=medium&amp;utm_medium=referral">Mars</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Ah, bad team members. Who haven’t met them in their life? If you haven’t met a single bad team members, then maybe you are the bad team member? 😂 I’m just kidding, but on a serious note, not looking oneself in the mirror is a real and frequently found problem on many people. So we’ll be discussing this later on. For this section we’ll be answering “Do we need to put up with bad team members?”. My answer is a big no.</p><h4>What to do about it?</h4><p>“So Rico, should we talk back to them, fight them, or cry about it?” Of course not. Provocative, physical actions, or putting all of this burden on yourself is not what my answer implies. My answer is we should not feel burdened on ourselves and our work by these so called ‘bad team members’ and try to correct them with our own actions. You may call me naive or that I don’t know anything about the ‘real’ world, but I sincerely believe that your actions are your own, and actions taken by others is out of your own control. This is why when there’s a problem, I always look to myself first instead of other people. “This and that happened suddenly, so what <strong>can I do</strong> about it?”. You should always look inward to yourself first before blaming others, even when that problem arises from others. Why? Why be so selfless? Like I said, what you can control is yourself. You can’t control others especially those who doesn’t like to be controlled. So the optimal way to solve your current problem is to do something about it yourself and not blaming others. This is because that problem already happened and you can’t time travel to prevent that problem from happening.</p><h4>Not Blaming Others First</h4><p>“So Rico, if we don’t find the culprit and the source of the problem, then wouldn’t that problem persists in the future?” A big misunderstanding. What I mean by not blaming others is to not direct blame and overly scold the person before we have solved the problem. It doesn’t bring any positive contribution to bring hatred and annoyance to the team in the face of the problem that we’re trying to solve. We should lightly warn the person who caused the problem and work together as a team to solve the problem. After the problem is solved, now you can give a good scolding or whatever you want to give to the person responsible for the problem, as long as it doesn’t go to far. With this mentality, the person responsible would most likely feel bad about causing the problem that everyone has to solve together, resulting in caution and reduced problems occurring. So a win-win solution right there! What if the person doesn’t feel bad? So what? It’s not your loss that he/she doesn’t learn anything from it. If the person is repeating the mistake over and over again, then in my opinion it would be better to let him go from the team. Scolding and hating on him excessively would not do any more good than bad. Like I said again and again, you could only control yourself and not others.</p><h4>Give Advice and Guidance, not Take Control</h4><p>“Uh Rico.. If you say that we can’t control others, so we can’t tell others how to behave or how to do the job correctly?” Again, no. What I mean by ‘you can’t control others’ is not that you can’t give suggestions or advices to other people, but you can’t force people to always do something as you wish. People are complex human beings same as ourselves. Stop thinking that other people and the world revolves around you and should obey all your wishes, but think that you and other people lives in the same blue planet we all love and have different cultures, personalities, and ways of thinking. You maybe can somewhat ‘control’ people with fear, but when there’s a chance — even the tiniest bit of a chance — you will lose that control and everything will fall apart. The better way of handling this is by giving advice and guidance to the person who make mistakes or behave improperly. Maybe he/she will ignore your advice, but then there will be no loss to you yourself. You’ve tried your best to give advice to them in good intentions. If they don’t want to hear it, it’s out of your control. What you can do is give them your advice regularly and frequently when they did the mistake again. Over time, who knows? Maybe they will hear your advice some day. What if everyone told you that you are a ‘goody two shoes’ or whatever? Again, who cares? This is not being on a ‘good’ or ‘bad’ side, but this is about working together as a team achieving a goal in mind.</p><h3><strong>3. A Great Team Member</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XXI_vEfXsA8U54La" /><figcaption>Photo by <a href="https://unsplash.com/@hannahbusing?utm_source=medium&amp;utm_medium=referral">Hannah Busing</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>What I wrote in section 2 should already answer half of this question. In a team consisting of multiple diverse people, we should not blame problems to others before the problem is solved and not taking control of others, but giving advice and guidance to them. But what else is needed to be a great team member? Here’s some more of my way to become a great team member.</p><h4><strong>Always Look at Yourself First.</strong></h4><p>As we’ve touched before, you should always look at yourself first. This is more true and should be done more before we complain about something. Is this your own fault? Are you doing the same thing as the thing that you are complaining about? Is what I’m complaining about really bad for me? Or is it only because I’m lazy and such? These are important things that we have to realize before we complain or blame others. We as humans, including myself, have a tendency to think that we are the most ‘good’ person in the room. Or at least we are on the good side and certain individuals are in the bad side. Well, think again. Sometimes we’re the ones who is causing the problem or divide among the team. With this knowledge, we can fix our behavior or mistakes and improve ourselves and our team. It probably hurts to see the truth that we are not as ‘good’ as we previously think (oh believe me, it hurts alright 🤕), but it is a necessary step to become a better person and a great team member for the whole of your team.</p><h4>Bring Everybody Up, not Down</h4><p>You probably have heard about this phrase somewhere. You should not be bringing everybody down with you, but bring everybody up with you. Jealousy is a strong feeling and emotion. Everyone has them at least at one point of their life. You would think that if you’re below someone in the ‘rankings’ — whatever that might entail in your case, then you would have to bring that person down so you could be on top. In my opinion, that is the wrong way to approach this problem. If you bring that person down, you would be at the same place as before. Yeah maybe you’re on top above that person, but you’re not moving anywhere yourself. Beside that, bringing someone down is most likely done through bad intentions and bad means. First, you should not do bad things, and second, this means that other people can find out about it and catch you do it. This would make you fall off from your so called ‘rankings’, and all the work you’ve done will be for naught. So why not bring yourself up so you can be on top? It might be hard and take a long time to achieve, but by doing that, you bring everyone else in your team up with you, and your team will improve and be better because of it. And don’t forget about your purpose in your team. Your purpose in your team is to pursue the team’s goal whatever it is. So to achieve that goal, you should do whatever you can to improve everybody on the team.</p><h4>Bring Joy in Every Situation</h4><p>A great team member have to bring joy and happiness to the team in every situation, including in difficult moments. Joy and happiness here is not in a form of pure happiness or people literally laughing and having fun. But you can do everything in your power to make the situations more fun and less dreadful. What you can do also depends on what you are good at. I’m not telling you to make jokes if you’re not good at making them. I’m not suggesting you make small talk if you’re not good at communicating with other people. What I’m saying is do whatever you can with your skills/talents/things you’ve learned to bring happiness to others in every situation. Naturally, this includes helping each other out when it’s needed.</p><h4>Helping Others</h4><p>As a team member, it’s your responsibility to help other team members out when they need it. But what I’m going to emphasize here is not just helping out when you’ve got the time. But helping others out even in rough times. I’m not telling you to drop everything and help the other person, but you should help others even when you’re not on the mood or your team’s in a difficult time. For me, helping others brings a unique kind of joy and happiness that can’t be described easily. Seeing others succeed and do their job properly because of me is really fun and it made me proud of myself. But of course, you should not be excessively proud and become arrogant. Keep it to yourself and make it a power source for when others might need help again.</p><h3><strong>4. My Own Experience</strong></h3><p>Right now, I’m in a course called <em>Software Engineering Project Course 2022 </em>in my university. It’s a course that teach on how to develop software correctly and efficiently in a team with 6 other team members. In my team, I’m nowhere near the team leader. I’m just the normal team member or the usual ‘developer’ of the group. I’m writing this article with my experience working in a team in mind, including working on this Software Engineering team. I have been trying to apply all of my belief that I’ve written in this article to practice in my team. Of course it’s not perfect and I’m nowhere near doing all of it. But the important thing is I know what I did wrong, and I will work on it to improve myself to become a great team member in my team.</p><p>For a short example, in my software engineering team, there’s a member who is really lazy and procrastinate a lot. For multiple times before, I’ve always been annoyed by his behavior that results in not contributing enough to the team. He usually does his work at the last minute and it’s not uncommon to copy/reuse other team members’ code. Naturally, this resulted in my team not being able to finish on time on one of our little deadlines. To be honest, I got a little bit angry at him then and feel unfairness because I’ve put a lot of hours into the project. But I remember to look at myself again. I’m no stranger to procrastination. It is not an easy thing to overcome and ignore. It doesn’t make my friend innocent of his misbehavior, but it puts my perspective in the right place and I sympathize with him a little. This quench my anger and let me think more calmly. Like I’ve said before, what others do is beyond our control. My job here is to give him advice and guidance on how to better his behavior. And honestly, this is where I struggle the most. I’m not a direct person when talking with others, so I’m having a hard time talking to him about my opinion and my advice. But I’m trying little by little over time to tell him that what he’s doing is wrong and he should not be doing it anymore. I too suffered from procrastination and know all about it. So I’ve got some tips on how to reduce procrastination to tell him.</p><p>This is where I have to learn more, to be more direct and fearlessly give others advice and guidance on what is right for the team. This proves that every one of us doesn’t need to do the things I’ve wrote perfectly, because I myself can’t do it all perfectly. But we need to strive to be better and improve as we go along for the better of our teams.</p><h3>5. Conclusion</h3><p>In conclusion, I think you have to be a good person and be selfless as a team member to be a great team member. This is done not just to be on the ‘good’ side or to stroke your own ego, but this is done to achieve your teams’ shared goal and to develop a strong and productive team. To be honest, I think I’ve rambled on too long on this article. But I believe on what I wrote to be important and you could make your own opinions about it. But beside that, it also serves as a reminder for me and you, to always be a good person and be selfless. Because the more you give to others, the more things you own yourself. Things that can’t be calculated by numbers. Things that you could only feel and experience. And one of those things is becoming a great team member.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=273d7cdab27a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scrum as a Framework, Why and How?]]></title>
            <link>https://medium.com/@rico098098/why-scrum-in-short-b946655a8605?source=rss-c08d5dd215f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/b946655a8605</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[scrum]]></category>
            <dc:creator><![CDATA[Rico Tadjudin]]></dc:creator>
            <pubDate>Mon, 28 Feb 2022 13:58:47 GMT</pubDate>
            <atom:updated>2022-03-20T14:36:18.661Z</atom:updated>
            <content:encoded><![CDATA[<h4>What and why Scrum is used by many and how you could do it yourself</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YVSlFccfOJWUPnF0" /><figcaption>Photo by <a href="https://unsplash.com/@edenconstantin0?utm_source=medium&amp;utm_medium=referral">Eden Constantino</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong><em>** This article is written for the purposes of an individual review for CSUI’s Software Engineering Project Course 2022. **</em></strong></p><p>*** Edited on 20/03/2022 ***</p><h3>Introduction</h3><p>You may have heard of Scrum before, especially if you are working in — or closely related with — the field of software development. Even if you aren’t in the field, you may have used or heard of Scrum before from someone you know or from some videos you’ve been watching instead of sleeping. 🤐</p><p>But, there is a huge difference between ‘having heard’ of Scrum and ‘understanding’ Scrum. If you’re interested on a deep dive of Scrum and you like reading a lot of text 😨, you can visit The Scrum Guide website by clicking <a href="https://scrumguides.org/scrum-guide.html">this</a> or go surf on the internet as much as you like!</p><p>But for those of you who would like a summary of sorts, you’re in the right place! In this article, I will try to summarize as much as I can on what is Scrum, why should you use it, and how you could do it with your own team. Let’s go!</p><h3>Contents</h3><ol><li>What is Scrum?</li><li>Why should you use Scrum?</li><li>All you need to know about Scrum</li><li>How to do Scrum?</li><li>My experience using Scrum</li></ol><h3>1. What is Scrum?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CbVgyND5bX9-JhxPMULMVg.png" /><figcaption>Source: <a href="https://scrumguides.org/">The Scrum Guide Website</a></figcaption></figure><p>The <a href="https://scrumguides.org/">Scrum Guide website</a>, describes Scrum as a framework for developing and sustaining complex products. It generates value through adaptive solutions for complex problems. We may not realize it, but change is inevitable. Change is not only prevalent in software development or other certain fields, but everything in this world is bound to change. To counter and solve that, we need to change ourselves and adapt to the ever-changing problem.</p><p>This is what Scrum is trying to do. It is a framework that creates an environment suitable for adaptability. This environment helps the team to solve problems quickly and develop great products, while sustaining it despite whatever change that may have happened. In other words, Scrum tries to make use of the inevitability of change to maximize output by encouraging change and adaptability.</p><h3>2. Why should you use Scrum?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eKrVG--yBQqX3QiR" /><figcaption>Photo by <a href="https://unsplash.com/@designer4u?utm_source=medium&amp;utm_medium=referral">Olga Guryanova</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The term Scrum itself is derived from the sport rugby, where a scrum (short for scrummage) is a formation of players packing closely together to attempt to gain the possession of the ball. This term was chosen to emphasize teamwork to achieve a common goal. In developing and sustaining a product, this quality is most definitely required, even more so when there are a lot of people involved and the potential of change is high when making the product.</p><p>As previously stated, change is inevitable in this day and age. People, workers, shops, companies and others who cannot adapt to these changes will have a hard time and left behind by others who can. This is more imperative on the field of software engineering. Every year, month, week, and days that passes, there will be new things to discover and new ideas to be implemented.</p><p>This is what makes Scrum and software engineering so compatible and why it is widely used by many.</p><h3>3. All you need to know about Scrum</h3><p>This section include explanation of Scrum Theory, Scrum Team, Scrum Artifacts, and Scrum Events. You might see that this section is a bit long, but bare with me here, because if you want to do Scrum, you’ll need all these things to implement it correctly and get value out of it. If you are confident and know about all of these things already, you may skip this section and go to section 4.</p><h4>Scrum Theory</h4><p>First, we’ll go through a summary of the theory of Scrum itself. Scrum uses an iterative, incremental approach to optimize predictability and to control risk. To do this, Scrum combines <strong>four smaller events</strong> — which we’ll discuss later on — for inspection and adaptation within a containing event,<strong> the Sprint</strong>. Before we discuss the Sprint itself, there is three empirical Scrum pillars that supports and make the Spring event itself possible. These three Scrum pillars are as follows.</p><ol><li><strong>Transparency</strong><br>In a project, every work and everything done to complete that work must be told and be known by all the people that worked on the project and all the people who are receiving the product of the project. This will encourage decisions that have more value to the project because everyone knows about everything related to the project.</li><li><strong>Inspection<br></strong>All the Scrum Artifacts and our progress made toward the goal must be frequently inspected to prevent and detect undesirable problems that arises with or without our knowledge.</li><li><strong>Adaptation<br></strong>One could say that adaptation is one of the essence of Scrum as a framework. With the everchanging requirements and environment expected by consumers and people in general, we need to be ready for adjustments to our work to reduce further deviations or changes that are too late to be corrected.</li></ol><p>These pillars need to be held when using Scrum as a framework for it to be successful.</p><h4>Scrum Team</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6Z9sRmQYUo1hl11i" /><figcaption>Photo by <a href="https://unsplash.com/@jasongoodman_youxventures?utm_source=medium&amp;utm_medium=referral">Jason Goodman</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In Scrum, we will be working as a relatively small team known as a Scrum Team. The Scrum Team consists of one <strong>Scrum Master</strong>, one <strong>Product Owner,</strong> and <strong>Developers </strong>as explained below.</p><ol><li><strong>Developers</strong><br>Developers as a group is the heart of the Scrum Team. These developers are the ones who will be creating usable increments of the project each Sprint Event. The word ‘developer’ used here does not necessarily only relate to the field of software engineering or computer science. Rather than that, every member of your team that is not the Product Owner or the Scrum Master is the developers. They are the ones who will be working to make and complete the product of your project in Scrum events.</li><li><strong>Product Owner<br></strong>Product Owners are the ones who will be managing the project and bridge the Scrum Team with all the stakeholders outside of the team. They are accountable for maximizing the value of the product resulting from the work of the Scrum Team. For Product Owners to succeed, the entire team and all other people related to the project must respect their decisions. However, respect does not mean fear or accepting all decisions without question. Those with suggestions or different ideas may talk and try to convince the Product Owner.</li><li><strong>Scrum Master<br></strong>Scrum master is someone who will maintain the rules and principles of Scrum on the Scrum Team. They do this by helping everyone understand Scrum as a framework, both within the Scrum Team and whoever is related to the project. We all know that trying to apply an obscure framework to a project where everyone involved has no idea what is going on and what are they supposed to do is really excruciating (believe me, I know 😫). The Scrum Master is the one in charge of solving this problem by educating everyone about Scrum as a framework and maintaining it while the project is being worked on.</li></ol><h4>Scrum Artifacts</h4><p>Scrum’s artifacts represent work or value to be done on our project. Each artifact contains a commitment to ensure it enhances transparency and focus to the scrum artifacts.</p><p>These are the scrum artifacts:</p><ol><li><strong>Product Backlog</strong><br>The Product Backlog is an ordered list of what is needed to be done to improve the product. It is the single source of work undertaken by the Scrum Team at any given time. In a Sprint, we might need to do Product Backlog Refinement. Product Backlog Refinement is the act of breaking down and further defining Product Backlog items into smaller more precise items.<br>For Product Backlog, the commitment that is made by all the team members is the <strong>Product Goal</strong>. The Product Goal describes a future state of the product which can serve as a target or goal of the product for the Scrum Team. Each items in the Product Backlog is defined by pondering “what” will fulfill the Product Goal.</li><li><strong>Sprint Backlog</strong><br>The Sprint Backlog is composed of the Sprint Goal (why), the set of Product Backlog items selected for the Sprint (what), as well as an actionable plan for delivering the Increment (how).<br>For Sprint Backlog, the commitment that is made is the <strong>Sprint Goal</strong>. The Sprint Goal is a single objective for the current Sprint. Despite it being a commitment, Spring Goal provides flexibility in terms of the exact work needed to achieve it. Developers can determine themselves how to achieve the goal. Sprint Goal also creates focus among the members and encourage the team to work together.</li><li><strong>Increment</strong><br>Increment is the smallest artifact in Scrum and act as a concrete stepping stone toward the Product Goal. Multiple increments may be created and added in each Sprint. Every one of these increment adds to the previous increments and work together with them to increase the value of the product. But of course, to increase value of the product, every increment must be usable in the sense that users of the product can see the difference and value added by the increment.<br>In increments, the commitment made by the team is the <strong>Definition of Done</strong>. The Definition of Done is a formal description of the state of the Increment when it meets the quality measures required for the product. In a sense, the Definition of Done is a definition of ‘when are we done working on this specific thing (an increment)’. This is especially important in the field of software engineering where the definition of ‘done’ is unclear and in many ways, subjective.</li></ol><h4><strong>Scrum Events</strong></h4><p>A sprint is a container for all the other scrum events. These events are used in Scrum to create habit or regularity and to minimize the need for excess meetings that are outside of the required meetings Scrum defined and intended.</p><ol><li><strong>The Sprint</strong><br>Sprints are fixed length events of one month or less. A new Sprint starts immediately after the conclusion of the previous Sprint. This is done to increase consistency and help make it a habit to team members. All the other scrum events happen within Sprints.<br>During the Sprint:<br>a. No changes are made that would endanger the Sprint Goal<br>b. Quality does not decrease<br>c. The Product Backlog is refined as needed<br>d. Scope may be renegotiated with the Product Owner as more is learned</li><li><strong>Sprint Planning</strong><br>Sprint Planning is an event where the team is planning out all the work to be performed for the Sprint that is about to be started. The Product Owner ensures that attendees are prepared to discuss the most important Product Backlog items and how they map to the Product Goal.<br>Sprint Planning addresses the following topics:<br>- Why is this Sprint valuable (Sprint Goal)?<br>- What can be done this Sprint?<br>- How will the chosen work get done?</li><li><strong>Daily Scrum</strong><br>Daily Scrum or Daily Standup Meeting is a regular and daily 15-minute meeting held at the same time and place every working day of the Sprint. This meeting is only for the developers of the team. The purpose of the meeting is to inspect progress toward the Sprint Goal. Every developer can state their progress, what has been blocking them from doing more, and what they planned to do next. This is not a fixed structure to how a Daily Scrum should be done, but you can do it with your own structure or technique, as long as the meeting focuses on the team’s progress toward the Sprint Goal and produces a plan for the next day of work.</li><li><strong>Sprint Review</strong><br>Sprint Review is an event that is held at the end of a Sprint. It’s purpose is to inspect the outcome of the Sprint and determine what to do next in the future based on what has been done. In this event, Scrum Team presents the results of their work to key stakeholders and discuss what changes — if there is any — that needed to be done in the future based on the current situation of the environment (this could mean what customers wanted, the condition of the market or the world, etc.). Based on this, the Product Backlog may also be adjusted to meet new opportunities for the product.</li><li><strong>Sprint Retrospective</strong><br>As the name of the event suggests, Sprint Retrospective is the time for the Scrum Team to retrospectively take a look at the recently completed Sprint in different aspects like the team’s individuals, interactions, processes, tools, and the Definition of Done that has been made. With all of these knowledge, we try to discuss and find ways to increase quality and effectiveness of the work and the team.</li></ol><h3>4. How to do Scrum?</h3><p>Now is the time you’ve been waiting for. That is how to do Scrum exactly? Here’s how I’ve done it with my team.</p><ol><li><strong>First, you and all your team members need to learn about Scrum!</strong><br>This is really important! You and all of the member of your team need to know and understand Scrum as a framework. Without it, Scrum will not work properly and your team will not get the positive value of doing Scrum as a framework. Even if you yourself as a team leader know all about Scrum, your team will not be able to implement Scrum properly and soon your team will be filled with confused and demotivated team members. If you’ve read section 3 of this article, then that should be enough for your fundamental information of scrum.</li><li><strong>Product Owner makes the Product Backlog Items (PBI)</strong><br>First, Product Owner needs to define the Product Goal. After that, the Product Owner will transform large items/requirements and functional details into epics and user stories. Epics are essentially categories of large overarching requirements/features of the product. Then these epics will have to be broken down to smaller user stories. These user stories then can be put to product backlog as product backlog items. An example of these user stories is as follows. ‘as a student, I want to add, modify, and delete a post on this page’. Make sure that each of these product backlog items include its priority, its business value, acceptance criteria, and its story points which is a kind of weight of the item for the developer and will actually be filled on the next step.</li><li><strong>The Scrum Team do the sprint planning for a Sprint</strong><br>The Scrum Team will be preparing and planning on what to do for the coming Sprint. Before you do anything, you will need to calculate how hard is each PBI — which had been selected by the Product Owner — or you could say it’s weight as a PBI. This weight is the story point of the PBI. You could make use of Poker Planning like on <a href="https://www.scrumpoker-online.org/en/">this website</a> to facilitate your Poker Planning. For each PBI, every member of the team will pick a number for the story point (Low numbers mean more easy and faster to complete while large numbers mean harder PBI) based on their own ability. After seeing the answers of all the other team members, you will discuss why your team members gave that particular story point for that PBI. After discussing, you will retry the poker and everyone will have to pick a number again for that same PBI. After this second time, the number which is most picked by your team members will be the one picked for the story point of that PBI.<br>After all PBI’s have story points, you will have to break down the selected Product Backlog into smaller subtasks. After that, your team will discuss on how exactly to achieve and complete these subtasks based on the team members skill and understandings of the subject.</li><li><strong>Working on the Sprint</strong><br>This is where the work starts. The developers of the Scrum Team will work on the subtasks that are defined on the Sprint Planning. To make this easier, you would have to make a Sprint Board which is divided to an “Open” section which is where all the subtasks are, a “To Do” section which is where all the subtasks that are already assigned to team members and are waiting to be worked on, a “Doing” section which is where all the subtasks that are in progress, an “On Review” section which is where all the ‘finished’ subtasks but need review from other developers, and a “closed” or “sprint-#” section which is where all the finished and reviewed subtasks resides. Remember that what defines a subtasks finished state is it’s Definition of Done which your team needs to define. Do this for the duration of the sprint and don’t forget about the Daily Scrum that has to be done daily.</li><li><strong>Sprint Review</strong><br>On Sprint Review, you need to present the progress of your team on the sprint to all the stakeholders for the project. Remember that this Sprint Review is for all stakeholders including possible clients who does not understand the technicality of your project. So you need to show what value has been added on the sprint in a way that all stakeholders would understand. Beside presenting the progress, in Sprint Review you need to discuss about possible changes or demand on the requirements of the project. If there are changes needed, you will have to adapt to it as a team. This is why the duration of a Sprint is usually better when it is shorter (maybe 2 weeks) as a shorter window will result on more feedback from stakeholders and make adapting more easy if there are changes needed.</li><li><strong>Sprint Retrospective</strong><br>As explained on section 3, Sprint Retrospective is where your team will look back on the Sprint that had been done and see where it can be improved. In this event, you will need to talk about both the work for the project and the team itself. With this, your team will acknowledge all the positive and negative things on your previous Sprint and continue to improve based on that.</li><li><strong>Rinse and Repeat</strong><br>After your Sprint Retrospective, you will need to go back to step 3 and do the planning for the next Sprint. Do the steps from step 3 to step 6 iteratively until all the PBI has been done and there are no more changes or fixes needed.</li></ol><h3>5. My Experience with Scrum</h3><p>I’ve been working in a Scrum Team effectively for approximately 6 weeks at the time of writing this for my Software Engineering Project Course 2022 in CSUI. I would say that it is definitely scary and hard for newcomers, especially if information is scarce on how exactly to do it correctly. Without guidelines and instructors, it’s quite hard to do it properly and find real success. But having said that, I really could see the unbridled potential of the framework if used correctly by everyone on the team. With the ever-changing demands and requirements of customers and people in general, now is the best time ever to learn how to adapt to it. Even if Scrum is not exactly the right fit for you or your team, learning it could prove to be really beneficial for you and your team’s growth. This could improve your understanding of each other and your capability to adapt to change, which is inevitable.</p><h3>References</h3><ul><li><a href="https://scrumguides.org/scrum-guide.html">https://scrumguides.org/scrum-guide.html</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b946655a8605" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>