About Çağdaş Alagöz

I am a software engineer who is interested in most anything related to software.

Capture parameters with Mockito ArgumentCaptor

While creating test methods for a class, you might want to access some arguments passed to a specific method. Luckily, you can capture parameters with Mockito ArgumentCaptor. It is especially useful when you can’t access the argument from the outside of the method.

Let’s check it out on a basic example. Let’s say we have a class called Product and we create stock codes for these objects before saving them to the database. So we’ve created a method called generateProductCodeAndSave() which generates the code then passes the product to another method in order to insert it to the database.

Continue reading

Why your Git repository is suprisingly large?

Git stores everything. It is a version control tool after all. What is once committed will always be available for anyone to checkout. But how does git stores all versions of your files? Does it copy every version? No. It just detects changes and takes note of them. After all, adding a new function to your class is just inserting some lines into a text file. But this doesn’t always help you to save repository space.

If you’ve added a file then deleted it in the next commit, it doesn’t go away. It has to be stored somewhere to allow you to access it in the future if you wish. These kinds of commits might cause your repository to grow and make it uncomfortably large for cloning. “There must be a way to clean this mess!” I hear you say and there is! But first, we have to figure out why your git repository is unnecessarily large.

Continue reading

Regular Expressions In Java

Regular Expressions are a key element in programming. There are times that you can save a lot of time with a simple Regex. As a lot of my teachers said while I was studying, it is an important thing that you should be familiar with. Regular Expressions are designed to help you define a pattern to search for in a String. You can use it to check whether a parameter is valid or to find a specific pattern of text in a large file. In Java, you’ll be using java.util.regex package to implement Regex logics to your project.

Continue reading

Why you should stop using Chrome?

Chrome is dominating the browser market since 2012. Maybe you’re thinking “Google is making a good job and having a lot of users because of this, is very natural” and you might be right. Yes, Google Chrome has a lot of features like remote control, casting, and whatnot. But it is not how Google achieved this success but where it is headed is concerning. So why exactly we must stop Chrome?

Browser market share image, Chrome 65 percent, Safari follows with 16 percent
Browser market share data acquired from gs.statcounter.com (19/08/2020)
Continue reading

How to transfer files from and to Android device via ADB

Transferring files between PC and Android is easy. But while working on a project which requires sending files back and forth between your computer and mobile device you may find this ADB commands useful. Whether it’s a certificate file or an image it’s easy to transfer files with ADB. I believe I do not have to state that this requires connecting your device via USB and having the required drivers installed on your computer.

Continue reading