Archive for the 'design' Category

TDD Training

Tuesday, October 30th, 2007
Refactoring - Martin Fowler

This week I’m attending Brian Button’s course on Test Driven Development. As someone who has considered himself an agile programmer for a while now, I’m finding myself more and more enlightened by the core techniques of Martin Fowler’s book, Refactoring. It is one of the texts of this course, and I can’t believe I’ve been coding without this book for so long.

At almost every job I’ve worked here in St. Louis, I’ve seen this book on someone’s desk or in a library area, but I’ve never bothered to pick it up. But after this course, it will be a staple of my (annoyingly ostentatious) desktop bookshelf.


BoxLayout vs. GridBagLayout

Thursday, June 22nd, 2006

For as long as I’ve been programming, I’ve never liked using WYSIWYG editors to layout my GUI elements. This goes all the way back to when I was just beginning web programming and HTML markup. I paid a lot of money for the suite of Macromedia software, including Flash, Fireworks, Freehand, and Dreamweaver. When I first started with Dreamweaver, I loved it. But the more I got into using it, the more I got frustrated with the things it wasn’t letting me do. When you are using an editor like that, it has to be somewhat smart in order to guess what you are trying to do. So it will “snap” elements to other elements, resize things the way it thinks you want to see them, etc. This can be just as annoying as it is handy.

I made the giant leap from Dreamweaver to straight HTML markup back in 2000, and I’ve never gone back. Even with my Java programming, I still can’t stand using the IDE editors. And it’s not that I haven’t tried! Several times when I was getting used to NetBeans, I attempted to use their editor to layout my screens. Sometimes it worked pretty good, and sometimes it just didn’t. Maybe I would get better and more efficient using the editors if I would give them another good college try, but I’m so set in my ways that I don’t think I can.

Now, although it was probably just as frustrating to figure out the nuances of Swing and its layout managers, I can make my screens look exactly like I want them (and with less code than the IDE would use, but who cares about that nowdays?).

So anyway. I guess that is my prologue to this weblog entry. I wanted to write something about the Swing BoxLayout. Although I’ve been a user of the GridBagLayout for years now, I’ve never really been happy with it. If you’ve ever used it, it’s probably because you were trying to do something too complex for a simple BorderLayout or GridLayout. You also probably realize how bloated and unintiutive it can be. But I’ve always been able to do (almost) exactly what I intended to do after a bit of trial and error (weightings are a bitch!). But now I’ve finally attempted to get to know the BoxLayout.

In order to use the BoxLayout, you don’t even have to use the BoxLayout. You can just use the Box. This is a class that is already “layed-out” for you with the BoxLayout. You can treat it just like a JPanel with a BoxLayout. Now although the Box doesn’t give you much versitility in 2 dimensions, you can combine several boxes to create a combo layout that meets your needs. For really complicated designs, I would suggest you still use the GridBagLayout, but for those designs that are just too much for the simpler layouts and not-quite-complicated-enough for the GBL… this is a nice quick-easy solution.

References