Wednesday, May 9, 2007

Launchy 1.25

If you're on Windows and you haven't tried Launchy yet, I'd recommend that you give it a try. My appreciation for it grows daily, and the new version adds several nice features. I'm pretty happy with the Go-y community-contributed plugin as well, although I imagine I'll only use that when I've got a lot open.

Eclipse Plugin: NTail

NTail looks useful; the ability to 'tail' a log can be handy; integrating that with Eclipse makes it convenient, particularly if you're running a debug session or something of that nature.

Tuesday, May 8, 2007

An Introduction to Commons IoC

Not to be outdone by the Dependency Injection Meta-Container, the Jakarta project is proud to announce Commons IoC.

In keeping with the proud tradition of Commons projects like Commons Logging, Commons IoC aims to bridge the wide array of Inversion of Control frameworks with a single API.

Accordingly, using a single programming model, users of Commons IoC can now build an injected-dependency application that can seamlessly switch, with a minimum of coding changes, between IoC from:

  • Spring Framework
  • Pico Container
  • HiveMind
  • Guice
Although this doesn't span all IoC frameworks, Commons IoC plans to continue to bolster support in later releases as necessary.

Configuration
Here's an example of injection in the Spring framework:
<bean id="exampleBean" class="examples.ExampleBean">

<i class="lineannotation"><span class="lineannotation"><!-- setter injection using the nested <tt class="literal"><ref/></tt> element --></span></i>
<property name="beanOne"><ref bean="anotherExampleBean"></property>

<i class="lineannotation"><span class="lineannotation"><!-- setter injection using the neater 'ref' attribute --></span></i>
<property name="beanTwo" ref="yetAnotherBean">
<property name="integerProperty" value="1">
</bean>

<bean id="anotherExampleBean" class="examples.AnotherBean">
<bean id="yetAnotherBean" class="examples.YetAnotherBean">


One from Hivemind:
service-point(id=CayenneService interface=markko.hivemind.CayenneService) {
invoke-factory(service-id=hivemind.BuilderFactory) {
construct (class=markko.hivemind.CayenneServiceImpl) {
initialize-method (method=init)
}
}
interceptor (service-id=hivemind.LoggingInterceptor)
}


And one from Guice:
public class MyModule extends AbstractModule {
protected void configure() {
bind(Service.class)
.to(ServiceImpl.class)
.in(Scopes.SINGLETON);
}
}

Notice how each of these is significantly different. Not only are they different in format, but they're different in intent. After some discussion, Commons IoC has elected to take another page from the Commons Logging and simply allow the users of Commons IoC to configure their injection within the base implementation, thereby retaining the full power of your chosen IoC tool's configuration.

Commons IoC in Action
So, having configured your application for injection, how do you use Commons IoC? You simply define your objects using one of these protocols, which Commons IoC supports for injecting dependencies into an object.

Constructor Injection:
public class MyClass()
{
private MyDependency depend;
public MyClass( MyDependency depend ) { this.depend = depend; }
}


Setter Injection, e.g.:
public class MyClass( )
{
private MyDependency depend;
public void setMyDependency( MyDependency depend ) { this.depend = depend; }
}


I hope this has given you a new understanding of Commons IoC and how to use it in your projects.

(yes, i'm kidding; really)

Saturday, May 5, 2007

Why RIAs Look Good: The Web Is a Mess

Bruce Eckel's "Web Standards: Only Less of a Mess" comes down to these three points:

  • These days, you can build the web using standards and get it to work in the major browsers.
  • This usually involves a fair amount of trial-and-error, some learning. Even in this new "web standards" world, the web is still a bit of a mess.
  • This mess is what has made building rich internet applications so painful all these years, and what makes alternate approaches, like flash and flex, appealing.
Now, I'm not sure that Eckel would agree with the way I've summarized these points, so feel free to read the original, but it's in line with how I feel about the web.

A web designer came by my desk the other day. I was waiting for my build, and re-reading the ALA article on three-column layouts. He noticed, and asked, amused, "Are you aiming for my job?"

Far from it. I've been programming for so long that I expect a clean working relationship between me and the computer: I tell the computer what to do, and it does what I tell it. Between inconsistent brower implementations and object models, incomplete and half-hearted standards implementations, the Web is not quite so sensible. It's a trial-and-error affair, one where many people rely on abstraction layers like Dojo, and Yahoo UI widgets, because doing it yourself is so darn painful.

I mean, three-column layouts are one of the most common web layouts -- how can it be so hard to do one? Why is this not basically equivalent to declaring in CSS that you'd like to take the three sections you've specified in HTML and lay them out in three columns?

This is why I almost wish we'd toss out a few of these standards and start again, start with something more complete and more standardized. That's not going to happen, but I can dream.