Tuesday, February 03, 2009

Obtiva HackFest and Glimmer Tree Data Binding in Progress

Today, instead of having our weekly GeekFest meeting at Obtiva, Dave organized a HackFest instead.

Colin, Dave, Roy, and Nate worked on
Colin's ultimate midi controller project. Tom, Leah, and Jake worked on the Metric Fu Aggregator. And, Tyler, Turner, and I worked on implementing Tree Data-Binding support for Glimmer.

In one hour, we made as much progress as we could, which amounted to coming up with a design for the data-binding syntax in this unit test:

module Node
attr_accessor :parent, :children

class Person
include Node
attr_accessor :name, :age, :adult

def test_root_node_only
adam = Person.new
adam.name = "Adam"

@target = shell {
@tree = tree {
items bind(adam, :name)

assert_equal 1, @tree.widget.getItems.size
assert_equal adam, @tree.widget.getItems.first

To bind SWT Tree items to a model node hierarchy, you pass two parameters to the bind command: the root model node and the name of the attribute to be used for displaying text in the tree.

More tests will eventually be written to test data-binding a root model with children.

In the future, this will probably grow in other directions to handle tree node images and selection.

Test-driven design is a common practice at Obtiva as it gets many birds with one stone: ease of exploration of ideas, test-coverage, clean code design, and higher productivity due to incremental development preventing endless hours of debugging.

Stay tuned for more on Tree Data-Binding support in Glimmer in the future.

No comments: