<?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 Bacarpereira on Medium]]></title>
        <description><![CDATA[Stories by Bacarpereira on Medium]]></description>
        <link>https://medium.com/@bacarpereira19?source=rss-2a772ea513c6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*UIjU76PWB_EWXiIS49aldw.jpeg</url>
            <title>Stories by Bacarpereira on Medium</title>
            <link>https://medium.com/@bacarpereira19?source=rss-2a772ea513c6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 20:26:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bacarpereira19/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[5 tricks I use frequently so I don’t lose track of the code]]></title>
            <link>https://medium.com/@bacarpereira19/5-tricks-i-use-frequently-so-i-dont-lose-track-of-the-code-ca49a3f39a4f?source=rss-2a772ea513c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca49a3f39a4f</guid>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[software-best-practices]]></category>
            <dc:creator><![CDATA[Bacarpereira]]></dc:creator>
            <pubDate>Sat, 27 Aug 2022 00:52:50 GMT</pubDate>
            <atom:updated>2022-08-27T16:48:51.146Z</atom:updated>
            <content:encoded><![CDATA[<h3>5 tricks to never lose control of your code</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LB--uW2nOTfCPQYbcicR7w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@ianplaytheworld">Ian Romie Ona</a> on <a href="https://unsplash.com/photos/OjdR0mn9xPA">Unsplash</a></figcaption></figure><p>Nowadays it is common to see projects get out of the developers control easily and for this reason companies tend to value programmers who understand topics like Architecture, DI (Dependency Injection), unit testing, OOP (Object Oriented Programming), Design Pattern.</p><blockquote><strong>But what is losing control of the code anyway?</strong></blockquote><p><em>A short answer is if you </em><strong><em>always </em></strong><em>affect (crashes) an existing feature whenever a new feature is requested by the customer then the code is out of control.</em></p><p><em>Another point is that if a new bug appears </em><strong><em>whenever </em></strong><em>an old one is fixed, and with each bug fixed the time to resolve the next bug grows then the code is out of control.</em></p><p><em>If your controllers or components have many lines of code like for example 500, 1000, 2000 lines it is a red flag that possibly the code is heading towards disaster.</em></p><h3>Next, I’ll show you the 5 tricks I use frequently so I don’t lose track of the code</h3><h3>1. Architecture</h3><p>Architecture is very important because it allows the project to grow with a unique structure by striving for the programmers in the project to follow a unique structural convention and this is very important because projects must have a standard to facilitate any kind of change and help new team members to understand the project easily.</p><p>A code that doesn’t follow any architecture is out of control because it won’t have any organizational pattern and for every change that has to be made programmers will get lost in the files and spend a lot of time trying to locate and test them (Test code that doesn’t has no architecture is nearly impossible).</p><h4>Choosing an architecture that suits your project will give you the following benefits:</h4><ul><li>It will be easy to maintain the software;</li><li>The system can be easily refactored;</li><li>It will contribute to the non-repetition of code;</li><li>The team can easily add features and facilitate processes to improve system performance;</li><li>It will facilitate testing and scalability.</li></ul><h3>2. DI (Dependency Injection)</h3><p>Dependency injection allows us reuse a lot of code and reduce coupling making the code more cohesive and once well applied we follow the principle (DRY — Do not repeat your self).</p><p>Generally when we come across files with 500,1000,2000,3000 lines of code it is because there is a very high level of coupling and when this happens programmers tend to copy code from one file to another and the number of files with several lines of code equals grows. As a consequence after a bug has been identified in one of these codes that was duplicated in the other files and even though the bug has been resolved in a record time in the future the bug will be reported again because <strong>N files</strong> with the wrong implementation of the badly written code. That’s why we sometimes see teammates being notified that a certain error has reoccurred in another part of the system. The reason for this is the duplicate code.</p><h4>Implementing dependency injection offers the following advantages:</h4><ul><li>Code reuse;</li><li>Ease of refactoring;</li><li>It will make testing easier especially Test Double.</li></ul><blockquote>When used we save a lot of time and with that we become more productive in fixing bugs and implementing new features.</blockquote><h3>3. Automated Testing</h3><p>Tests are very important in software development although a lot is said nowadays about the deadline vs tests dilemma. Developers must know how to test their code.</p><p>It is common to ignore tests at the beginning of the project because of the anxiety of seeing things work fast, but as time goes by new features will be implemented and there will come a time when the software will have <strong>10¹⁰ </strong>features and then the developers will be left with fear of changing anything even deleting comments from the code (😄 😄) this is because without testing the whole team will be blind. No one will know what part of the code was affected because of a refactoring that was done.</p><p>Tests help us to have greater control of the code and for each change that causes some damage to a part of the code, we will easily realize why N tests will fail and this helps the developer to easily solve problems still in the development branch, preventing us from sending some code with hidden bug for the main branch.</p><p>Tests are like promises, whenever the developer performs something that he did not promise in the tests they will fail informing the developer that he is trying to do something he has not promised. This helps a lot since the reason that the test failed is always indicated.</p><h4>Why Automated Test ?</h4><blockquote>As you continued to add and update features, you probably also continued to run your code and verify it works. But doing this manually every time is prone to mistakes, and does not scale.</blockquote><h3>4. OOP (Object Oriented Programming)</h3><p>Imagine that you are developing an app or system and you use dictionaries or hashmap to save data in the database locally or on the server via API.</p><p>If any data is saved in any part of the app/system then you will have to update, list, search and other validation operations on the data.</p><p>The project will be a mess using dictionaries or hashmap. One of the causes of the mess will be the data access because these data structures will not allow you to access the value from the <strong>.attribute.</strong></p><blockquote><strong>Example: person.name vs person[‘name’]</strong></blockquote><p>Using these data structures will cause other problems because if an attribute is added or removed in the payload that saves the data then it will have to search through all the files that we use the payload to make the change and this will consume time and cause other problems such as a very high level of coupling in the code.</p><p>This is where Object Oriented Programming comes in. For the problem presented above, we would easily solve it by creating an object and when saving the data we instantiate an object with the data we want to save and then we save the data. At the time of listing we will retrieve a list of the type of object that we have saved and the access to the data will be the <strong>object.attr</strong> convention and this will prevent us from having access to the data via key.</p><p><strong>Object oriented programming has several benefits for code such as:</strong></p><ul><li>Code reuse through inheritance;</li><li>Modularization for easier troubleshooting;</li><li>Contributes to eliminating code redundancy.</li></ul><h3>5. Know how to estimate</h3><p>Your manager walks through the door and says that the customer wants a new feature and asks how long the feature will be available and the developer feels pressured thinking he necessarily needs to respond at that moment without any analysis says 5 days. On the first day of execution, he realizes that it was not that easy and the feature involves adding complex code logic, requires changes to the database, many validations, requirements that have not yet been defined by the customer and many tests. It requests certain requirements on how the feature will work and the customer sends it on the second day and because of the time the developer implements many things in a hurry and then new features are requested over and over and the project that started well ends up failing in terms of code because the developer did not know how to estimate and did many things in a hurry.</p><h4>Here are some tricks to improve a task’s execution time estimation:</h4><ul><li>First analyze what was requested;</li><li>Do not underestimate the problem;</li><li>Avoid giving times like this (15 minutes, 30 minutes, 1 hour).</li></ul><blockquote>As a programmer, you need to provide your managers, colleagues and users with estimates for the tasks that need to be performed and so it is a very important skill.</blockquote><h3>Conclusion</h3><p>Worrying about code quality should be a writer’s job. Currently projects grow exponentially and for this reason you should look into the factors that make the project easy to maintain since a project in production with many bugs can have a negative impact on the life of the programmer and the company.</p><blockquote><strong>In addition there are more techniques I use to keep track of code such as:</strong></blockquote><ul><li>Avoid using too many nested callbacks;</li><li>Conduct code review;</li><li>Avoid using unnecessary comments.</li></ul><p><em>If you have any questions or suggestions for a point that was not included here, let me know in the comments.</em></p><p>Follow me on Twitter: <a href="https://twitter.com/bacar_bc">@bacar_bc</a> i’ll follow back 😃</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca49a3f39a4f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>