DEV Community

ElshadHu
ElshadHu

Posted on

First Pull Request

Feeling Stressed and Strong

Totally, contributing to a different project was a valuable experience. That was a big milestone that i took today by writing an understandable code. When I started my programming journey I was thinking the best code is which compiles but in reality No. Because communication is the key, writing meaningful comments and making your code speak for itself is highly important.

First Milestone

Setting up my groupmate's project was the first challenge that faced, but wait that was just the beginning. my groupmate and I started communicating and I gave instructions about dependencies that i have in my program which are related to packager and libgit2. Then thanks to God, my groupmate set up my project and the next step was to writing code.

Code Challenge

When i first checked out the code i tried to check every module and read every code. Then, i realized that it will go forever. I started taking notes about module and based on the function and class names with old style writing to the paper. So eventually i got the main idea that in order to write a good code i don't need to touch the main logic and use the current design.

Code Specific

Firstly i researched std::chrono library which is used to show the timestamps and i figured out that I can check the time difference and got the current time for getting the recent files. For me this library was more comfortable than ctime library which is related to C language.

 constexpr int MAX_RECENT_DAYS = 7; 
Enter fullscreen mode Exit fullscreen mode
 //get current time and calculate the difference    
        std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
        std::chrono::system_clock::time_point daysAgo =  now - std::chrono::hours(24 * MAX_RECENT_DAYS); 
Enter fullscreen mode Exit fullscreen mode

We could use auto, but we only use this library here for me, it made sense to write with types. Another thing was related to lambda which i really like in coding, because it's an easy callback and does not make the code complicated. Also, using algorithm which is recommended by C++ creator that when algorithm possible avoid manual loops.

  auto end = std::remove_if(scanResult.files.begin(), scanResult.files.end(),
        [](const FileEntry& file) { 
            //checking the File via function
            return !isFileRecent(file.path); 
        });

Enter fullscreen mode Exit fullscreen mode

Pull Requests

Another unique experience was that I had today was to see on terminal that my git push failed to my project repo because of pull request. Because i did not pull the code from GitHub to my local machine and I learned how to ammend my commit. Lastly, day by day i am feeling less afraid of using Git.

Outcomes

Today one of the hardest times in my coding journey. I used all of my brain cells to give nice instructions about my project set-up and I will add a new instruction to my README. I also want to appreciate to my groupmate because my groupmate handled the situation in a
professional way like i did.

Future Goals

In order to avoid dependencies and not spending tons of hours to my project's set-up i would try to use TypeScript or JavaScript. That was really nightmare but came with nice rewards to my knowledge. Also, I will think about dependencies in next projects.

Top comments (0)