Work like a professional

At the beginning of this week, I took part in the lecture about fast coding with IntelliJ. Its main goal was to show participants that they can speed up development with tools which are available in IntelliJ IDEA. This event inspired me to write a post about my experience with working with different IDEs, especially IntelliJ.

Up till now, I have written a couple posts about tricks in a software made by JetBrains company.

Shortcuts

“Using a mouse sucks. True programmers use only a keyboard.” – maybe yes, maybe no. Same with “spaces or tabs?” (tab lover here). I think that there is no good answer for both of them. At the end of the day, it really doesn’t matter. No one can undermine that working with shortcuts is faster than any other way of navigation over OS. If you are using mainly keys, you don’t have to move your hand over a table to grab a mouse and perform any action with it. Moreover, if we consider the likelihood of misclick, then the whole process takes significantly much time.

Keymap

IntelliJ provides us a lot of tools which to help learn all of the necessary shortcuts. First of all, keymap which is accessible via Help -> Keymap Reference. The application automatically will open a PDF file with the most important keys combination. In my experience, it is worth to print and put it in a place which you can easily see during programming. You can also mark the most important positions with a color. After some time, you will stop glancing on it because you will learn everything.

Key promoter plugin

IntelliJ allows you to install external plugins. One of the plugins which help with increasing productivity is “Key promoter”. Every time you do an action that can be done with a shortcut, the plugin will notify you about this possibility.

 

Productivity Guide

Another tool which IntelliJ provides is Productivity Guide. This simple dialog will show you which features you use the most often. In the bottom part, you can see some tips about selected functionality. It is worth to spend some time and become familiar with those positions.

 

Terminal

I like working with the terminal so I use it a lot. It is very uncomfortable to change an active window every time you want to type some basic commands in it. IntelliJ has an appropriate view to work the terminal. You can activate it using the bottom bar in the main window or by pressing Alt + F12.

On Windows machines, by default cmd.exe is used. If I’m working with Windows I always change it to Git Bash. You can do it by going to the Preferences -> Tools -> Terminal and changing shell path value to:

With this simple functionality we can use find, cat, grep, sort, etc. commands. Isn’t it fantastic?

The terminal view is one of the reasons why I prefer IntelliJ over Eclipse.

Debugger

As all of the professional tools, IntelliJ has embedded debugger. I don’t want to go into its details so I’ll cover only those parts which help me the most.

First of all, evaluating expressions saves a great deal of time.

Using evaluation, we can check what a method or an expression will return. The feature uses values straight from the stack so it is very valuable if we can take a look what our algorithm will return on every level.

Secondly, stopping execution if a condition is true. For the example below, execution will stop when user’s login will be equals to “admin”.

This feature saves our time if a method processes a collection with many values and we want to check only one of them.

Thirdly, during the debugging, we can add custom watches.

Useful when we want to watch only one value which is placed deep down in an object.

Run configurations

IntelliJ gives us possibility to create custom run configurations. With this function, we can set up how our application will be run with the “Play” button. Moreover, we can connect multiple configurations into a chain.

In the following example, the configuration will run command“mvn org.pitest:pitest-maven:mutationCoverage” and “mvn clean install” afterward.

We can define as many configurations as we want for different tools – Junit, Spring Boot, Maven, Gradle and so on. Simple but extremely powerful feature.

IntelliJ vs Eclipse

At the end of this article, I want to say something about comparison IntelliJ with Eclipse. Holy war, isn’t it?

In my point of view, both of those tools are good. One thing IntelliJ has in its favor is embedded terminal, but on the other hand, Eclipse has way better support for OSGi. A few months ago I tried to setup OSGi project with IntelliJ and I gave up. It seemed easier to build developer environment on top of Maven builds.

In the case of debugger both, IntelliJ and Eclipse, have similar functionalities so it’s up to our preferences which one is most suitable for us.

Another thing to be said for IntelliJ is support for a decompiler. If a user wants to set up a decompiler in Eclipse then a lot of time and patience are required.

One thing that gets on my nerves when I work with IntelliJ is its bootstrap. For huge projects, it takes ages to end the indexing. Moreover, a user can do nothing – searching is disabled, refactoring functions are disabled. In this case, Eclipse is a way faster.

 

In this post, I don’t cover even 1% of tools available in IntelliJ. I decided to write only about those that I use as a daily basis. Undeniably, it is worth to spend some time reading or watching videos about your favorite IDE. There are a lot of things we do manually but we can automatize them.

I would recommend you to watch PhpStorm Best Practices – The Perfect Workflow for PHP Developers. Many of presented tricks are suitable for any other JetBrains application.

You may also like

Comments