Java-Productivity

The community has spoken. We’ve gathered your best and greatest productivity hacks into one post.

We all have our own little tricks that help get us in a working-mood and boost our productivity. We use tools to avoid tedious everyday tasks and run scripts to automate processes. We do all that just to make sure everything’s in place, working properly and efficiently.

In the following post we’ve decided to go deeper and discover those hacks, tips and tricks that will make us even more productive than before. Start taking notes.

Your Very Own Tips and Tricks

When it comes to being productive, we know there’s always room for improvement. In addition to closing distracting social networks and cleaning unwanted files, there are a lot of options just waiting for you to use them.

That’s why we decided to turn to our trusted readers, teammates and close friends of the blog and ask you for your special tricks and treats. We got a lot of feedback that included useful tools, handy shortcuts, hardcore scripts and even basic tips for better focus.

Since we want to share the wealth, we picked the top tips to lay out for you. Pick whatever suits you and your work environment, and just do it.

Scripts: Your Own Jarvis

If we’d have to choose a winner for our survey, scripts would be it. No surprise that most of us prefer to automate a big part of the workload, especially if it’s an everyday task that takes up too much of our time.

Most of you mentioned the use of bash scripts. Ferran Delgado elaborated and told us about a divided project he’s working on. It’s composed of one common part for the entire company, and another specific Java project for his department. They use a script to monitor and control that the Maven steps are carried out correctly. It also uploads the jar file to the remote machine for the pre-production testing.

Our very own David Levanon, Senior Software Architect at Takipi, recommend using alias commands. Meaning you can launch any command or a group of commands by only typing a few characters.

Since we at Takipi work with a lot of programming languages, it takes time to rebuild the code, refresh IDE’s, restart the system and so on. That is why David created environments that hold the Git repository with aliases and handy shortcuts that are ready to go within minutes and within 2 keystrokes. That way he can connect to an Amazon machine and work on it as if he was working on his own computer in a matter of seconds.

For example, he created an alias to connect to a local MySQL:

And an alias to check if Jenkins is running:

David also created some handy functions to help him with everyday tasks, such as converting decimal numbers to hexadecimal:

And a function that extracts all zip files and place them in a directory:

One of his favorite functions creates and CDs to temporary directory with the current time and date:

And of course, he has a function to kill a Tomcat process:

Monica Beckwith, Java/JVM Performance Consultant and a JavaOne Rock Star also has a few scripts that help her out. She uses automated scripts to generate a JFreeChart to plot any/all relevant GC file information.

If you’re experiencing a hard time with reducing your Java Garbage Collection overhead, we have a few tips that might help out, no matter which garbage collector you choose to utilize.

Bottom line: Use bash scripts, create aliases and handy shortcuts and try to automate whatever you can when you load up your machines or servers.

Documentation: Prepare for the Next Developer

One of the most important things we need to remember is that we’re not the only ones who’ll have to read our code. A lot of you agree with us, and recommend adding elaborate comments for future reference.

Lukas Eder, Founder and CEO of Data Geekery and the creator of jOOQ stated that every software is bound to grow, and at some point it will become impossible to write code which will be completely self-explanatory.

That’s why all pieces of logic that are not immediately obvious should be documented with a one-liner comment, that references a publicly available GitHub issue, which contains all the historic information about why things are the way they are.

This way, years after any given bugfix it will be easy to figure out why any decision was made, which would be impossible otherwise:

Bottom line: Explain whatever you can, so it will be easier (or simply possible) to understand your code and work with it.

Troubleshooting: The Pursuit After Bugs

Oleg Šelajev, Product Engineer at ZeroTurnaround, told us that what made him more productive is a skill. His advice is to learn to use the IDEs debugger to the fullest capacity. Identify and use the correct types of breakpoints: exception breakpoints, method entering, field access and of course, the conditional ones which are only hit when the condition you specify is true. This will make stepping through the code much easier because you will avoid false positive stops.

Oleg also adds that when you need to add additional log statements you should prefix them with something distinguishable and ridiculous, so it will be easy to grep that information and it will never slip past the code review. He likes to use “Panda says:” as the prefix, because who doesn’t love a panda 🙂

If some errors do manage to slip through the cracks, another tool you should try is Takipi. It will help you save precious time looking for the root cause of your errors, and you’ll be alerted when your code breaks. Whenever a new exception is thrown or a log error occurs – Takipi captures it and shows you the variable state which caused it, across methods and machines. Check it out.

Bottom line: Troubleshooting is an inseparable part from software development, learn how to make the most of it.

Tools: Monitor and Manage Your System

Working in production means dealing with frequent deployments, along with a large amount of services and servers. This requires tools that will help with the daily recurring tasks you encounter. And indeed, we got a lot of recommendations about various tools that can help out in that area.

The two that stood out were Chef and Puppet. Both are open sourced tools that help you monitor your product’s performance, functionality, servers and so on. If you’re not sure what’s the difference between the 2, or simply wondering which deployment management tool you should pick, we compared Chef vs. Puppet vs. Ansible vs. SaltStack vs. Fabric.

Speaking of finding the differences, we also got a lot of suggestions for various diff tools, that includes:

We turned to Tzofia Shiftan, Team Lead at Takipi and asked what’s her go-to-tool. She uses Meld to compare files and directories, review code changes and understand the merge before it effects the code.

Tzofia also uses another handy tool, Indicator, that helps her monitor her system. It shows performance graphs of the CPU, network activity, memory and any other system resource you’d want to check up on. In case you were wondering, David monitors his system with htop.

In case you’re looking for tools that will help you while you code, you might want to look into JRebel. It reloads your code changes instantly, so you don’t need to restart your Java process to see the changes made.

For other useful tools, that will help you understand how your application and environment behaves in production, check out the following post.

Bottom line: Tools are made to help you whenever you might need a helping hand. Use them to keep up with your code, check your system and your whole environment.

Misc: Close Your Chrome, Kill the Buzz

Now that you’ve got your shortcuts, scripts and tools in order, it’s time to get to work. But for some of us, focusing on our tasks might be the hardest thing to do. We know we had a hard time to sit down and write this post. That’s why we decided to get a few tips from our team:

  • Read your emails just once or twice a day
  • Setup reachable goal for every day (and actually do them)
  • Find the right music that helps you stay focused
  • Clean your desktop and hide everything you don’t need
  • Close the browser tabs you’re not using
  • Get a standing working station, it helps get the blood flowing
  • Remember to take a break every once in awhile

Bottom line: It’s not always easy being productive, and you should find whatever it is that sets the right working mood for you.

TL;DR

You’re in the middle of a busy work day and want a quick overview of everything we mentioned in the post? Here is everything we covered:

  • Aliases – Launch a group of handy commands with a few clicks
  • JFreeChart – Display charts inside applications
  • Documentation – Make your code comprehensible for future developers
  • Troubleshooting – Learn how to simplify your bug and error hunt
  • Takipi – See why Java code fails in production
  • Chef + Puppet – Use tools to overview and manage your systems
  • Compare++, Guiffy, Kompare, Meld – Use diff and merge tools to compare and detect changes
  • Indicator, htop – Monitor your system and resources in real time
  • JRebel – Reload code changes instantly

Final Thoughts

Even though most of us have our very own workflow and habits, it’s nice to hear what others have to offer. Sharing is caring, and you can always learn about new tools or shortcuts that will help make you more productive.

We hope you learned at least one new hack that will help you out, and of course – if you have any other tricks or tips we would love to hear about them in the comments below.

email
I write about Java, Scala and everything in between. Lover of gadgets, apps, technology and tea.