This blog is going to be very opinionated. I’ve been writing software professionally for almost 30 years now, and before that I was competing on a global level as a school kid (representing Ukraine in a World Olympiad in Informatics back in 1993), so I have a lot of wisdom to share (and not too much modesty), so welcome if you want to learn.
Before we get to LaaS code, I wanted to talk about moving through the code. This aspect is easy to overlook and I don’t see a lot of articles about it anywhere, which is a shame. Programming is similar to video games in a way – you have a map of the world in your mind, you remember where everything’s at, and to be efficient you have to be able to move around with ease. Ideally with grace even, with no unnecessary efforts, very quickly and without stumbling. Look how professional Starcraft player fingers dance on the keyboard:
When playing to win, you don’t have time to think about where the individual fingers go, you need to think about resources, armies, your long-term strategy – the fingers just do the work following your intentions, subconsciously.
For software engineering, the first step in terms of moving gracefully is of course to touch type – if you have to look down to find the keys with your eyes, do yourself a favour and learn to type without looking ASAP. Human brain has a limited capacity, and if you’re thinking about individual keys you are not thinking about program architecture, algorithm branches, edge cases and other things you could be thinking about – those brain “CPU cycles” are wasted.
Pretty much everyone touch types nowadays, which is great. But there are at least 2 more techniques that are just as crucial for being productive as touch typing – only contrary to touch typing I see most of programmers not using them. It’s like watching someone play Doom for the first time – instead of having fun and killing demons they’ll just bump into walls helplessly.
Go to Declaration and Back
First of these 2 techniques is simply going back. Most programmers use “Go to declaration” feature already – it’s just too good, even the beginners use it. But it only gives you a fraction of value if you don’t have a shortcut to go back. Sometimes I just can’t help but notice how people literally look lost after “going in” (e.g. going to declaration) a couple of times, and have to use editor tabs, or global search, or look for the file in the project directory tree to return… and if it’s the same file, they scroll… such a waste of time and focus! This in turn makes you afraid to go to declaration often, because getting lost sucks.
But it’s a problem that’s very easy to fix: just go back by using “Back” feature (duh!). It’s incredible how underused this feature is. Assign a shortcut to it that you like (I use Ctrl+Backspace), and use it all the time. Never go back by searching or clicking around – the previous location is always one keystroke away. In Webstorm, go to Settings, Keymap and search for Back to assign a custom hot key:
This changes the workflow. You see a function that you don’t quite remember what it’s doing? Ctrl+click it – or better yet, press your keyboard shortcut to go in (keyboard is way more efficient than mouse or god forbid touch pad), – take a look, and go back with Ctrl+Backspace or whatever your preferred key combination is. It takes a second, and you don’t lose your train of thought this way. Since it’s so cheap to do, you can jump to declaration multiple times in a row – you see that function, and there’s another function, and then there’s an interface you don’t quite remember what the shape of it is – just go in the second, the third time, take a look, and come back quickly to where you started. No mental effort required, the fingers just follow your intention and you don’t lose your train of thought.
This is so simple, and such a great boost to productivity, I really cannot emphasise this enough. By doing this all the time while developing, you get to know the code in a very different manner, it becomes like a big hyper-linked web of things, you start to feel how the project is made of interconnected objects and pathways between them. Very much like in a video game, you build a mind map of the world you’re in – and you move through it gracefully, without giving a second thought to the mechanics of fingering. And if you don’t feel the game, you’re gonna lose to someone who does every single time, they will just run circles around you.
This technique serves the same purpose as going to declaration and back: to prevent getting lost in the code. When working on a piece of code for a long time, just bookmark it with Ctrl+1 – this way it’s always just one keystroke away. See a method and want to jump through the usages? Just press your shortcut for Find Usages, scroll through the list with Next occurrence and Previous occurrence (obviously, using keyboard shortcuts), and wander around the code with ease and confidence – the piece you’re working on at the moment is always just one keystroke away, so you are never really lost.
Bookmarks remind me of Starcraft groups a lot – not only the actual hot keys are the same (Ctrl + number), but the feeling of control it gives you is very similar. In Starcraft, you have multiple groups within your army that you can switch between and control independently, and in programming, you have multiple pieces of code you’re focusing on at the same time. It could be, for instance, a unit test and the code under test (I use Ctrl+0 for the test I’m currently working on, and Ctrl+1 for the code under test), or controller and template, or one main function and a couple auxiliary functions, or a service and interface definitions and some dependencies – there are up to 10 bookmarks you can have, which is more than I personally can handle, I don’t really use more than 3. But I pretty much always have at least one bookmark – being able to quickly go back and switch between 2-3 places in the code is just invaluable in my opinion.
There are more important techniques, of course, but these 2 – Go to Declaration and Back and Bookmarks, – I find to be the most undervalued and underused. If you’re not using these IDE features yet, give them a try, I guarantee you will increase productivity this way (be a happier developer and make more money, yeah?) Good luck, reach out to me with questions and suggestions; feedback is always appreciated – and stay tuned for more good stuff soon 🙂