As I sat down to write this blog post, I thought through how many years I’ve been developing, and how many great people I have been lucky to meet in my career. I’ve been developing professionally for 18 years now (wow, I’m getting old) and the last 10+ have been as a consultant. In all that time, through all the different organizations I’ve been lucky to have worked with and all the developers I’ve sat alongside, there is one thing that sticks out to me about us all… we are lazy.
If you ask a developer to perform a task, most of them will write a program to do it and then run that program. Why? Because… we are lazy. If you come back and ask us to perform the same task again, we’ll just re-run that program. We complain about clicking 3 times, having to scroll a web page and load times that (gasp!) exceed 5 seconds.
I can’t say that I’m any different, though. And to some extent, I think it has served me well. That is to say, it serves developers well to be somewhat lazy. Of course, being inherently lazy is a bad thing. It can make you cut corners, write bad code, not think things through, and make your wife want to pull her hair out.
But, I’m a pretty optimistic guy. Being lazy can also (if used wisely) help breed efficiency. It can foster communication and innovation. Heck, if really put to the test, it could even make you a better programmer.
I look at the development environment that I use day in and day out and I realize how much it does for me, and that I’d be lost without it. My IDE of choice is Eclipse™. I’ve been using it since the late 1990s and I wear her like an old comfortable sweater. I just can’t seem to get away from her.
Between Eclipse’s visual layout, editor support, and keyboard shortcuts, I have been able to train my fingers and brain to not only minimize the number of keystrokes I type to perform tasks, but to also minimize the amount of times my hands have to leave the keyboard touch the mouse. Because that takes forever!
So, here are a few of my favorite features/tips/tricks about being a developer inside of an environment like Eclipse:
Navigation
When I say the word ‘navigation’, what I mean is moving around between files and within one. The ability to quickly locate and open a file for editing is paramount to a developer’s laziness. Can you imagine having to dig through folder after folder every time you wanted to open a file? Eclipse affords you two great ways to avoid that:
1. Open Type
This is typically mapped to the Ctrl-Shift-T key combination. Open Type pops up a dialog box with the cursor focused on the search box.
Begin typing and Eclipse will present to you a list of classes that match your keyword (wildcards supported!). Use your arrow keys, select the matching file, and hit enter. Voila! You opened a class and your hands never had to touch your mouse. (Note, newer versions of Eclipse also let you choose what View/Editor to open the file with at the bottom of the dialog box).
2. Open Resource
This is typically mapped to the Ctrl-Shift-R key combination. Almost identical to the Open Type command, Open Resource will open any file, not just a Java class. The same methodology applies. Open the dialog, type the name, hit enter. Super simple.
Many times, I find myself using these tools to not only open files, but to do research on where they exist, too. For example, if I get a ClassNotFoundException
, I’ll use the Open Type dialog to type in the name of the missing class and look to see what jar file it exists in. It’s a fantastic way to diagnose classpath, build, and deployment problems.
Now that you have a file open, Eclipse gives you some great tools for navigating within the file itself.
3. Incremental Find
This is typically mapped to the Ctrl-J key combination. This allows you to start searching the open file, keystroke by keystroke. Once you begin, by typing Ctrl-J, you can enter characters to match (case insensitive!). Each character you type adds to the search, and you can see the cursor (and focus) move through the file as it finds matches. Stop typing keys and type Ctrl-J again to move to the next match (for the current string of characters you are searching on).
4. Open Method
This is typically mapped to the Ctrl-O key combination. This allows you to search for a declared method in the currently-open-file. Again, this is case insensitive and wildcard enabled. Simply begin typing part of the name of the method you wish to navigate to, and hit enter to go directly to the highlighted match.
Bonus!
With the Open Method dialog window open, type Ctrl-O again. This allows you to now search and open a method anywhere in the Hierarchy (inherited methods) of the current class!
5. Quick Type Hierarchy
This is usually mapped to the Ctrl-T combination and uses the current cursor position as its context. The purpose of this is to show you a hierarchy tree of all classes in the hierarchy that implement or extend the current selection. For example, put your cursor in the name of an Interface and type Ctrl-T. You’ll be presented with a list of all classes that implement that interface. Do the same on a method name and you’ll see all overrides/extensions of that method. This is super handy for getting an idea of where you are in the hierarchy.
Task and Time Tracking
Whether you are a consultant, contractor, full time employee, or freelancer, chances are that if you are a developer, you’ll be asked to track your time and fill in a timesheet. There are countless clocks and timers available that are desktop and web-based to keep track of these things. But again, I’m lazy. I want all my tools to be inside of Eclipse so that I don’t have to launch other applications and navigate between them. Eclipse has a decent solution to not only track your time, but to track your work tasks as well. It’s called Mylyn.
Mylyn is the basic idea of listing and tracking the progress and status of tasks you need to perform. Mylyn uses connectors to talk to 3rd party workflow tools, such as Bugzilla, Jira and Rally. By connecting Mylyn to these tools, you’ll be able to your list of work items and activate one to work on. Activating a task (double-clicking it in the Tasks view) not only starts a timer, but also keeps track of every file you touch while that task is activated. Mylyn calls this a context. Files can be added and removed to/from the context. Tasks can be activated and deactivated. Other tasks can be activated and deactivated and Mylyn keeps track of all of it.
Many times, the connector you are using (usually written by the same developers that built the workflow tools) also allows you to open the Task to edit it. This allows you to add notes, log file names and even log time towards the task you are working on. Again, you didn’t have to leave Eclipse to do this.
Database Access
The Eclipse foundation has put countless hours and effort towards developing its database connectivity platform. Built-in Eclipse features are already complete to allow you to connect to remote databases (every major implementation is supported, from Oracle to DB2 to SQL Server and MySQL) and execute queries.
I’ve used their Data Tools Platform in the past, but recently I got nudged towards the Toad plug in for Eclipse. Toad is well known for its desktop database tools, but I’ve never gotten attached to it for whatever reason. But, their Eclipse plug in works fantastically for me.
It allows you to store pre-defined connections, execute queries, and see their results, as well as has a well implemented Outline view of the database. This view shows you everything you have access to once you are logged in. Tables, views, packages, synonyms, and more are all in one compact view. And, the whole thing is filterable by keystroke (wildcards supported!). Can’t remember the exact table name? Simply type in a few characters and let Toad filter the list down for you.
Clicking on a table (or view) shows you detailed information, including the columns, types, references, indexes and constraints. You can even preview the data in the table by just clicking on the Data tab.
And, again, you didn’t have to leave Eclipse to do any of this.
Log File Monitoring
Typically, I’m running my code inside of Eclipse and the logging/output is fed to the console. But there are times when that just isn’t possible. I recently found a nice plug in called LogViewer that allows you to open a log file on the filesystem and watch it grow. This is essentially the Eclipse version of the unix tail command. For those times when you aren’t/can’t run your code inside of Eclipse, this is super-helpful.
Conclusion
Eclipse has many other features that I use daily. I can’t say enough about its repository connectivity (for CVS, SVN, and others), support of server launching (Tomcat, Apache, JBoss, etc), debugging tools, and much more. But when it comes to being lazy, these are my favorites. Have some of your own? Please let us know!
– Adi Rosenblum, asktheteam@keyholesoftware