Home

Setting up a killer development environment for CS2103T

This post is about setting up a CS2103T development environment that is fast, efficient and will be useful for whatever Java development needs you may have in the future. These are gleaned from research I did when I was preparing my own environment for CS2103T at the start of this year, my experience going through the module, and observations of how my peers develop. Tips are broken into 3 categories, Setting up Eclipse, Using Eclipse, and Working as a team.

Setting up Eclipse

You will probably be developing on the Eclipse Platform, if not, just stop reading.

Note that Eclipse itself can do a lot of things, but you’ll just be using it to power your Java development needs.

Eclipse will be your second home this semester, let’s make things comfortable by doing some minor renovations.

Color scheme

If I’m going to stare at a program for a long time, it needs to look nice. Eclipse isn’t ugly, but nice is subjecting, but I prefer a dark theme. If you have the same taste as me, hi 5, you can get it here, and it looks something like this

How my eclipse looks like with the dark theme

Alternatively, you can just choose the colours of the editor, the syntax colours, with the Eclipse Color Theme plugin. Personally I like Monokai or Wombat.

Formatter

Now that Eclipse looks prettier, let’s work on how our source code looks like. There’s no way I can tell you how to write nice code, including naming classes, methods and such, thats the Prof’s job. But at least I can teach you how to ensure your code follows the specified code style guideline.

Under the Package Explorer view, right click your project, and click Properties, this is the Project Properties window, a place to set project-specific configurations. Or just select your project and hit Alt-Enter. You should see a new window pop up:

Project-specific properties

Click on Java Code Style, and check Enable project specific settings. Then expand the Java Code Style tree, and click Formatter. This is where you specify how your Java code is formatted, indentation, braces, whitespace, etc. I’ve check out the style guide for my module, configured it by hand using whichever settings I could find/understand, and the XML is uploaded here. You can just download this and import it in. But note that I probably didn’t do everything right, and that requirements may change, so do run through the formatted files and see if it matches!

Most preferences window have a search box, so you could have just typed Formatter and reached the same view! Try to remember these time savers, those seconds really add up :)

Code Style

This has more to do with the way you write Java code, rather than white space and such. This option is under Java Code Style as well, so just enable it for your project and fiddle around with it. THe default Eclipse profile should work fine.

Save Actions

You can find this under Java Editor and this is an awesome time-saver. Basically it lets you configure actions that happen upon saving a file! Quickly enable it, and the default settings are fine. Go ahead and save these changes, and then make some minor edits on a file, such as importing an unused class, and save the file. See the magic happened.

Warning though, make sure you don’t enable the formatter options that sorts methods by alphabetical order, that will be painful.

You can see some advanced stuff under Additional actions. No sweat, those are just good practices, feel free to research about them. Particularly, I found some articles about why trailing spaces are bad.

Build Paths

Build paths are places where the compiler looks for classes when compiling your code. If you end up using libraries for your project, quite likely, note that adding the .jar into your project folder is insufficient. You need to add the jar to your project build path. You can do so using the project properties window too. Click on Java Build Path, and click Add Jars, point it to the jar. Simple :)

Useful plugins

Eclipse Marketplace has lots and lots of plugins, and you can actually visit the marketplace from inside Eclipse, just go to your main Eclipse window, select Help then Eclipse Marketplace. Or hit Alt+H then W. For me I have Vrapper, because I love to use Vim. If you want to use Vim within Eclipse, install Vrapper, it provides support for all of my Vim needs including movement comands, search and replace etc.

Misc

When you try to copy paste your code from Eclipse to say Word, the syntax highlighting might not show up right. If so, disable code folding, go to Window -> Preferences -> Java -> Editor -> Folding and disable it.

Using Eclipse

There’s really only one thing I want to talk about here: using keyboard shortcuts. The saying goes “the keyboard is mightier than the mouse”, and that holds at least for software development. Trying to move your cursor to click that small “Run” button to test your code takes ages compared to a simple F11. Learn the shortcuts and use them well, I’ve compiled a short list of my favourites.

Ctrl+Shift+L quick view of shortcuts
Ctrl+Shift+L again open shortcuts preferences page
Ctrl+1 quick fix
Ctrl+Shift+R open resource or any file
Ctrl+F11 run
F11 debug
Ctrl+Space offer content assist/completion
Ctrl+M maximize/minimize current tab
Alt+Left go to previous place u edited
Alt+Right symmetry of Alt-Left
Ctrl+O code outline
F2 open tooltip
F3 show declaration
Alt+Shift+T open refactoring dropdown
Alt+Shift+M extract method (good for refactoring)

Working as a team

I’m not talking about conflict resolution, intercultural communications or that sort- go to CS2101 for that. I’m talking about multiple people working on the same piece of code, and how to do that with as little friction as possible.

Google Code

On hindsight, we didn’t appreciate Google Code that much, and we didn’t start using it early enough. My advise is to use it for everything. Google Code itself is a great task tracker- you can list your user stories, feature suggestion, ideas, bugs, deadlines as issues, And then mark them as ongoing, completed, wontfix, done, or closed as you work on your code. This may distract you from writing code, but it helps the team keep the project so much more organized. Besides, usage of Google Code is factored into your marks, so why not use it? Yes, it doesn’t have the most beautiful interface, but it’s quite speedy and effective. So start from day one, and religiously enter and update your issues there.

Also, the commenting system is pretty useful. It automatically emails anyone cc-ed on the issue as well, so you can keep updated even without going to the web interface.

Mercurial

I like using TortoiseHg because it’s so simple: choosing which files to stage for commit, commiting, visualizing branches, merging, pushing, fetching etc; all these common functionalities all just a click away. Get used to it, and learn how to use it. But don’t forget that a command line interface exists! When faced with a difficult situation, like improper pulling/merging, most questions and answers on StackOverflow or such are about the command line. So you probably have to use it once in a while.

Talking

We have great technology that enable us to work remotely, and technically we can complete this project without having to meet up at all, sans tutorials/lectures. But where’s the fun and learning in that, right? Take this chance to hang out with your group, talk to them in person about your project, and about other stuff as well. This will help build chemistry and bonds within your team, and will make this module so much more enjoyable and fruitful. The product is not your application, it is you, and the friendships you make.

This is just a quick guide to optimizing your workflow for CS2103T development, and isn’t comprehensive. But I’ve talked quite a bit about Setting up Eclipse, Using it, and Working with your teammates. I hope you have learned something new and these tips will help you for this module. More importantly though, I hope you keep learning, and share your knowledge with everyone, to that we, and our craft, can grow together - so that we become better software engineers.