Archive for December, 2009

JSON as a Universal DB Model DSL

December 30th, 2009

I write web applications rarely and reluctantly. I am not the most qualified to initiate a project based on the following ideas. If I did, it would likely  fall into a state of disrepair once my ephemeral attention has shifted back to playing with stock prices. However, I think it is a good idea. I am hoping someone who has both the time and interest codes it up. This is a new level of lazy.

var user_model = [
    // column name , generalized type,   , validation rule,   hidden?
    ['first_name'  , 'text'              , 'name_regex'              ],
    ['last_name'   , 'text'              , 'name_regex'              ],
    ['middle_name' , 'text'              , 'name_regex'              ],
    ['birth_date'  , 'date'              , 'over_18'                 ],
    ['location'    , ['double','double'] , undefined,        ,   true],
    ['addresses',  , 'has_many'          ,                           ]
];

Basically, from a Rails perspective, replace your ruby database migration DSL with code that parses the above JSON (e.g. user_model.json) and creates the appropriate schema. Replace your ActiveRecord validations with the validations from the json model. (Depending on your language, there may be differences in REGEX syntax. Having some well defined common REGEX definitions, such as EMAIL_VALIDATION, might be appropriate.) On the client side, you can display most forms automagically, based on the order defined in the json model (if it is in fact an array.) Furthermore, you can also run client side validations before submission. (If your validations are so weak that sharing them remotely represents a security risk, you are probably doing something wrong.) It might also remove the need for many controllers. A lot of CRUD is so generic that it might be possible to have a single /:model/:action/* controller. Scaffolding is not DRY. Finally, as the lingua franca, sharing model definitions outside your project’s language is simplified.

Any takers?

A Math Lesson for Nancy Pelosi

December 7th, 2009

Nancy Pelosi is now an vocal exponent of H.R. 4191, the “Let Wall Street Pay for the Restoration of Main Street Act of 2009.” (This makes me pine for Orwellian naming templates. If they titled this bill, “The Freedom and Security for the American Financial System Act,” at least I could delude myself into thinking that its true purpose was obfuscated to the average nightly news watcher, rather than being an unmistakable deference to mob opinion.)

The following is a reasonably accurate summary of the bill:

The U.S. Government’s fiscal situation is FUBAR. For foreseeable and unforeseeable reasons, the deficit is now a leviathan. For the sake of expediency, it is best to go with the tried-and-true Democratic narrative that places all of the blame squarely on the shoulders of the evil Wall Street fat cats. (This narrative is mostly a pastiche of Scrooge McDuck. The government has an odd tendency to use cartoon ducks to sway popular opinion.) Since Main Street’s unemployment has persisted while Wall Street’s profits have returned, the best course of action is to use fervid populist opinion, to take money from the ostensibly stable and wealthy Wall Street firms and redistribute it to the unstable industries that would obviously be irreparably damaged if not for the infusion of money.

Since the political actors are perennial fans of war analogies, I’ll make one of my own: H.R. 4191 is similar to a situation in which there are 5 wounded soldiers and one unharmed soldier left on a battlefield. Upon reviewing the situation, the feckless medic who has just entered the fray realizes that these soldiers will need blood transfusions. The medic proceeds to shoot the unharmed shoulder in the thigh, allowing the blood to messily drain into a pan to be given to his comrades. This is hyperbole; it is also not far from the truth.

Irrespective of the fact that the Wall Street firms are far from healthy — they may be making large profits but they are still exposed to some terrific risks — a cursory glance at the numbers using basic arithmetic, would suggest that Wall Street is not likely to be the one bearing the costs of such a tax raise. (Basic arithmetic is probably above the botox battered brain of Nancy Pelosi.) I am not talking about the pedestrian argument that suggests the tax would be passed on to consumers. I am referring to a more damning flaw: no market maker could pay this tax.

Take, for example, the 25 basis point tax on plain old stock transactions. Looking at Yahoo Finance right now, I see the bid-ask on SPY is 111.20/111.21. Market makers looking to make a few pennies on every transaction might have difficulty staying in the black with a 25 basis point tax per transaction. (I was unable to ascertain whether the tax is levied once per side or once per round-trip; For a conservative estimate, I’ll assume it is only levied once per round-trip). This would mean the market maker could only profit on swings of at least 28 cents if he was hoping to avoid bankruptcy.

(Ironically, some of the proponents of this bill were touting it as a structural method of reducing volatility! They argue that with a tax, there are incentives to hold positions longer. That may be true for marginal day traders. However, market makers would have to significantly widen spreads in order to survive. Wide spreads translate into higher volatility.)

Since market makers are integral elements of markets, it seems likely that they would be exempt from this tax. While the tea-party crowd loves to shout that the “Progressives” are socialist wolves in sheep’s garb who are looking for any and every way to demolish capitalism, I’m not so conspiracy-minded. Progressive Congressmen and Congresswomen would be forced to exempt market makers in order to maintain market integrity. At which point the absurdity of the bill comes into sharp focus: the bill that would force Wall Street to “contribute” to the economic recovery would…EXEMPT WALL STREET?!

P.S. I appologize for the discordant feel to this post. I am a bit peeved by this bill and could not proceed stoically. I have spent the past 9 years of my life learning about markets so that I could be a competitive trader. This bill would render 9 years of sacrifice (lower grades in college; no traditional forms of employment to build my credentials; less time with friends and family) wasted for arbitrary reasons. I suppose this is true for most congressional edicts.

Fund-raising is done wrong

December 5th, 2009

Soliciting small donations is called fund-raising. It involves straight-forward requests, bake sales, pay-per-mile jogs, and beef-steak dinners. It is not glamorous. Soliciting large donations is called development1. It is glamorous. It involves managing relationships (see: SalesForce, Convio, Kintera.) People who work in development are ostensibly paid a premium because they either have or are capable of building a network of high net-worth contacts from which funding can be extracted. The more general the cause they advocate for, the more important they become.

Most not-for-profits favor development over the solicitation of small donations. This preference was probably justified in the past but now exists as a historical artifact — a philanthropic appendix.2 The cost of building and maintaining a motivated army of constituents was much higher twenty years ago than it is now. However, with the advent of internet-based communications, it can now be practically free in terms of time and money. This preference may now persist due to certain cognitive biases. It may appear as though finding one large donation is more likely than finding N small donations of equal aggregate value.

For small highly-focused organizations, I believe this nearly ubiquitous preference is sub-optimal. The constituent beneficiaries also have networks of contacts: their friends and family. The relationships between the constituents and their friends and family are likely to be far stronger than anything a development professional could build. I have been impressed by the generosity of my own family and friends in supporting my cause. I was also impressed by the initial strong push made by the Chordoma community in general after I offered them a fund-raising tool. Unfortunately, the initial success of community fund-raising was soon marred by swift appearance of fund-raising fatigue. Ignoring the poor quality of the first implementation, I completely missed a very important feature set: feedback. I believe that novelty combined the promise of proactivity resulted in a strong drive at first. However, after funds had been collected, there was a post-endeavor funk. Money had been raised, but there was no obvious coincident progress made on the non-monetary front. (Such an expectation is not rational nor was it encouraged, but I assume it was a quietly held assumption nonetheless.)

I believe feedback mechanisms could alleviate this problem in the same way that repetition in marketing leads to consumer interest. Early on it was decided that coaching mechanisms — nagging reminders, occasional notifications of non-monetary progress, and reports on historical donors that have not given recently — would be beneficial. Unfortunately, life intervened and I never implemented those features. This is unfortunate as I subsequently concluded that such mechanisms are crucial. (I think MoveOn.org’s email campaigns are a paragon of good feedback mechanisms in fund-raising. Ignoring the accompanying inane commentary, they are brutally effective.)

I should also note that in favoring beneficiary empowerment, the organization does not preclude the possibility of receiving large donations. Again, exploiting the social connections of your constituents gives you a far deeper social reach than that offered by development professionals. For causes that affect people randomly across socio-economic parameters, you’re going to find some potentially wealthy individuals. The constituents are engaging in the search for wealthy donors at no expense, in time or money, to the organization. If they tease out a potential large donor, why should they then be referred to a development professional? The potential donors interest is already piqued. Now they need to be convinced that their money will not be given in vain. They need to be sold on the efficacy of the organization. The development professional could (and basically does) play this role. However, since it has already been established that the donor is a strong lead, this role could also be played by someone intimately involved in the actual decision making of the organization.

Obviously, I have made a lot of assumptions in asserting the superiority to community-style fund-raising over top-down development work. Some of these assumptions are known to me, but I am probably ignorant of others. I encourage the reader to leave comments to help guide me while building Fundify, which will act as a test of my fund-raising hypothesis.3 Expect to see an alpha with active deployment sometime in late December / early January.

Notes:

  1. I strongly dislike the term development in this context, but it’s part of the industry nomenclature. In the non-profit world, development means a combination of marketing and one-on-one salesmanship.
  2. Medical g33ks: I understand this might not be strictly true. Please refrain from commenting that this not a perfect analogy.
  3. Actually, Fundify is being built to raise money for Chordoma research, a rare type of cancer. I have Chordoma. I would like to not have to worry about Chordoma. That being said, focusing on testing my hypothesis is a better motivational tactic. Intellectual curiosity is a robust motivator; Terror inspired by mortality is a persistent drain.