Intentional Software - Democratizing Software Creation
Business users doing programming? Simonyi and Kolk presents how Intentional Software offers a radical new software approach that separates business knowledge from software engineering knowledge.
Tracking change and innovation in the enterprise software development community
Posted by Werner Schuster on Jul 06, 2007 09:30 AM
Swing was added to the JRE with version 1.2 in 1998, after it's predecessor AWT turned out to be insufficient for nontrivial applications. One of Swing's problems (next to the performance and Look and Feel issues) іs the amount of code necessary to build even small applications. This has lead to a host of XML based GUI definition languages to be created.new. A sample of Profligacy code:
@ui = Swing::Build.new JFrame, :texts, :label do |c,i|See the link for more sample code.
c.texts = [JTextField.new(10), JTextField.new(10)]
c.texts.each_with_index {|t,n|
t.action_command = "text#{n}"
}
c.label = JLabel.new "Something will show up here."
i.texts = {:action => method(:text_action) }
end
@ui.layout = FlowLayout.new
@ui.build("Two Text Fields Demo").default_close_operation = JFrame::EXIT_ON_CLOSE
def text_action(type, event)
puts "EVENT: #{type} #{event.action_command}"
end
menu_bar {
menu('File') {
mnemonic :VK_F
menu_item('Exit') {
mnemonic :VK_X
on_click { @frame.dispose }
}
}
}
This shows how Ruby's method_missing and Blocks are used to allow for some very compact code creating a component tree consisting of a menu_bar holding a menu with one menu_item. The method calls all take Blocks (the code in braces) which are executed. A combination of metaprogramming and method_missing is used to determine whether to create a new object or execute a method such as mnemonic on a just created object. As can be seen with the on_click call, Cheri::Swing also allows easy event handling. The on_click takes a block which will be executed when this MenuItem is clicked, hiding all the tedious setup of Listeners or Actions. bind operator from JavaFX Script. This allows to define expressions which are evaluated whenever one of the variables it references is reassigned. This takes care of event handling in a compact way. A sample:
require 'swiby'Which one of these APIs will become relevant in any way remains to be seen. Swing XML GUI definition libraries are a dime a dozen, with no end of newly created ones in sight. The difference to them is that the JRuby libraries are generally quite small, in the case of Profligacy currently 200 lines of code, with no 3rd party dependencies. This makes them easy to understand and maintain. And since they all allow to write GUI definitions in Ruby, they are also much easier to extend. If some feature or combination of components is not supported, it's possible to fall back to just handling Swing objects instead of having to lobby the library maintainer to add a feature.
class HelloWorldModel
attr_accessor :saying
end
model = HelloWorldModel.new
model.saying = "Hello World"
Frame {
title "Hello World F3"
width 200
content {
Label {
text bind(model,:saying)
}
}
visible true
}
IBM Web 2.0 Developer eKit: Free Tutorials, Webcasts, Whitepapers
IBM Agile Development eKit: Free Articles, Expert Q&A, Educational Resources
Introducing Project Zero: Building RESTful services for your Web application
Business users doing programming? Simonyi and Kolk presents how Intentional Software offers a radical new software approach that separates business knowledge from software engineering knowledge.
Jason Rudolph discusses Java/Grails integration, Grails plugins, creating a Grails sample application, Grails app structure, data querying and persistence, validation, controllers and tag libraries.
The Scrum Product Owner role is powerful, valuable and challenging to implement. It brings healthier relationships between customers and developers, and competitive advantage - if you do it right.
Effective Java, Second Edition by Joshua Bloch is an updated version of the classic first edition, which won a 2001 Jolt Award. InfoQ asked Bloch questions about the areas that the new edition covers.
A new article by I. Drobiazko and R. Zubairov introduces v. 5 of the Apache Tapestry component-oriented web framework. The tutorial shows how to create a component and covers IoC in Tapestry and Ajax.
In this interview, Burton Group consultant Pete Lacey talks to Stefan Tilkov about his disillusionment with SOAP, his opinion on REST, and addresses some of the perceived shortcomings REST vs. WS-*.
Jay Fields presents his concept of Business Natural Languages - a type of Domain Specific Languages geared towards being readable by domain experts.
Adoption and interest for Distributed Version Control Systems is constantly rising. We will introduce the concept of DVCS and have a look at 3 actors in the area: git, Mercurial and Bazaar.
1 comment
Reply