SpringOne Americas

Private Events

Blogs

View all Blogs >>
  • Kirk Knoernschild

    Software Developer & Mentor

    An image more»

  • Jason Rudolph

    Author of Getting Started with Grails

    I had the more»

  • Brian Pontarelli

    Founder of Inversoft

    Found a good fix for this one as well. This will work on LIs or DIVs. Here’s how to do this in IE and FireFox: li { display: inli more»

  • Mike Levin

    Software Developer specializing in Web2.0 websites

    more»

  • Ryan Shriver

    Business and Technology Consulting

    more»

  • Matthew Bass

    Software Developer & Entrepreneur

    Many Rails plugins require that certain files like images, CSS, and JavaScript get copied to the public folder during installation. The... more»

  • Neal Ford

    Application Architect at ThoughtWorks, Inc.

    One of the techniques I more»

  • Howard Lewis Ship

    Creator of Tapestry and HiveMind

    The latest release of Tapestry, Tapestry 5.0.16 (Release Candidate), is now available. Tapestry 5.0.16 is the release candidate; we... more»

  • Alex Miller

    Sr. Engineer with Terracotta Inc.

    The Lamb da Lounge is a new St. Louis area user group focusing on functional and dynamic languages. The first more»

  • Michael Nygard

    Agile technology leader and dynamicist

    Patrick Muellr has an interesting post about being more»

  • Nathaniel Schutta

    Author, speaker, software engineer focused on user interface design.

    Today we learned something important, the NTSB announced the more»

  • Jeff Brown

    SpringSource Engineering And Professional Services - Groovy and Grails Developer

    Strange enough title.Let's start with a hypothetical conversation between a geeky developer and his much less geeky wife: more»

  • Ted Neward

    Enterprise, Virtual Machine and Language Wonk

    ... Corey Vidal, you have outdone every YouTube video I've ever seen, and I was a hug more»

  • Pratik Patel

    Enterprise Architect

    SpringSource today announced that it has purchased G2One, the folks who have been driving the development of Groovy and Grails. The following... more»

  • Graeme Rocher

    Project Lead of the Grails Project & CTO of G2One

    You may have already read about it in the various news outlets and blogs covering the announcement, but if you haven’t I’m excited to spread... more»

  • Stuart Halloway

    CEO of Relevance

    I will be bringing more»

  • Andrew Glover

    Co-author of "Continuous Integration"

    more»

  • Matt Raible

    Creator of AppFuse and author of Spring Live

    This morning, my co-workers and I discovered that Link edIn decided to trim 10% of its employees. The Denver Offi more»

  • Jared Richardson

    Agile coach and co-author of Ship It

    Jurgen Appelo has an ongoing interview series on his blog. He's published a lot of very smart people and I'm honored to squeak in too! ;) more»

  • David Bock

    Principal Consultant, CodeSherpas Inc.

    I have been setting up a rock-solid server cluster for a client and ran into an interesting issue trying to install Phusion Passenger onto... more»

  • Richard Monson-Haefel

    VP of Developer Relations, Curl Inc.

    more»

  • Pramod Sadalage

    Co-author of "Refactoring Databases:Evolutionary Database Development"

    Consider this Hibernate mapping @Column(name = "qReferenceId") public Long getQReferenceId() { return qReferenceId; more»

  • Craig Walls

    Author of Spring in Action

    At one time not too long ago, I wasn't a big fan of annotations. But then I let my guard down and even started liking them. But now I'm... more»

  • Brian Goetz

    Author of Java Concurrency in Practice

    more»

  • Scott Leberknight

    Chief Architect at Near Infinity

    In late 2006 Neal Ford wrote about Polyglot Programming and predicted more»

  • Kenneth Kousen

    President of Kousen IT, Inc.

    In this entry in my “Making Swing Groovy” series, I want to talk about threading issues. Specifically, more»

  • Erik Doernenburg

    Principal Consultant @ Thoughtworks

    One of my favourite tools to render graphs is Gra phViz Dot and in an more»

  • Venkat Subramaniam

    Founder of Agile Developer, Inc.

    I wrote a four part article for Java World on creating DSLs in Java and Groovy. For your convenience, I decided to list the links to those... more»

  • Jason Harwig

    Senior Software Engineer at Near Infinity

    The most popular entry I've written at Near Infinity has been the more»

  • John Heintz

    Principal Consultant with New Aspects of Software

    In a recent discussion interview questions came up, here's my favorite one.To set some context this question is designed to gauge the abst more»

  • Mark Johnson

    Director of Consulting at CGI

    At the Columbus NFJS show held on July 25-27th during one of the BOF sessions Dave Bock, Scott Davis and I discussed unit tests vs functional... more»

  • Joseph Nusairat

    Author of Beginning JBoss Seam & Co-Author of Beginning Groovy & Grails

    Well i am assuming Apress has the most random site in the world at times.But today only they have our recent book, Beginning Groovy & Grai more»

  • Keith Donald

    Lead of Spring Web and Creator of Spring Web Flow

    I am pleased to announce that Developing Rich Web Applications with Spring, a three-day bootcamp lead by SpringSource engineers on web... more»

  • Vladimir Vivien

    Software Engineer / Consultant

    Judging from the list of features that will be included in NetBeans 6.5, more»

  • Pete Behrens

    Organizational Agility Coach

    Marti nig & Associates Methods & Tools group recentl more»

  • Brian Sam-Bodden

    Java author, Ruby geek and Open Source Advocate

    In this installment we are going to build the Dashboard page of the Tempo application. T more»

  • Mark Fisher

    Spring Integration Lead

    In my recent post, I had mentio more»

  • Ron Bodkin

    Chief Software Architect, Quantcast

    I'm looking forward to speaking at The Rich Web Experience conference in San Jose next month. The event runs from September 7th through 9th.... more»

  • Mark Goodwin

    Web Application Security Specialist

    We've already looked at one of the two big problems posed by anti DNS pinning on Java applets; because there's rebinding on the applet and... more»

  • Scott Davis

    Author of "Groovy Recipes" & TDD Expert

    Every time I see a live show at the Denver Botanic more»

  • Romain Guy

    Java User Interface expert.

    more»

  • Ramnivas Laddad

    Author of AspectJ in Action, Principal at SpringSource

    InfoQ.com has published my AOP myths and realities talk recorded at a No Fluff Just Stuff conference. InfoQ.com founded by Floyd Marine more»

  • David Geary

    Author of Graphic Java and co-author of Core JSF

    The 2006 NFJS tour kicked off t more»

  • Kito Mann

    Editor-in-chief of JSF Central and the author of JSF in Action

    JBoss Tools 3 Beta1 was built and made available on Halloween night. This release will only work with Eclipse 3.4/Ganymede. We recommend you... more»

  • Jason Hunter

    Author of Java Servlet Programming

    I just posted the JDOM 1.1 release for download. This release includes about 20 improvements and bug fixes. more»

In the Spotlight - Alex Russell

Alex Russell

Project Lead, Dojo Toolkit & Director of R&D, SitePen

Alex Russell served as Project Lead for the Dojo Toolkit from 2004 to 2008 and is Director of R&D at SitePen, a consultancy focused on the development of web applications, exceptional user experience, and pushing the limits of the web. Currently, he serves as President of the Dojo Foundation, an organization that supports development of several high-quality, open source, JavaScript projects and distributes them under liberal terms. Prior to joining SitePen, Russell was a senior engineer at JotSpot and Informatica where he helped both companies build highly interactive, web interfaces. His earlier, open source involvement included stints as editor of the OWASP Guide to Building Secure Web Applications and primary author of the netWindows DHTML toolkit.




















Continuing Intermittent Incoherency
Alex Russell's notes on the web, life, and Dojo


Alex Russell's complete blog can be found at: http://alex.dojotoolkit.org

Saturday, November 1, 2008

Contents after the jump due to the political (and highly contentious) nature of the content.

A couple of weeks ago I had the great honor to officiate the beautiful civil ceremony that saw my dear friends Caryl and Amy married. As Jennifer and I were married just a bit earlier in the year, we were well aware of the logistical nightmare that is a wedding. Given everything else that was going on in the lives of our friends at the same time, the timing of the wedding seemed likely to give one of them a heart attack…but there really wasn’t much of a choice. It’s now or potentially never.

The shortened timeframe that many of our friends and colleagues have planned their weddings on is due to the impending vote on California’s Prop 8 ballot initiative which seeks to amend the California constitution to take away the right of same-sex couples to marry. For those who haven’t been following along closely, earlier this year the California Supreme Court ruled (on a split vote) that Article 1 makes denying the rights of civil marriage to any set of consenting adult citizens illegal.

This makes some people crazy, irate, or both.

Not a week after our friends were married, Jennifer and I were folding laundry while listening to the radio. An episode of the call-in show Forum came on which had the “pro” and “con” sides both represented by articulate advocates. I can’t recommend strongly enough that you listen to the broadcast, since it gets to the core arguments for and against Prop 8 in an incisive way.

Fundamentally, the prop-Prop 8 argument (i.e., anti gay marriage) is that it’s always been done this way, that gay marriage in some way undermines straight couples and the family structure, and that change would make those who are against gay marriage feel like they are being discriminatory. The first argument I have some sympathy with, particularly as it relates to the appropriateness and timing court decisions. When courts are significantly ahead of public opinion regarding grants of negative rights, the potential to exacerbate existing social frictions is very real. This can harm lots of people on both sides of an issue. That, on balance, however hasn’t been sufficient grounds to continue to deny major groups of Americans rights before (think women’s suffrage and equal pay). Arguments based on the idea that something has always been done a particular way therefore run counter to the subversive and radical nature of the American system. We base interpretation of the law on argumentation (informed, of course, by common morality). Courts are not allowed to re-enforce the status quo simply to preserve a group’s sense of comfort. Groups looking for a particular remedy must provide an argument that squares with the Constitution. It’s worth remembering that documents which suggest that everyone is entitled to equal rights under the law aren’t common in human history. There is nothing so American, then, as to suggest that what makes us different is that we explicitly recognize the rights of groups not like ourselves. After all, it’s the only way to guarantee that those groups respect and preserve the rights of others as well.

That, then, leaves the arguments that gay marriage (or, more broadly, an understanding that being gay is not criminal) will cause the decay of straight relationships and marriages. As a married straight person, I find this argument ridiculous. Let me be very clear on one point: when we as a society recognize the rights of our minorities, we do not create those minorities from whole legal cloth. The people who that Prop 8’s supporters want to take rights away from have always existed. It’s not as though the recognition that they have been oppressed for centuries somehow makes that continued oppression right. Nor does it suddenly cause more people to “become gay”. I’ve had gay and lesbian friends since high school, and never once has it caused me to question my own sexual orientation. Given the deep conversations I’ve had with my friends over the years, it’s clear to me that being gay is as much of a choice as being black is. Those who oppose civil gay marriage seem to believe that they aren’t doing any harm to anyone by denying others rights. What this means to me as someone who grew up in a very conservative part of the country but nevertheless has nearly always had gay and lesbian friends is that Prop 8’s supporters are simply denying the harm they have caused to their own communities, families, and co-workers. It is simply willful ignorance to wish away ten percent of the population. Likewise, their argument assumes that some among us don’t deserve equal protection because somehow granting them standing in court will diminish the standing of straight couples. I have yet to see any compelling evidence of this.

Lastly, the argument that children will somehow see their parents as bigoted and that parents have a right not to be viewed as prejudicial by their families strikes me as particularly foolish. Progress requires that we change, and change requires that we acknowledge that what came before was not optimal. This is true no matter how you define “progress”. To effect real change, abolitionists required an understanding in the populace that slavery was wrong. Similarly, prohibitionists had to build a large constituency against alcohol consumption in order to get the eighteenth amendment passed. In both cases the question of moral right and wrong needed to be settled independently of the question of legal and illegal, but settling that issue was a pre-requisite for social change and legal action. In each case, large sections of the people fundamentally disagreed with the majority well past when the issue appeared “settled” in the law. That is a question of private morality and the fact of the disagreement is what animates our political and legal processes. Without recognized disagreements, how can there ever be progress in any direction?

So the question for those concerned parents comes sharply into focus: do those parents agree with every single other thing taught in public schools? If they don’t (and I’m guessing parents who are “Yes on 8″ voters aren’t big on, say, biology, astronomy, and the scientific method), how do they handle the the other disagreements? What makes this one so much different? Have those parents abdicated the teaching of morality to the public schools on every other front? And why do they assume that they won’t be able to exercise their rights to have their kids exempted from teachings they don’t agree with on religious grounds?

Lets get to the real center of this: religious groups have a right to be prejudiced against whomever they please. It’s a fundamental part of being an American that you are allowed to believe whatever you want. It’s not, however, a recognized right that you will never be presented with evidence of your disagreement with others. Hiding behind a cloak of forced ignorance and denial is intellectually and morally dishonest. If the church to which I belong wants to argue that gay marriage is sinful, wrong, or in some other way morally bankrupt, then it needs to have the courage of its convictions to make that case forcefully in the world as a moral and ethical case. Isn’t it the church’s job to convert those who disagree with it to the church’s way of viewing the world and in so doing change their behavior? If religious organizations think that it’s wrong for gays and lesbians to practice their rights under the law, it’s incumbent of the church to convince gays and lesbians of that, not the rest of us.

When the church over-reaches and instead attempts to legislate from the pulpit, both the genius of the constitution and the authority of the church are jeopardized. Arguing the civil implications on the moral grounds is simply inconsistent with how our law operates, and the church knows it. Worse, what if the church were to win such a fight on that basis? Who then interprets where to go from there? Lots of faiths with many differing views all reject religious gay marriage…which of those faiths should be consulted next time? All of them? What if they don’t agree? It’s a far better thing that the Church understand the distinction between church and state in order to preserve the independence of its message from the corrupting influence of power. History is crystal clear on this point.

More to the point, though, if you wish to be prejudiced why should it somehow cause distress that others disagree? Isn’t the mere fact of the disagreement an opportunity to make a case? And if the argument doesn’t hold up for the majority of the population, doesn’t it deserve to loose? For churches and communities of faith to attempt to argue that the institution of holy matrimony (as distinct from civil marriage) is in any way affected by the equal protection provisions of the law is dishonest and misrepresents their interest in the political process. To argue that it would be best if society simply didn’t recognize the difference between the law and what the church teaches is also disingenuous, dishonest, and dangerous to the church.

I cannot support Prop 8, and I urge you not to either. Please vote “no”. The proponents have not fielded good arguments that show harm and have resorted to incredulous arguments which bear no resemblance to the truth. The opponents have sought and won the protection of the law. Taking that away – which is what is on the ballot – is unconscionable.


Wednesday, October 22, 2008

My warmest thanks and a hearty “congrats!” to the Uxebu crew and Dylan for getting the new dojofoundation.org site up and running:

The new site is important for a couple of reasons. First, it’s a good step in the direction of working to make clear that Dojo-the-javascript-toolkit and Dojo-the-foundation are completely separate entities with different goals and different leadership. The Foundation will take any and all projects that want a good home and are willing to meet the basic criteria that let others trust the code and process behind Foundation projects. It’s been weird that most of the documentation about Foundation policies and procedures has lived on the Toolkit site for so long, and having them be totally separate should help clarify.

Secondly, the Foundation site helps show off the projects which aren’t the toolkit. The Foundation has more than doubled in size in the last year (in terms of projects), and looks set to continue that expansion. That the Toolkit project gets the most attention has been a long-term irritant to nearly everyone involved, and it’s my hope that the Foundation site will help to fix that.

Lastly, the Foundation site is beautiful. Built with the Toolkit and Dojango, the site is a great showcase for the kinds of things that are easy to build with Foundation-sponsored technologies. Nice work everyone!


Friday, October 17, 2008

Content after the jump due to the public policy nature of the post.

Here we go again.

Every four years we go into the partisan spasms of a heat-not-light [dis]enfranchisement “debate”. What’s perpetually lost is any coherent discussion of the causes of the debate. As with gerrymandering, the causes are structural and neither party feels it would serve them to effectively deal with the situation at it’s roots. Not because solving the problem wouldn’t be better for everyone (in both cases, it objectively would), but because it would change the game, and our 2-party system is nothing if not over-specialized to the current rules of the game. In this sense, both redistricting reform (killing gerrymandering dead) and automatic voter registration systems cause the old rules to lose their hold, instantly changing the calculus of holding on to power. Automatic registration via so-called “motor-voter” laws, registration with passport applications, automatic updates with change-of-address on US mail, and other sensible policies are opposed by partisans of both parties because they have the potential to allow discontent to cause large swings in electorate behavior. Today, between the systematic disenfranchisement caused by requiring citizens to register to vote and the effective gerrymandering-based dampening of popular will, enormous changes in likely voter feelings about the direction of the country (or, less often, a locality/district) are required to break an incumbent’s grip on power. As an example, the “right-track/wrong-track” polling numbers in 2006 said that nearly 70% of Americans thought the country was on the wrong track. That feeling swept the Democrats into a razor-thin congressional majority (which the Republicans have been filibustering to death ever since), but in a 2:1 year, wouldn’t you expect a similar landslide in Congress? Perhaps not in the Senate where fewer seats are up for a vote as a structural hedge against change, but certainly we should have collectively turned enough of the bums out to make the remaining ones fear for their jobs. As it happened, in a race with 33 seats up for discussion (15 held by Republicans), only 5 of the bums lost their seats. Now compare that to the most recent pre-Bush period of comparable “right-track/wrong-track” numbers: the Republican revolution” of ‘94. On that basis it becomes evident that a shift in power half-again as large – based on the same “market fundamentals” – was at least justified. 8 seats changed hands in ‘94 vs. 5 in ‘06. The difference? A census and therefore a chance for many states to gerry….er…redistrict. The calcifying power of…um…power worked its magic 2 years ago and the Senate is deadlocked as a result.

All of these effects cause fewer parts of the country to be competitive. If you support competition in markets (as I do), then there’s no higher calling than supporting a competitive marketplace for ideas, and both parties are doing their best to stifle the pricing function of our public policy market. No wonder then that Republicans think they can steal (or at least dispute) an election by challenging voters in Ohio, despite many discredited attempts in the past to find large-scale vote fraud. Eight years of intense Republican scrutiny into the non-issue has utterly failed to turn up any massive conspiracy or even credible small-scale fraud. Remember, pressuring US AG’s to prosecute thin or non-existent voter fraud cases – then firing them when they couldn’t find any and/or wouldn’t make them up – is what got Alberto Gonzalez hauled before congress for months on end, eventually leading to his disgraced resignation and continuing questions as to the impartiality of the DOJ. This isn’t a winner of an issue for the GOP, but it sure is an effective way to try to keep the under-informed from coming to the polls and having their votes counted. And they know it. Scare-tactics and fear-mongering as [keep|get]-out-the-vote strategy. Democrats, naturally, feel that their on-the-ground vote registration in targeted areas can be an effective weapon in distorting the outcome.

Either way, it’s shameful.

The Democratic approach is perhaps less reprehensible since the folks who are registered can vote however they please, but there’s no denying the attempt at demographic distortion. But why should citizens need to register as a separate process from establishing residency, getting mail, or a driver’s license anyway? And why isn’t same-day registration the law of the land? If Wyoming can do it, why not New York and California?

Fundamentally, all the objections to broad enfranchisement end in a large-scale IT problem…but not a particularly hard one. What I’m not hearing from nearly anyone is a recognition that this shouldn’t be a debate that happens in a functioning democracy. That we have it on a quadrennial basis is simply an embarrassing acknowledgment that our democracy is not functioning.

If McCain really wants to put “country first” and be a maverick, he’d be bringing this up as an urgent topic of national debate. It would certainly be better than the sleazy robo-call effort his campaign is now investing in. And if Obama wanted to build real credibility with Americans about his willingness to effect real change, shouldn’t he start here? Certainly it’s a better use of the national discourse than helping McCain draw unwarranted (and likely un-wanted) attention to a plumber. And where the hell is the 4th Estate when we need them?

Oh, right. Camped out on some plumber’s lawn.

Luckily, I happen to live in California where the Governor (who I disagree with more than not) has put redistricting reform on the ballot in the form of Prop. 11. I’ll be voting “yes” on 11, if only to make it that less likely that 4 years from now we’ll have to have this “discussion” again.


Monday, October 13, 2008

Greg Wilkins hits the nail squarely on the head:

At Webtide, we sell developer advice, custom development and production support for jetty and dojo cometd. We don’t expect our clients to buy our services because of some sort of guilt trip from the value they obtain from those projects. We expect our clients to pay for the value add that we give. The software is free under the terms of the apache 2.0 license and we expect no charity or moral obligation in return.

This pretty much sum’s up why most venture-backed Open Source efforts either fail so miserably at building real community or just fail miserably in general. Open Source – to my mind – isn’t some talisman you wave over software to instantly take market share from entrenched players or to instantiate your very own +5 Army of Contributors (with the zealotry bonus) for personal gain. Instead, it’s a great way to distribute software that should already be a commodity at near the cost of reproduction (roughly bupkis) and prevent network effects from ingraining outsized profits to firms whose marginal utility is suspect. If something is still worth paying for, it’s natural to expect that it won’t fare well in the world of free software. Too few people are liable to understand its value to create the virtuous cycle of contribution and use that makes the whole thing work. The great news here is that commercial software isn’t dead at all. It just has to actually be better.

Open Source (and to similar and complementary extent, open standards) helps drive Pareto-efficient allocation of capital in the software business. That may not be a high calling, but it’s a lot easier to justify than living off of monopoly rents for a living, and I take great comfort in knowing that what we do at SitePen adds amazing value (else we wouldn’t make a living at it). As with Greg and WebTide, people pay us for what’s actually scarce: clue, skill, and hard work.


Friday, October 10, 2008

My MBP batteries keep dying after about a year (each). I usually have 2 that I tote around with me, and each tends to be good for 1.5-2hrs of actual work. This means that I tend not to be able to work through a cross-country flight, and particularly not if I need a VM for anything (which is most of the time). I think that if Apple does rev the MBP’s on the 14th, the things I’d pay for boil down to “more memory and much longer battery life”. The 5+ hour flight to TAE then provided a short window to do work in before I retreated to watching episodes of The Colbert Report on my phone. Knowing that i wouldn’t be able to work the whole time, I brought a copy of a great paper on Traits. The paper got me thinking a lot about dojo.declare() and dojo.delegate().

Today, Dojo’s delegate() function is a straightforward implementation of the Boodman/Crockford delegation pattern which Doug calls “beget” and which ES 3.1 will refer to as Object.create:

1
2
3
4
5
6
7
8
9
10
11
12
dojo.delegate = (function(){
    // boodman/crockford delegation w/ cornford optimization
    function TMP(){};
    return function(obj, props){
        TMP.prototype = obj;
        var tmp = new TMP();
        if(props){
            dojo._mixin(tmp, props);
        }
        return tmp; // Object
    }
})();

This function returns a new object which looks to the old object for things it does not itself have. Imagine an object foo which contains pithy truisms:

var foo = {
  science: "rocks!",
  learning: "is how you know you're alive"
};

We now want to promigulate our opinions, so we can delegate the responsibility of forming them:

var bar = dojo.delegate(foo, {
  testify: function(){
    console.debug("science ", this.science, "and learning", this.learning);
  }
);

Now, our bar object can change its mind independently of foo, but until it does, it’ll behave as though foo’s views are its own:

bar.testify(); // outputs: "science rocks and learning is how you know you're alive"
 
// bar refines its opinion
bar.science = "is a process"; 
bar.learning = "requires humility";
foo.science == "rocks!"; // still true
 
bar.testify(); // outputs: "science is a process and learning requires humility"

But what about when the chain gets deeper? The fact that bar can’t “see” foo’s values via this isn’t much of a problem when the hierarchy isn’t very long, but if you’re specializing a behavior or complex interaction, making it possible to get at the parent’s values for properties and methods becomes more pressing.

Neil has previously written about lightweight subclassing, but for as good as it its, it doesn’t get us all the way there either. In regular OO-style languages, the inheritance system gives you an out via a “super” keyword or convention. This type of property shadowing-with-exceptions is a huge boon to composition in class-based languages, but it’s not the whole story. Indeed, the Traits paper was all about the shortcomings of this special-purpose mechanism. What we want for both long delegation chains and long inheritance hierarchies is a more general system; in essence a way to say “I want to control how things are shadowed and which ones an item points at in each level of the hierarchy”.

What if we could make delegate() savvy of this type of indirection? Here’s my quick prototype:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
delegate = (function(){
    var tobj = {};
    var TMP = function(){};
    return function(obj, props){
        TMP.prototype = obj;
        var tmp = new TMP();
        if(props){
            var remaps = props["->"];
            if(remaps){
                delete props["->"];
                for(var x in remaps){
                    if(tobj[x] === undefined || tobj[x] != remaps[x]){
                        if(remaps[x] == null){
                            // support hiding via null assignment
                            tmp[x] = null;
                        }else{
                            // alias the local version away
                            tmp[remaps[x]] = obj[x];
                        }
                    }
                }
            }
            dojo.mixin(tmp, props);
        }
        return tmp; // Object
    }
})();

This new version of delegate() accepts a specially named “->” property in the list of items to add to the destination object. Items in this list can either “shadow null” (hide entirely) the parent’s property or can provide a new name for it, assuming of course that the new object will also have a property of that name. Here’s a quick example of “->” at work with our previous example. This time, foo also has a “testify” method that we’d like bar to be able to control without having to copy the implementation:

var foo = {
    science: "rocks!",
    learning: "is how you know you're alive",
    testify: function(){
        console.debug("science ", this.science, "and learning", this.learning);
    }
};
 
var bar = delegate(foo, {
    "->": {
        "testify": "grampsSays" // maps foo's "testify" to bar's "grampsSays"
    },
    testify: function(){
        if(this.science && this.learning){
            this.grampsSays(); // call the re-named "testify"
        }else{
            console.debug("this object is strikingly ignorant");
        }
    },
});
 
bar.testify(); // outputs: "science rocks and learning is how you know you're alive"
bar.science = false;
bar.testify(); // outputs: "this object is strikingly ignorant"

That New Object Smell

The last missing piece of the hierarchy pie here is that there’s no initializer for the objects which come from a delegation. A simple addition of some property detection code to look for an initializer can easily handle that:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
delegate = (function(){
    var tobj = {};
    var TMP = function(){};
    return function(obj, props){
        // boodman/crockford delegation w/ cornford optimization. 
 
        TMP.prototype = obj;
        var tmp = new TMP();
        if(props){
            var remaps = props["->"];
            if(remaps){
                delete props["->"];
                // like dojo.mixin(), except w/o key/key mapping
                for(var x in remaps){
                    // "safe" copy properties
                    if(tobj[x] === undefined || tobj[x] != remaps[x]){
                        if(remaps[x] == null){
                            // support hiding via null assignment
                            tmp[x] = null;
                        }else{
                            // alias the local version away
                            tmp[remaps[x]] = obj[x];
                        }
                    }
                }
            }
            dojo.mixin(tmp, props);
        }
 
        // support for "constructor" functions. The name "init" is arbitrary.
        if(typeof tmp["init"] == "function"){
            tmp.init.call(tmp);
        }
 
        return tmp; // Object
    }
})();

And there we have it. A style of delegation that easily supports both Trait-like name aliasing (and null shadowing) as well as internal initializers. Since our upgraded delegate can handle nulling out a parent’s value for a property, we also have a straightforward way to prevent parent initializers from being called (or being called/chained - at our discretion - by a new name):

var foo = {
    science: "rocks!",
    learning: "is how you know you're alive",
    testify: function(){
        console.debug("science ", this.science, "and learning", this.learning);
    }
};
 
var bar = delegate(foo, {
    init: function(){ this.testify(); }
});
// outputs: "science rocks and learning is how you know you're alive"
 
var baz = delegate(bar, {
    // map away the parent's constructor
    "->": {
        "init": "superInit"
    },
    // provide our own constructor
    init: function(){
        console.debug("howdy!");
        this.superInit(); // call the super-object ctor
    }
});
// outputs: "howdy", "science rocks and learning is how you know you're alive"
 
var thud = delegate(baz, {
    "->": { "init": null } // hide the parent ctor
});
// outputs: nothing

This form of delegate is likely to appear in Dojo 1.3 along with similar improvements to dojo.declare() to help alleviate the composition problems associated with using complex sets of mixins.

Update: corrected the null-out branch and updated the text with Doug’s note that beget/delegate will be called Object.create() in 3.1.