Week 5, Thursday

April 23, 2009 at 8:48 pm (Java, Ruby, Week 5)

I dug into Limelight today, spending the morning experimenting with a view and styling for a Tic-Tac-Toe board. All the code is Ruby (running on JRuby), so there’s some pretty cool stuff you can do, especially with styling. My favorite features so far are gradients and rounded corners, which cause me nightmares in XHTML/CSS, but they’re as easy in Limelight as this:

gradient :on
gradient_penetration 90
gradient_angle 135
rounded_corner_radius 15
border_width 2
border_color :black

Besides that, other big wins over CSS that I see are the ability to store variables (in my case, things like board_size that I can use to calculate percentage widths of the squares and a simple macro-style inclusion of one set of styles into another (extends :square), which reminds me a lot of SASS. I haven’t seen evidence (and Eric M. and Paul confirm this) that there’s anything like CSS’s nested elements, but I often see those used hackily anyway (yes, that’s a brand-new word, feel free to copy).

Turns out my Java Tic-Tac-Toe will see a little more action after all: apparently it’s possible to have Ruby create Java objects, so that we can write a view in Ruby that will integrate with the rest of my Java program. However, there’s going to need to be some refactoring first, so that the Java view can be constructed more simply and have fewer dependencies. I guess tomorrow at lunchtime we’re going to do a Randori session with Limelight to do some of this integration. I’m excited to see how this sort of thing is done, but I have plenty of work ahead of me to avoid embarrassment as people have free reign over my code. I think I’ll do the refactoring to make the Ruby object creation easy before the Randori, and probably also make the hashing into an interface, so that people playing the game aren’t obliged to have their computers spend so many hours calculating the meaning of life storing records in the database (I stole that bit from Micah).

The alternative would be to rewrite TicTacToe in Ruby, which I’ve done once but I think it’s dirty enough, OO-wise, that it would be harder to integrate by lunchtime tomorrow. I may rewrite the game logic in Ruby at some point, but not yet.

Right now, my assignment is to get a really good user interface together, maybe even some little animations or something to make it look nice. In principle, I feel pretty comfortable with this; when I was implementing XHTML/CSS sites from Photoshop mockups, I got to see a lot of amazing designs, matching them basically pixel-for-pixel, and I think I gained an amateur eye for design by osmosis. But of course, now it’s a matter of learning Limelight!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: