All Opinions In Beta

Reasons I love IntelliJ #1

Recently I’ve been  interviewing a lot of candidates at work, most of whom use Eclipse and have very little experience with keyboard shortcuts that seem to be default with IntelliJ users. I guess if you’ve made the effort to go out and look for a better IDE then it’s indicative that you’re keen to be as efficient and effective a developer as possible, which I think is hugely important. If you’re going to spend over 9 hours a day doing something then learning at least the most basic shortcuts is the least you can do to improve your code output.

 

Inspired by this I put a video together to showcase the features that excite Eclipse users the most when they see them for the first time, or if you tube’s not your thing, read on for gifs and transcript.

This is effectively an exercise in loving the shortcut alt-enter. If anywhere in IntelliJ you see something red or grey, hit alt-enter on it and IntelliJ will create or fix it for you.

Create New Variables

variable

One of the really cool parts of IntelliJ is how it writes most of the code for you;  as a user you don’t have to do much typing.  In this shortcut, Ctrl/Cmd+alt+v will create a new variable for you from a newed up object.

Create new class

new class

Write the name of a class you want but doesn’t exist, hit alt-enter on it and IntelliJ will create the new class for you

Create new methods

method

Yet again, write the code you want to see in intelliJ and hit alt-enter and it will create it for you.  Write your new method name, hit alt-enter and the method is created.

Adding Parameters

parameter

If you need to pass something into a method in intelliJ, just put the parameter in and hit alt-enter and it will add it in.  This becomes immensely helpful if you have tens/hundreds of instances around your code base; write it once and intelliJ will add in the parameter and allow you to set a default parameter.

parameter2

 

Code Templates

code template

IntelliJ has a whole host of code templates that allow you to write code with very little text! Why write public static void main when you can write psvm and hit tab.  iter allows you to auto generate for loops.  And you can write your own templates which is very cool.

Generator

generator

IntelliJ is smart enough to know standard coding patterns.  If you pass parameters into a constructor you probably want to create fields for them; alt-enter on the grey text (which indicates it’s unused) will allow you to create new fields for constructor parameters.  Using alt enter on the new parameters or using the generator (alt-insert windows/ctrl-n mac) you can then easily create getters for those fields

I hope you enjoyed this post! Whilst you're here, check out my course on learning TDD in Java. It's a concise and hands on tutorial with full source code provided, hosted at Udemy.
Click here to learn TDD!

This project is maintained by samberic