Monday, September 1, 2003

Quickly format your Java code using WebSphere Studio

THIS WEEK'S POWERTIP

By Dan Velasco

Welcome to the second week of the WebSpherePower Update newsletter. My name is Dan Velasco, and I hope to be a helpful guide along your journey through the wonderful world of WebSphere. We'll learn, laugh, and bond together through insightful tips lovingly delivered four times a month to your Inbox. I hope you'll enjoy this week's tip and all of the ones that follow. So, without further ado, let's get on with the inaugural tip. Technically, last week's article wasn't really a tip...it was more of an industry backgrounder. Now this, this is a tip...

Keeping your Java code clean and well-organized is something to which we all aspire. One of the great features of WebSphere Studio is that it allows you to quickly and easily format your Java code. All you need to do is right-click somewhere in your Java code and choose the Format option from the pop-up menu. Provided you don't have any text selected, the Format command will work on all of your Java code in the current file and clean it up for you, doing such things as properly indenting statements to make everything much cleaner and easier to read. If you do have text selected, right-clicking and then choosing the Format option will format just the selected text. This is handy if you only want to cleanup part of your Java code rather than all of it.

I often try and include a mini-bonus tip, and today you're in luck because I've got one just for you. One very nice feature when formatting code in WebSphere Studio is that you can select a line or block of code and then use the Tab key to indent the code. This allows you to quickly move code to position it just where you want. If you want to outdent the code (i.e., move it back to the left), simply press Shift + Tab, and the selected code will go in the other direction.

Since the WebSpherePower Update newsletter is just starting, I welcome any comments, questions, or suggestions that you might have. You can reach me at dvelasco@webspherepower.com. My goal is to provide you with high-quality, practical tips that you can quickly put to use on the job. Of course, since the audience is going to be diverse, not every tip will necessarily appeal to your interests, but I'm going to do my best to include a variety of tips, covering such WebSphere-related topics as development, administration, deployment and integration. Just stick with me, because while some tips might not float your boat, other tips will be exactly what you've been looking for. Thanks for reading, and I'll talk to you next time.

Dan Velasco is a Senior Technical Editor for WebSpherePower Magazine and DominoPower Magazine and is an occasional contributor to Computing Unplugged Magazine. He is also a Principal CLP Application Developer (R4, R5 and ND6) as well as a CLP System Administrator (R4 and R5). You can reach him via email at dvelasco@webspherepower.com or on the Web at http://DanVelasco.com.