<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alyson Fernandes Basilio</title>
    <description>The latest articles on DEV Community by Alyson Fernandes Basilio (@alysonbasilio).</description>
    <link>https://dev.to/alysonbasilio</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F155629%2F44b340b7-2140-4e8b-b422-3e9f5f41f921.JPG</url>
      <title>DEV Community: Alyson Fernandes Basilio</title>
      <link>https://dev.to/alysonbasilio</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alysonbasilio"/>
    <language>en</language>
    <item>
      <title>4 Tips to split extensive Pull Requests</title>
      <dc:creator>Alyson Fernandes Basilio</dc:creator>
      <pubDate>Thu, 17 Dec 2020 17:00:32 +0000</pubDate>
      <link>https://dev.to/alysonbasilio/tips-to-split-extensive-pull-requests-5g4d</link>
      <guid>https://dev.to/alysonbasilio/tips-to-split-extensive-pull-requests-5g4d</guid>
      <description>&lt;p&gt;As a Software Developer working on a product squad, one of my daily responsibilities is to review other developers code. But, when this code change is too big, to review it can be a torture. Usually, you don't know where to begin and it takes too much time to understand the impact of the changes that your colleague is doing.&lt;/p&gt;

&lt;p&gt;Here are some tips that I use to make my Pull Requests more "reviewable".&lt;/p&gt;

&lt;h2&gt;
  
  
  What is an extensive Pull Request?
&lt;/h2&gt;

&lt;p&gt;It makes no sense to talk about splitting a Pull Request if it is small and understandable. But, when the Pull Request have more than 200 lines of changed code, you can start thinking about splitting it. &lt;/p&gt;

&lt;p&gt;Another metric that I follow is the number of files affected by the change. If there are more than 5 changed files, it could be a sign that you should split your change into small pieces.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxf27wpp9tqivijq28fil.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxf27wpp9tqivijq28fil.png" alt="A Pull Request with more than 800 lines of code and more than 40 changed files" width="342" height="106"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Beware!
&lt;/h3&gt;

&lt;p&gt;These 200 lines of code can't include tests because tests can be as extensive as necessary, and it is ok. Tests usually have a lot of lines just to setup the test environment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;describe MyClass do
  describe '#method' do
    describe 'when you have to write 8 lines of code just to make your test understandable'
      it 'considerably raises the Pull Request changed lines of code'
        ...
      end
    end
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To classify a Pull Request as extensive, you have to consider only the changes that you made on the code that will run.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tip #1: Split your Pull Request into understandable pieces
&lt;/h2&gt;

&lt;p&gt;Any Pull Request must have a goal. Sometimes it can have multiples goals, and that is where the problem is.&lt;/p&gt;

&lt;p&gt;Last week I had to work on a project that I never touched before. When I started working, I realized that the project was not ready to run on a dockerized environment. So, I had to create some docker related files (Dockerfile, docker-compose.yml, ...). It was nothing related to my initial goal, so I opened a Pull Request only to setup the docker environment. In this case, the goal is simple to understand for anyone who will be reviewing.&lt;/p&gt;

&lt;p&gt;Another example is to setup or change linter rules. Sometimes there is a rule that never affected you, but in that specific change, it started affecting and you have to deal with it. But, to deal with it can mean that you will have to change a bunch of code in random files that are not related to the initial goal of your Pull Request. It is a smart move to open another Pull Request for these linter changes. Also, this example is perfect for the next tip.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tip #2: Look for changes on unrelated files
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2upw506axie5lgr0k5sh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2upw506axie5lgr0k5sh.png" alt="Pull Request Github notification" width="710" height="39"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When an extensive Pull Request have changes on files that are not directly related to your initial goal, it is time to ask yourself if it could be another Pull Request.&lt;/p&gt;

&lt;p&gt;Usually this happens when you have to refactor one piece of code that affects multiple unrelated files. You could just do the refactor first and then apply the necessary change to achieve your goal. Again, here you transform 2 goals into 2 Pull Requests.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tip #3: Think about what you could merge that would not affect any current behavior
&lt;/h2&gt;

&lt;p&gt;To refactor is the usual case of change that does not affect any current behavior. Sometimes you just find an opportunity to optimize a query or to replace some code that is not in the best place. I am not going to tell you that "You must not change working code" because I believe that every developer wants to change working code when they realize an opportunity to make that code better. &lt;/p&gt;

&lt;p&gt;If an opportunity appears, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Change the code if it is a small change;&lt;/li&gt;
&lt;li&gt;Put the change on your to-do list and work on it right after your current work;&lt;/li&gt;
&lt;li&gt;Create a Technical Debt to work on it later if you don't have time to spend on this type of work.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tip #4: Sometimes you just realize that you can split that big change into small pieces later, and it is ok.
&lt;/h2&gt;

&lt;p&gt;I usually start working without thinking if I could split the major task goal into small achievable goals. Then, when I achieve the major goal, I realize that it could be splitted. &lt;/p&gt;

&lt;p&gt;Then, I list all small goals I think that makes sense, open a fresh new branch from the main branch and start working on it. After finishing the first small goal, I open another branch, now from the branch that I was working on, and develop to achieve the second small goal.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fkjssotwxsc2juam4c8sm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fkjssotwxsc2juam4c8sm.png" alt="Git branches" width="591" height="693"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After finishing all small goals, it is important to tell reviewers that every small goal is a part of a bigger goal, especially if they have an order to be respected.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;One of the most satisfying things to do at work is to review a code that you don't have any problem to point out and you understand every single change that has been done. If you create this experience for your colleagues, I am sure that you will be influencing them to also do code changes in small pieces.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9akqatye0v2ww6v50fbo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9akqatye0v2ww6v50fbo.png" alt="An approved Pull Request" width="362" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Nobody likes to waste time on a Code Review. Don't be that developer.&lt;/p&gt;




&lt;p&gt;Cover Photo by &lt;a href="https://unsplash.com/@markusspiske?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Markus Spiske&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/code-review?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Git branches photo by &lt;a href="https://docs.microsoft.com/pt-br/azure/machine-learning/team-data-science-process/collaborative-coding-with-git"&gt;Microsoft Docs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks to &lt;a href="https://www.linkedin.com/in/j%C3%A9ssica-veng-magalh%C3%A3es-27a96674/"&gt;Jéssica Veng&lt;/a&gt; for reviewing the text.&lt;/p&gt;

</description>
      <category>pullrequest</category>
      <category>pr</category>
      <category>changerequest</category>
      <category>codereview</category>
    </item>
  </channel>
</rss>
