<?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 Valentina Kania on Medium]]></title>
        <description><![CDATA[Stories by Valentina Kania on Medium]]></description>
        <link>https://medium.com/@kakavalka?source=rss-c64668a630d9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*SEmINYa5TQ6zK9mH.jpg</url>
            <title>Stories by Valentina Kania on Medium</title>
            <link>https://medium.com/@kakavalka?source=rss-c64668a630d9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 11:59:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kakavalka/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[Week 6 — Last Individual Review]]></title>
            <link>https://medium.com/println-mic/week-6-last-individual-review-df177f8951e8?source=rss-c64668a630d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/df177f8951e8</guid>
            <dc:creator><![CDATA[Valentina Kania]]></dc:creator>
            <pubDate>Tue, 15 May 2018 17:26:39 GMT</pubDate>
            <atom:updated>2018-05-16T07:25:31.005Z</atom:updated>
            <content:encoded><![CDATA[<h3>Data Migration &amp; Seeding</h3><p>In Println, data seeding and migration is done by one of our hackers, Muhammad. I did not do any of those because there is only one data type we need to seed, “User Profiles”. Therefore, I am going to explain my theoretical knowledge and understanding of what my coworker did. I will also write about my experience in Schema Migration.</p><h4>Data Migration vs Schema Migration</h4><p>Schema migration, or database migration, is a change management to relational database schema. I took part in this type of migration.</p><p>To do it, we need to create the schema migration script first, which is done by:</p><pre>python manage.py makemigrations</pre><p>To migrate, we run:</p><pre>python manage.py migrate</pre><p>which will apply the migrations to the database, in our case, our PostgreSQL database.</p><p>In Django, schema migration scripts are irreversible. That means, you cannot unapply any migrations done beforehand. I once made a mistake weeks ago, deleting old migration scripts, and building a new one. This created chaos throughout back-end and Heroku server. However, thank God for Muhammad, and I finally learned what Django migration scripts are.</p><p>Data migration, on the other hand, is a change management in the real data inside the database. This is usually done when we are changing into another DBMS. We did not apply data migration, however, we initialized data in our servers by seeding.</p><h3>Think Big &amp; Daily Improvement: What’s Next for Println?</h3><h4>Our Goals</h4><p>From the first time I met our product owner, we always made ourselves clear that the goal of building Println is not just to complete PPL course, not just building another printing platform, but to solve problems regarding unreliability and difficulties of printing that we face today. We <strong>aim to</strong> create a responsive, fast, and reliable automatic printing platform that is scalable, which can be used and implemented easily to small and medium printing enterprises.</p><h4>Product-Oriented, not Task-Oriented</h4><p>I am very blessed to walk this Println journey with five talented, goal-oriented, and encouraging teammates. In every scrum meeting and sprint planning, we actively discuss the design of our product as a whole, to make sure that each of our codes aligns with our product goals, and integrates well to the system.</p><p>I know some other PPL students who struggle to integrate their code with their teammates, because they did not discuss it through. Their design and concepts did not align, and they only focus on their tasks without carefully thinking about how their code integrates to the system. I am lucky that <strong>this is not us</strong>, and I believe this is what differentiate us from other teams.</p><p>Other than finishing our tasks independently, we also make time to meet (usually on Saturdays) and do back-end front-end integrations. With the help of API Documentations that I made (published on Postman), we fix bugs, adjust endpoints that are too difficult for client to consume, and testing our application as a whole.</p><h4>How I Improved throughout my Println Journey</h4><p>I would say I improved both in technical skills as well as social skills in this journey.</p><p>Technically, I improved a lot. I learned about Django Rest Framework best practices. I learned about tools such as mocking, SendGrid, Google Social API, and others I never touched before. I, the dev-ops illiterate, also learned so much about Heroku and CI/CD. Being one of the responsible person in Heroku, I learned about PaaS and how it works.</p><p>Socially, I learned to work in teams. As a person normally working independently, I learned so much on respecting organizational needs above my own. I learn to position myself as a backend engineer, adjusting to front-end engineers. I learn to contribute my thoughts and ideas in team, and I make new, fun friends to work with.</p><h4>What’s Next for Println?</h4><p>After PPL, I am sure our responsibilities as engineer in Println technically ended. This does not mean we will turn a blind eye toward any faults in the system, but this only means our contract work is done. Therefore, it is our responsibility to leave the source code and the system in a good condition. It needs to be reusable, scalable, and readable to those new engineers building Println after this. That is why we learned so much from PPL about refactoring, testing, architecture, etc., to make sure our application is maintainable.</p><p>After PPL, Println will be MIC’s leading product in automatic printing. We hope with all the extra features we built, Println can be the best printing options for anyone needing printing services, not limited to Fasilkom students, but also throughout UI, and hopefully even beyond.</p><p>Println is planned to be sold as a service to printing enterprises to ease their access to customers.</p><h3>My Tasks</h3><p>There are two big PBIs I have been doing in this sprint: Dynamic pricing and forgot password.</p><p>Here are some of my code snippets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*qIOQtT_Q8z2wJlICrpRyvw.png" /><figcaption>Sending Email with SendGrid API</figcaption></figure><p>For automatic email provider, we use SendGrid API v3. It is cheap, has a free sandbox with up to 100 emails/day, and easy to configure. We only need to send the content and mail data to the SendGrid API, and it will be automatically queued to send by SendGrid.</p><p>For dynamic pricing, there are too much code to display. I made four endpoints for front-end to consume, which are:</p><ul><li>Create (POST)</li><li>List (GET)</li><li>Update (PUT)</li><li>Delete (DELETE)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df177f8951e8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/println-mic/week-6-last-individual-review-df177f8951e8">Week 6 — Last Individual Review</a> was originally published in <a href="https://medium.com/println-mic">println-mic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Week 5 — TDD at Println]]></title>
            <link>https://medium.com/println-mic/week-5-tdd-at-println-79c2e0d781e5?source=rss-c64668a630d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/79c2e0d781e5</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[tdd]]></category>
            <dc:creator><![CDATA[Valentina Kania]]></dc:creator>
            <pubDate>Thu, 03 May 2018 14:39:20 GMT</pubDate>
            <atom:updated>2018-05-03T14:48:22.624Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why We Use TDD</h3><p>Test Driven Development, aka TDD, is one of the most talked-about development recently. Some truly implements it, some other hates it. But what makes us adopt TDD in our project?</p><ul><li>Our PPL course requires us to adopt TDD. Lol, kidding. There’s much more than that.</li><li>It helps us to figure out how our implementation is going to be, what functionalities it needs to have, and its expected behavior. When we make the tests, we need to design as many possible cases of the function, and figure our expected output of the cases.</li><li>It helps us find bugs. (Wait, really?) It is way easier for us to figure out which test cases succeed and which ones fail, then we can focus on debugging those failing cases.</li><li>It helps you measure how good your application is. This may or may not work in some cases, but in my case, the fewer the tests, the more the holes of the application. When we do not test, we sometimes forgot negative cases that may happen, introducing more bugs in the middle. With TDD, we can try minimizing bugs and prevent it from the beginning.</li></ul><h3>But, TDD is Difficult…</h3><p>Tell me about it! The first time I was introduced to it, this is what happened to me:</p><ul><li>It really, really slowed down my programming speed. It takes, like, more than 3 times my normal speed to build a simple functionality. 1 speed unit is for building tests, 1 speed unit is for my implementation, and 1 other unit is for figuring out what happened in this code.</li><li>It tested my patience. When I first learned about unit testing, especially mocking, it took me hours (probably even days) to figure out how to mock a single function. It took me hours to mock an HTTP Request without failing all over again.</li></ul><p>But, as we progress, it wasn’t really that bad. It truly helps me to design the expected behavior of my program, as I need to come up with as many negative cases as I can for the tests. I also picked up my speed in building the tests. It also helps me to find holes in my code very quickly, as I do not need manual testing to see where my bugs are. Well, my test coverage will tell me where I screwed up! (Don’t get me wrong, we still do manual testing, just to make it even stronger)</p><h3>How We Use TDD in Println</h3><p>What are the steps of Test-Driven Development?</p><ol><li>Creating tests, and let them fail.<br>This includes creating mock HTTP requests (if needed), preparing stubs (empty classes, empty function, and URL path) just enough to make it FAIL, not ERROR. <br>Error is a condition where an exception is raised, without any handler catching it, usually because a function is not yet defined (hence we create stubs). But failing, is a condition where there is no exception, but the function does not behave as expected (because it’s still a stub, an empty function).<br>In Gitlab commit, we usually tag it <strong>[RED]</strong>, and have our CI pipeline failing and shows red.</li><li>Code the implementation to make the tests pass.<br>Do your normal coding. Implement the function. Don’t forget to run the tests to make sure it passes all tests. If there is one, or more, failing tests, debug it. It is easier to trace it from failing cases as you can focus only on part of the code that may be responsible on the failing tests.<br>In Gitlab commit, we usually tag it <strong>[GREEN]</strong>, and have our CI pipeline passing, and shows a green tick.</li><li>Refactor the codes for better implementation.<br>Do it as needed. Clean up the dirty comments, make better variable names, change the magic numbers to constants, and implement the clean coding. The second step of TDD was usually only focusing on how to make the tests pass, so this stage is for us to clean our codes. Don’t forget to check for the linter warnings! This is the part where I always forgot, so sometimes my tests are 100% coverage, but my CI produces errors because I kept forgetting about checking for linter warnings. No worries, after some weeks I started to get used to it, and always check for linter warnings before pushing my codes.<br>In Gitlab commit, we usually tag it <strong>[REFACTOR]</strong>, and have our CI pipeline passing, and shows a green tick, just as the green one. It’s because refactoring are never supposed to change the external behavior of the function.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79c2e0d781e5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/println-mic/week-5-tdd-at-println-79c2e0d781e5">Week 5 — TDD at Println</a> was originally published in <a href="https://medium.com/println-mic">println-mic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Week 5 — Software and Everything]]></title>
            <link>https://medium.com/println-mic/week-5-software-and-everything-d01f51225ad5?source=rss-c64668a630d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/d01f51225ad5</guid>
            <category><![CDATA[continuous-integration]]></category>
            <dc:creator><![CDATA[Valentina Kania]]></dc:creator>
            <pubDate>Wed, 02 May 2018 15:42:04 GMT</pubDate>
            <atom:updated>2018-05-03T04:40:33.223Z</atom:updated>
            <content:encoded><![CDATA[<h3>CI/CD?</h3><p>Continuous Integration is an automation process for building and testing an application, triggered by a commit pushed within a repository. Continuous Integration is a stage where all developers’ code are integrated into one, in our main repository, PPL-C3, at Gitlab. In this stage, codes we commit are merged into a branch associated to a certain PBI, and tested to make sure that our code integrates well with the existing system. I have put the code snippet in my previous blog, and the main points are that our CI scripts do is that we run three tests: test_frontend and test_backend and test_microservice. All tests are executed everytime someone pushes to any branch in the repository.</p><p>After the three tests are passed, we move to the CD stage.</p><p>Continuous Deployment is a stage where after CI stage is passed, any changes in the application is automatically deployed to a server. This is why it’s called continuous deployment. We deploy, continuously, after changes are made. At Println, we activate our CD Pipeline to run to our Heroku server. Code snippet also put in my previous blog.</p><h3>Heroku as PaaS, and Why It’s Better for Println</h3><p>A month ago, we decided to serve our production app in DigitalOcean, an Infrastructure as a Service (IaaS) platform. Our DevOps engineers (re: Mamad &amp; Gunawan) spent almost two days setting up the server, programming in Bash scripts, reliving their Sysprog memories. This setup is super complicated, because DigitalOcean provides the infrastructure of a server to us. Meaning, we have the freedom to choose our infrastructure (like our RAM, memory, OS, etc), but we need to set them up ourselves. Basically, it’s like we buy our own computer, but someone maintains the hardware for us. Powerful, for large apps, but takes too much time, especially for students like us.</p><p>On the other hand, Heroku provides a platform for us to develop, run, and manage our application, without having to set up the other things. Bam, I set up not just one, but TWO servers (front-end and back-end server), which only consists of setting up the buildpacks (we use Python and Node.js buildpacks), setting up database (using Postgres; the free version), and configure the environment variables, AND changed the CD script in less than two hours. Well, that was quick.</p><p>See below for comparison.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Lw6zCa6-SrcpExjLivIeg.jpeg" /><figcaption>IaaS vs PaaS, vs SaaS</figcaption></figure><p>This is why, setting up Heroku is way much easier than DigitalOcean, and we’re glad we moved it back to Heroku.</p><h3>Software Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*vnQNNG6eEsFuXIP4P-uccQ.png" /><figcaption>New and improved version of Println architecture (cr: Master Hustler)</figcaption></figure><p>Legend:</p><ul><li>straight arrow : request flow</li><li>dotted arrow : response flow</li></ul><p>Tech stack:</p><ul><li>Frontend : React.js</li><li>Backend : Django Rest Framework, with PostgreSQL as DB</li><li>Microservice : Node.js</li><li>Dropbox : to save user files</li><li>RajaSMS : to send notification to user</li></ul><h3>What architecture are we using?</h3><p>There are many architectural patterns in software development, such as monolithic (where one app handles all), client-server (server provides a resource, client requests it), and one of the most well-known today, also implemented in Println, is <strong>microservices architecture</strong>.</p><p>Microservices architecture is a software architecture based on Service-Oriented Architecture (SOA), which divides its software into several small loosely-coupled services. Each service is modular and only responsible for a certain task domain. Currently, we have only one microservice, which is the print job service. This service is responsible for handling print jobs coming, printing them to the printer attached to its computer, and updating the status of the job.</p><p>Our implementation of microservices architecture is not yet perfect, since our backend app is not yet separated into small services. This is because in our current stage of development, we have yet to see that separating the codes are worth the time, and our application is still small. However, in large application systems, such as Tokopedia, Traveloka, etc., applications are separated into several services with specialities, such as payment, account, bookings, etc.</p><p>Other than microservices architecture, Println also seems to implement <strong>client-server pattern</strong>, because resources in the user are accessed via front-end, requested to the back-end. Our implementation of REST APIs also supports this argument. REST API helps us to separate concerns on front-end and back-end, so that client and server can communicate with low coupling, which improves the maintainability of Println.</p><p>Seen from the other perspective, we can also see it as a <strong>layered pattern</strong>, where each service is a layer responsible for its task. Frontend is the UI layer, the backend and the microservice is the application layer, and the database and Dropbox is the persistence layer. (Thanks to Intan)</p><p>Why do we choose this?</p><ul><li>Low coupling: easier to maintain, no need to understand the whole part/code because each service has its own responsibilities, not highly dependent to each other</li><li>High scalability: because of low coupling, each service can grow interdependently and be developed separately, without having to wait for each others’ services</li></ul><p>Source : <a href="https://doc.lagout.org/programmation/Django/Django%20Design%20Patterns%20and%20Best%20Practices%20%5BRavindran%202015-03-26%5D.pdf">https://doc.lagout.org/programmation/Django/Django%20Design%20Patterns%20and%20Best%20Practices%20%5BRavindran%202015-03-26%5D.pdf</a></p><p><a href="https://towardsdatascience.com/10-common-software-architectural-patterns-in-a-nutshell-a0b47a1e9013">https://towardsdatascience.com/10-common-software-architectural-patterns-in-a-nutshell-a0b47a1e9013</a></p><h3>What Have I Done?</h3><ul><li>IsNotBanned permission: only a not banned user can access all the resources of Println</li><li>Manual QA Testing: automated testing is a good way to test if our codes work, but manual testing is also important. We need to make sure the APIs are understood well, the UI is responsive, and the code works under every circumstances.</li><li>Backend Documentation: I made a documentation for PrintTransaction APIs, for other developers to understand the payload, response, etc of the PrintTransaction endpoint. The documentation is published on Postman.</li><li>Dynamic Pricing: To allow admins to set up dynamic pricing, and to control it from their dashboard. Backend task.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d01f51225ad5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/println-mic/week-5-software-and-everything-d01f51225ad5">Week 5 — Software and Everything</a> was originally published in <a href="https://medium.com/println-mic">println-mic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Week 4 — Refactoring Codes & Software Architecture]]></title>
            <link>https://medium.com/println-mic/week-4-refactoring-codes-software-architecture-fd1b17972c30?source=rss-c64668a630d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd1b17972c30</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Valentina Kania]]></dc:creator>
            <pubDate>Tue, 17 Apr 2018 16:08:32 GMT</pubDate>
            <atom:updated>2018-04-18T07:59:32.979Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*dldR8ybIFAlmw8_5IIaaiw.jpeg" /></figure><h3>Code Refactoring &amp; Cleaning</h3><p>This week, I refactored my codes regarding to the print transaction flow.</p><p>Here are some examples of what I did.</p><p><strong>Refactoring Status Codes to Communicate with MS</strong></p><p>First, I made the status codes without really think about what might happen with the Microservice, and not communicate it well with the developer. Hence, my status code is ‘meh’. Then, it just got worsened by my fellow developer, which added PROCESSED status code after DONE. This is definitely not intuitive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/205/1*jsXyPl3LuWMvBwqfJ-iESw.png" /><figcaption>The code before refactor. Who puts processed after done?!</figcaption></figure><p>So, I refactored it. I made sure that the codes are intuitive enough to read, such as -1 for ERROR, and everything else is sequential. This also implemented the <strong>boy scout rules</strong>, meaning, leave the place cleaner than when you arrive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/1*E6E0x9dmEGAHrTOVHUSA7g.png" /><figcaption>Better, less ambiguous status codes</figcaption></figure><p>Other than refactoring the implementation, we also need to refactor the tests, to make sure the code still functions after the refactor. This includes adding the new fields, adjusting to the new object attributes, etc. These tests need to be solid, and self-checking, so we didn’t waste time just to check them ourselves, and possibly find bugs in our old codes. (At least this is what I got from Martin Fowler)</p><p>One example of a major refactor I did was flattening Transaction and PrintHistory object into one, PrintTransaction. This is done because initially, I thought these two objects were to communicate with different consumers, Transaction is to microservice as PrintHistory is to frontend, and later discover that these objects are better flattened, to improve database queries, reduce coupling, and easier to maintain. These two objects can also be categorized as “Lazy Class” by Fowler, because Transaction object turned out not being able to serve its purpose without PrintHistory, it is dependent which made it kinda useless on its own.</p><p>First, I moved my tests. I adjusted the tests to the new model, altered the necessary fields, and renamed the tests to match with the name of the new model, view, and serializers.</p><p>Then, I refactor the whole PrintTransaction model. I deleted the old ones, and created a model consisting of all fields from both old models. Then, I adjusted the serializers and the views according to the model.</p><p>Despite the huge revamp, this should still be considered refactoring. How? It does not change how the backend communicate with the microservice nor the client, except a few status code adjustment above. We still provide the same endpoint to the API consumers, requested the same fields, and provided the same response.</p><p><strong>Errors and Exceptions Handling</strong></p><p>Most errors inside the backend are handled by Django Rest Framework middleware, so we do not have to implement them ourselves. However, I do understand that there are ways to implement exception handling in custom way, which is by adding a custom middleware.</p><p>This middleware catches whenever a code raises a certain error, and returns a DRF Response object, with a message and status code. We also need to list in in Django project settings, to register some sort of listener throughout the app.</p><p>We don’t implement these custom middleware because the provided Django middlewares are sufficient to handle exceptions in our projects. Some errors we raise, and believe that Django handles are:</p><ul><li>ValidationError() —raised by Serializer classes when a field is not validated, returns 400 Bad Request with the details of the validation errors</li><li>AuthenticationError() — raised by Authentication classes when all forms of authentication fails to authenticate a request, returns 401 Unauthorized</li><li>Http404() — raised by get_object_or_404 method if an object is None or not found, returns 404 Not Found as a REST Response</li></ul><p>and many others.</p><p><strong>Clean Codes as Explained by Guest Lecturers</strong></p><ul><li>Use linting tools — we do, we use pycodestyle for our linting tools, to make sure our code is indented correctly to improve readability</li><li>Make each method maximum of a screen length — I always try to keep my methods under 30 lines, which can be seen on my Gitlab account</li><li>Make your code self-explanatory — I always try to use variable and constant names as descriptive as possible, and keep them consistent throughout the app (such as naming all transaction-related objects with PrintTransaction prefix all over the models, serializers, views)</li><li>When your code is self-explanatory, comments are unnecessary</li></ul><h3>Design Pattern inside Println</h3><p>In Println backend, we use Django REST Framework. DRF is using Model-View-Serializers pattern. As much as it sounded like MVC pattern, these two are not related.</p><ul><li>Template Pattern: we use ViewSets to help defining our views to the consumers, as ViewSets provide some methods for us to override, such as: retrieve, list, create, update, partial_update, destroy. We do implement many of them in our ViewSets, like these:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*Z80LCSTU9vF2BUtnZHDD3w.png" /><figcaption>Implementing list and partial_update views</figcaption></figure><ul><li>Observer Pattern: as explained above, many Django classes observe and listen to our signals, such as errors, or when a certain event happens, every subscribing classes or methods are notified automatically. An example of these is Middleware.</li><li>Facade Pattern: Serializer can be considered as a facade to the Model. This allows Views to perform certain actions to the Model, without actually modifying the Model itself. We do implement Serializer, such as its create, validate, and update functions.</li></ul><p>There are so many other patterns, like Object Relational Structural Pattern, implemented in Django, and the list goes on and on, so I decided to only explain three of them.</p><h3>Software Architecture</h3><p>A software architecture is defined as a structure of a software system, including the software elements itself and the relations between elements.</p><p>There are many architectural patterns in software development, such as monolithic (where one app handles all), client-server (server provides a resource, client requests it), and one of the most well-known today, also implemented in Println, is microservices architecture.</p><p>Microservices architecture is a software architecture based on Service-Oriented Architecture (SOA), which divides its software into several small loosely-coupled services. Each service is modular and only responsible for a certain task domain. Currently, we have only one microservice, which is the print job service. This service is responsible for handling print jobs coming, printing them to the printer attached to its computer, and updating the status of the job.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5jakbhPX6fBd-fc-ignuMg.jpeg" /><figcaption>An ugly writing by me about the communication of our system in Println</figcaption></figure><p>Our implementation of microservices architecture is not yet perfect, since our backend app is not yet separated into small services. This is because in our current stage of development, we have yet to see that separating the codes are worth the time, and our application is still small. However, in large application systems, such as Tokopedia, Traveloka, etc., applications are separated into several services with specialities, such as payment, account, bookings, etc.</p><p>Other than microservices architecture, Println also seems to implement client-server pattern, because resources in the user are accessed via front-end, requested to the back-end. Our implementation of REST APIs also supports this argument. REST API helps us to separate concerns on front-end and back-end, so that client and server can communicate with low coupling, which improves the maintainability of Println.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*Sb92HE_F6WhL7mL9uneb6Q.png" /><figcaption>How Println basically works</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd1b17972c30" width="1" height="1" alt=""><hr><p><a href="https://medium.com/println-mic/week-4-refactoring-codes-software-architecture-fd1b17972c30">Week 4 — Refactoring Codes &amp; Software Architecture</a> was originally published in <a href="https://medium.com/println-mic">println-mic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Week 9 — Deployment, Software Architecture, and User Profiles]]></title>
            <link>https://medium.com/println-mic/week-9-deployment-software-architecture-and-user-profiles-d4ba02ac1786?source=rss-c64668a630d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4ba02ac1786</guid>
            <dc:creator><![CDATA[Valentina Kania]]></dc:creator>
            <pubDate>Tue, 03 Apr 2018 17:21:43 GMT</pubDate>
            <atom:updated>2018-04-04T07:43:53.939Z</atom:updated>
            <content:encoded><![CDATA[<p>So, between week 7 and week 9, what have I done?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0xThN67QmQrdTryi_XwCFQ.png" /><figcaption>Gitlab CI/CD Flow</figcaption></figure><h3>Deployment — Software Environment</h3><p>Software Environment is a term used to refer to an environment that supports a software, including operating system, database, specific tools or container, even hardware tools (if applicable, like a printer, for Println).</p><p>Last week, some of our first features were reviewed on Sprint Review with our Product Owner and the lecturers. If our features merged in SIT (System Integration Testing) UAT (User Acceptance Testing) environment are accepted, they would be deployed to production. There are three major environments in Println, staging (we also call them coba_coba), SIT UAT, and production.</p><h3>What We Use</h3><p>We are using CI/CD tools from Gitlab, configuring the scripts for test and deploy in a .gitlab-ci.yml file. We define our CI/CD environment variables in Gitlab Settings.</p><h3>Staging Environment</h3><blockquote>A staging server is a mirror of the production business management server. — Microsoft Developer Network</blockquote><p>Staging environment is an environment created to mimic production environment, used for testing purposes. In Println, staging environment is connected to every branch except sit_uat and master; meaning every story branch is connected to this environment.</p><p>Everytime someone pushes to a story branch, the CI/CD script will run two tests, called test_frontend and test_backend. If both tests pass, the script will run a deployment stage to the staging server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*b3W52FO-xlDi7XScHunO-w.png" /><figcaption>Script for deploy_staging</figcaption></figure><h3>SIT UAT Environment</h3><p>SIT UAT environment, just as its name, is an environment for testing, System Integration Testing and User Acceptance Testing.</p><p>The first step, System Integration Testing, tests how our current feature works with the currently merged system, how it integrates with the others, and testing the system as a ‘whole’ (the current whole, not the real whole application). In this environment, we can detect if a feature is conflicting with another feature, if the product flow does not work as expected, etc.</p><p>User Acceptance Testing tests whether our users would be satisfied with our current product. For Println, our users are the stakeholders. This is why this SIT UAT environment is the environment exposed to the stakeholders in Sprint Review.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*QwNd4jxQi4qt4nYERD-a5w.png" /></figure><h3>Production Environment</h3><p><em>News flash: </em>Our production server is currently moved again to Heroku.</p><p>Well, production environment is a real environment. It hosts the real working application of Println, contains the real database, and (ideally) interacts with the real target users of Println. Basically, it is published. That is why the process of deploying an application to this environment needs a long process and checking.</p><p>After we test our features in the SIT UAT environment, Println stakeholders, which consist of MIC representatives, lecturers, and the scrum team, meet together in what we call a Sprint Review, and have the available features tested. If our features are accepted without notes, or if the notes are already resolved, we can directly create a PR from sit_uat branch to master branch, where the CI/CD script will deploy our application to the production environment. In Println, only the Scrum Master has access of running the CI/CD job to production environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*wRgMqcJPaFEpoEu2Fv30Eg.png" /></figure><h3>What Have I Done?</h3><ul><li>Creating endpoint for Edit Profile — I learn something, it is better to use ViewSets than APIView, how to create better Response format for our Frontend engineers</li><li>Writing API Documentation — again, to help our frontend engineers understand what our REST APIs are doing. We are currently writing in Markdown files, and we are planning to write in YAML in this sprint</li><li>Deployment, again and again — last week, our Heroku account got suspended due to concurrent build limit, so we need to move our server to a new account. Then, just last night, our Product Owner decided not to fund our production server anymore, so we needed to move the production server to a new, fast, and free one: Heroku.</li><li>ES6 — I wrote two teeny tiny functions in Javascript, to create a file validation system. And I learned a little about Enzyme, the testing library.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4ba02ac1786" width="1" height="1" alt=""><hr><p><a href="https://medium.com/println-mic/week-9-deployment-software-architecture-and-user-profiles-d4ba02ac1786">Week 9 — Deployment, Software Architecture, and User Profiles</a> was originally published in <a href="https://medium.com/println-mic">println-mic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Week 2 — Agile Development in Println, and Implementing Login-Logout]]></title>
            <link>https://medium.com/println-mic/week-2-agile-development-in-println-fff175cc9852?source=rss-c64668a630d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/fff175cc9852</guid>
            <category><![CDATA[agile-methodology]]></category>
            <dc:creator><![CDATA[Valentina Kania]]></dc:creator>
            <pubDate>Wed, 21 Mar 2018 13:57:46 GMT</pubDate>
            <atom:updated>2018-04-04T07:47:18.407Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*t2QZoWzFtHResc-bi0pwzg.jpeg" /><figcaption>Just fresh fun stuff to keep you engaged</figcaption></figure><p>Hey, there! In building Println, we are using Agile Methodology as our development framework. Aside being mandatory for the Software Projects course, Agile has been helping us to keep on track on our progress to reach our goal.</p><h3>What is Agile?</h3><p>Being one of the most popular frameworks used in tech companies today, Agile focuses on delivering products in fast, iterative, and agile way.</p><p>Agile is a software development method where works of developing a product is divided into short phases (called sprints) with each sprints focuses on certain deliverables, adaptive of changes in requirements, and frequent reviews and assessment.</p><p>Agile Methodology is created as software business is now highly competitive, those who cannot keep up faster than the others cannot survive. This is why there is Agile Manifesto, the basic concepts of Agile explained.</p><h3>Agile Manifesto</h3><blockquote>We are uncovering better ways of developing software by doing it and helping others do it.<br>Through this work we have come to value:</blockquote><blockquote><strong>Individuals and interactions</strong> over processes and tools<br><strong>Working software</strong> over comprehensive documentation<br><strong>Customer collaboration</strong> over contract negotiation<br><strong>Responding to change</strong> over following a plan</blockquote><blockquote>That is, while there is value in the items on the right, we value the items on the left more.</blockquote><h3>Building our Product: Project Vision and User Stories</h3><p>The scrum journey in Println starts by planning our main product. Using Business Canvas, our team with the Product Owner (Microsoft Innovation Centre), listed down problems and ideas which we wanted to focus on. As Println is not completely new in our faculty (we have, not one, but <strong>two</strong> similar existing products widely-used by students), the stakes are really high if we wanted to stand out. From our meeting with the PO, we made our project vision, defining our objectives, goals, and our limitations.</p><p>On ideation phase, our hipster created mockups for Println, which are amazingly pretty, tested our mockups to some friends, and asked for feedbacks.</p><p>After planning our objectives, we started to plan on user stories. <strong>What</strong> do users want to be able to do within Println? <strong>Why</strong> do they want that? And <strong>how</strong> are they going to achieve that? These users stories keep us to focus on building features our users really need. Some examples of user stories in Println are:</p><ul><li>As a user, I want to be able to upload a file to Println, so I can print it or save it for later.</li><li>As an administrator, I want to be able to see my printing statistics, so I can make monthly reports to my boss.</li></ul><h3>Sprint, Product Backlog, and Tasks</h3><p>A sprint, in software development, means a set of period where a team works on a few backlogs, based on priority. Meaning, sprints are periods where we focus on developing certain features planned in the beginning of sprint period, called Sprint Planning. How long is a sprint? This depends on the Scrum Master, I know some companies doing a sprint weekly, biweekly, but in Println, we are doing it monthly, taking other college courses into account.</p><p>Wait, what’s a Scrum Master? <em>No, it’s a who</em>. A scrum master is someone responsible to lead or facilitate the whole scrum development process. They are the moderator on our meetings.</p><p>Before babbling about sprints and its flow, one important term needs to be explained. Product backlog. It is a more concise version of a user story. Product backlog is a list of items needed to exist in a product. It is a medium of how business people communicate with engineers on what needs to be built. Therefore, it has to be concise, descriptive, and easy to understand. No heavy technical terms. A single item in backlog is called PBI, stands for Product Backlog Item. Every PBI has a weight, or story point, or just point, to represent the difficulty of the item. In Println, we use the Fibonacci story point system, within the range 1–8. When thinking of each point, each of our member give estimates on a PBI. There were moments where one of us give 2 points, while the other gives 8. In this case, each of the extreme points giver would explain their estimation, why, and what aspects they think are important. This discussion helps us agree on a number for each points, and understand underlying problems that we might not have thought of before being pointed out by the other members. One unique motto Println members do on giving points are “fear of the unknown”, where we may give bigger points on items we do not know how we would implement yet, so it can give us rooms for learning and exploration.</p><p>Alright, so how does this sprint thing works? It all started with a sprint planning. In sprint planning, we discuss on what product backlogs are prioritized to develop in this period. This is why, on Scrum Board (explained below), PBIs are sorted by priority, highest to lowest. Each planning, we pick n items from Product Backlog, n depending on their points and our capability, and put them on Sprint Backlog. These items are our goals of the current sprint.</p><p>We define our Sprint 1 goal as “User can upload a file”, as we have so many PBIs on our Backlog. We also define our Definition of Done.</p><p>As a PBI is still too vague for us developers, we break them down into Tasks. Each task needs to be done in approximately 6 hours. We made 40 tasks throughout 6 PBIs. In Tasks, we use technical terms to define functions, tests, and implementation of a feature.</p><h3>Scrum Board and the Not-so-Daily Meetings</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_YpTlBHShW1XmfABMWXIPg.jpeg" /><figcaption>Our Scrum Board</figcaption></figure><p>A daily meeting, standup meeting, or scrum meeting, is a regular meeting among scrum team and their master to report their progress. In Println, we don’t do this everyday, instead we report every Tuesday and Thursday. There will be 8 meetings in one sprint.</p><p>Each daily meeting, we report on what we’ve done, what we are doing, and what task we will take later. We also clear up some technical confusion (like what parameters our front-end developers want us to accept, whether there is any request on the JSON Response format, etc.), ask for probably some advice when we are stuck on a problem, and synchronize our minds.</p><p>On each implementation we make, we need to make sure our deliverables follow the Definition of Done, task-wise or PBI-wise. One of the hardest Definition of Done for me to implement being 100% code coverage, of course, since we need to make sure all statements, all branches are covered. With all sweat and tears, we refactor codes, we check on logic, and finally managed to get 100% code coverage on every file we write.</p><h3>Sprint Review and Retrospective</h3><p>At the end of our sprint, we will face Sprint Review. A sprint review will be attended by the scrum team, scrum master, and stakeholders. In this case, our product owner (MIC), and our lecturers. We will demonstrate our deliverables (what we built on said sprint), and our stakeholders will decide whether to accept our product. PBI-wise, every items on the sprint backlog needs to be Done, by putting them to the Done Tasks, and obey our definition of done.</p><p>Retrospective is also a time when instead of reviewing the product, we review ourselves, and the team. We report on what we learned during the sprint, what we need to improve, and our improvement plan next. We also review our team work, how we communicate with others, or if there was problem within the team that slows down the development process.</p><h3>The Dirty Codes</h3><p><strong>What have I learn these two weeks?</strong></p><ul><li>Mocking a REST request for testing, consisting of REST nature, request and response headers, request &amp; response body, and status codes</li><li>Django REST Framework: Model — View — Serializer, how they work, and how to implement them</li><li>Django Auth: Extending their login and logout functionality, Permissions classes, and Token Authentication</li><li>Software Deployment: What you should do when your deployment SaaS has bug in their codes, setting environment variables and integrating database, adding migration as a release build before running applications</li></ul><p>Yesterday, pip and setuptools were updated to newer version. Heroku Python buildpack upgraded their pip, but forgot to upgrade their setuptools. Hence, an error on our backend deployment (frustrating!).</p><ul><li>Integration with Client: Cross Origin Resource Sharing setup</li></ul><p>Without CORS setup, client automatically rejects resources (including JSON responses) without Access-Control-Allow-Origin header. In Django, we can specify which Origin are accepted (with ALLOW_ALL, fixed sets, or regex!) using django-cors-headers. This problem was found when we tried to integrate our backend with the client code.</p><p><strong>What’s coming?</strong></p><ul><li>React.js — yeah, I will finally come to the dark side (aka client side)</li><li>Deeper understanding of Django Rest Framework</li></ul><p>More info:</p><p><a href="https://gitlab.com/PPL2018csui/Kelas-C/PPL2018-C3/tree/sit_uat">https://gitlab.com/PPL2018csui/Kelas-C/PPL2018-C3/tree/sit_uat</a></p><p><a href="https://gitlab.com/PPL2018csui/Kelas-C/PPL2018-C3/tree/login-logout">https://gitlab.com/PPL2018csui/Kelas-C/PPL2018-C3/tree/login-logout</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fff175cc9852" width="1" height="1" alt=""><hr><p><a href="https://medium.com/println-mic/week-2-agile-development-in-println-fff175cc9852">Week 2 — Agile Development in Println, and Implementing Login-Logout</a> was originally published in <a href="https://medium.com/println-mic">println-mic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Week 1 — Social OAuth with Django]]></title>
            <link>https://medium.com/println-mic/week-1-social-oauth-with-django-26ce7bf28a25?source=rss-c64668a630d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/26ce7bf28a25</guid>
            <category><![CDATA[django-rest-framework]]></category>
            <category><![CDATA[oauth]]></category>
            <dc:creator><![CDATA[Valentina Kania]]></dc:creator>
            <pubDate>Wed, 07 Mar 2018 20:09:54 GMT</pubDate>
            <atom:updated>2018-03-07T21:19:47.777Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/230/1*ulWobiFO14chXHojbOtQWw.png" /><figcaption>Println Social Login</figcaption></figure><p>When building a product, we need to take into account how our users are going to register and log themselves in to our apps. While manual sign in is still sufficient, connecting our app to existing social media account is way faster and more convenient for our users. Especially, when your app is small, most people won’t bother creating a new account just to get inside your app. Hence, Social OAuth becomes more widely-adopted, and now implemented in our Cloud Printing Application, Println.</p><p>On my first week of Sprint 1, I got the task to learn about OAuth process and implementing Google OAuth to my application for Software Projects class, Println. Here is what I learned so far.</p><h3>The Google Auth Flow</h3><p>Basically, the Google authorization flow for web applications goes like this:</p><ol><li><strong>Asking User’s Permission via Google Authorization Server<br></strong>After clicking on the Sign In with Google button for the first time, user will be redirected to a page where user will be asked to grant permission on their data, such as email, contacts, and basic profile info. For Println app, we will be asking all permissions needed to access Google OAuth2 API v2.<br>Upon submission, Google Authorization Server will provide us an authorization code.</li><li><strong>Exchanging Authorization Code to Access Token</strong><br>The client-side app will send a POST request to Google with the authorization code in exchange for a short-lived access token and a refresh token, which we will use to access the Google API.</li><li><strong>Requesting data from Google API using provided Access Token<br></strong>After receiving access token, our application server will make a request to Google API. Google will return user information as defined in our scopes before in point 1.</li><li><strong>Doing Whatever We Need with the Data<br></strong>In this case, our user info will be used to create an account, if a user with associated email is not yet registered, or to log a user in, if the email is already registered as our user.</li></ol><p>Implementing Social OAuth client can be troublesome, especially because different social media platforms have different rules and protocol for their OAuth clients. In Python, though, we can use the widely-used Social Auth library, which encapsulates the authentication process, and automatically create or log users in to our app, so we can focus on the next steps.</p><h3>Python Social Auth</h3><p>Python has a robust social auth library called Python Social Auth (now split to <a href="https://github.com/python-social-auth/social-core">social-auth-core</a> and other framework-based modules to improve scalability; Django: <a href="https://github.com/python-social-auth/social-app-django">social-auth-app-django</a>). It’s not only applicable for Google OAuth, in fact, they provide sign in/up modules for many social platforms like Facebook, Github, etc. (full list <a href="https://python-social-auth.readthedocs.io/en/latest/intro.html#auth-providers">here</a>)</p><p>Because I am using Django’s User object, I only need to implement an AuthSerializer and respected API View.</p><pre>class AuthSerializer(serializers.Serializer):</pre><pre>    access_token = serializers.CharField(</pre><pre>        allow_blank=False,</pre><pre>        trim_whitespace=True,</pre><pre>    )</pre><p>for the views/auth.py:</p><pre>@api_view(http_method_names=[&#39;POST&#39;])<br>@permission_classes([AllowAny])<br>@psa()<br>def exchange_token(request, backend):<br>    serializer = SocialSerializer(data=request.data)<br><br>    if serializer.is_valid(raise_exception=True):<br>        # This is the key line of code: with the @psa() decorator above,<br>        # it engages the PSA machinery to perform whatever social authentication<br>        # steps are configured in your SOCIAL_AUTH_PIPELINE. At the end, it either<br>        # hands you a populated User model of whatever type you&#39;ve configured in<br>        # your project, or None.<br>        user = request.backend.do_auth(serializer.validated_data[&#39;access_token&#39;])<br><br>        if user:<br>            # if using some other token back-end than DRF&#39;s built-in TokenAuthentication,<br>            # you&#39;ll need to customize this to get an appropriate token object<br>            token, _ = Token.objects.get_or_create(user=user)<br>            return Response({&#39;token&#39;: token.key})<br><br>        else:<br>            return Response(<br>                {&#39;errors&#39;: {&#39;token&#39;: &#39;Invalid token&#39;}},<br>                status=status.HTTP_400_BAD_REQUEST,<br>            )</pre><p>(courtesy of Toptal, link below)</p><h3>Testing</h3><p>As a good TDD developer, I created (more like, copied-and-pasted from Github) some tests before implementing my functions to make sure that my code works with the expected cases.</p><p>On TDD, the tests are created first, along with the stubs (to avoid syntax errors), but we leave them all to fail. These unit tests define our acceptance criteria. That way, we are enforced to implement our code in a way to satisfy all the tests.</p><p>The tests are created to check if the code will work (i.e. does not crash) under these expected cases:</p><ul><li>A user has not registered themselves</li><li>A user has registered their social media account before, and wants to log in</li><li>A user has registered, and at one point, deleted their account, so they should not be able to log in anymore</li><li>An invalid/expired access token is given</li><li>Access token is empty</li></ul><p>I implemented them in my TestGoogleAuth class which inherited APITestCase class, and RequestsMocks class from <a href="https://github.com/getsentry/responses">responses</a> as Context Manager. Why not just unittest mock? Or HTTPretty? As we are trying to mock an API Request with requests library, unittest mock is out of the question. This leaves us with HTTPretty, a complex library that mocks HTTP protocol and give custom responses. However, in this project, I am using responses library, which claims to be the appropriate mocker for requests library.</p><pre><a href="http://twitter.com/contextmanager">@contextmanager</a><br>def mocked(endpoint):</pre><pre>with responses.RequestsMock() as rsps:<br>        rsps.add_callback(responses.GET, endpoint,<br>                          callback=respond_to,<br>                          content_type=&#39;application/json&#39;,<br>                          match_querystring=True,<br>                          )<br>        yield rsps</pre><p>(again, thanks to Toptal)</p><p>However, testing this API feature on Postman requires a real token that your social media provider would accept, which, for Google OAuth, can be obtained <a href="https://developers.google.com/oauthplayground/">here</a>. You can select scopes or APIs that you want to get access to, and exchange your authorization code with an access token, too!</p><h3>Some Notes so I can be graded on my course…</h3><h3>Git</h3><p>Our team has applied Git workflow as instructed. As this week’s task focuses on Register backlog, our team created a branch called ‘register’ based on ‘sit_uat’ branch. Each developer codes in a new file to minimize conflicts.</p><p>I also implemented the RED, GREEN, REFACTOR commit, with details as follows:</p><ul><li>[RED] commit tag, used on commit regarding unit tests that fail because functions are not yet implemented</li><li>[GREEN] commit tag, used on commit regarding function and class implementation, with all unit tests pass (OK)</li><li>[REFACTOR] commit tag (not yet used), should be used on commit regarding refactoring, cleaning codes, and renaming.</li><li>No commit tag, used on other commit messages, such as updating settings, creating code skeletons, etc.</li></ul><p>Cheers!</p><p>Valentina — 1506757264</p><p><strong>P.S.</strong> Special thanks to this site which helped me a lot on building this feature: <a href="https://www.toptal.com/django/integrate-oauth-2-into-django-drf-back-end">https://www.toptal.com/django/integrate-oauth-2-into-django-drf-back-end</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26ce7bf28a25" width="1" height="1" alt=""><hr><p><a href="https://medium.com/println-mic/week-1-social-oauth-with-django-26ce7bf28a25">Week 1 — Social OAuth with Django</a> was originally published in <a href="https://medium.com/println-mic">println-mic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>