First of all, Happy New Year! We’ve begun our next voyage around the sun and with a new year comes a fresh plate to start working on new projects.
So that is what I did. I tried myself at Android Development again, and I have to admit it is actually okay. It is not as smooth as I wish it to be, but Google certainly did an okay job with what I have been exposed to.
But this post is not about Android or even Java (which I have come to dislike less what a surprise) but about the IDE known as Android Studio or more specifically IntelliJ IDEA. I had some previous experience with it, but it was rather limited and somewhat clouded with judgement. This time I went with an open mind, forgetting C, Ruby, Python and my other previous very specific usages of languages and editors/IDEs. It was awesome, here is why:
Refactoring is a pretty big part of keeping a codebase healthy. And as it grows you tend to be less ready to make changes to it. While one usually tries to follow the current best practices regarding seperation of concerns I have found that applying it is really hard and sometimes poorly understood (I am guilty of this).
Now the reason why I think it’s awesome is because I am able to change huge parts of the App at once and not have to worry
about it breaking at some point due to my changes. (This is not true all the time though)
Compare that to how you do it in Vim: You
grep over the code (or other ways to find text), you then change those occurences
and hope you got them all. You can also check them all by trying to compile and get all the errors and warnings out.
Although the latter approach won’t always work in all languages, e.g.: casts in C.
This is something I use all the time. I write a piece of code and later realize I might need it somewhere else as well, with a select and the Refactor shortcut I can quickly extract that method and reuse it. There are still some kinks here and there but overall it is much faster than extracting it all by hand as the IDE finds all required parameters and fills them in.
What I call Method Enhancement is this use case:
- I add a property to a class and I want it to be initialized by an argument in the constructor.
- I get my cursor on the property, press Alt+Enter, select the correct entry which adds it to the constructor.
- Put the correct values into each usage which can be easily found through the IDE as well.
I can’t see myself doing this trivially in Vim other than by hand.
Plugins in IDEs are pretty great, but I want to talk about one specifically: IdeaVim. It gets the speed of vim editing into the IDE which is the sole reason why I am a huge fan of Vim, the speed. With this I can edit files with the speed I am used to, which I think is awesome.