MVC: M != the Database

Great article on the misunderstood scope of the “Model” in the Model-View-Controller architecture. The takehome: Models are commonly thought of as wrappers for database access/stored objects, but application state and business logic need to go in them, too. Otherwise you get bloated controller and/or views that clumsily try to take care of these concerns.

Earlier today I was building a multi-step wizard app—no DB storage—and found my controllers getting messy with session and state handling code. The solution was a Wizard class that encapsulated the steps through the forms and the maintenance/validation of the collected data, but until this article I might not have thought of it as a model.

Zend Framework kinda, sorta has a hack for making a wizard using “subforms” and what makes this an awkward construction is that a view helper is not the best place to maintain the state info that a wizard requires. A “Zend_Wizard” class would need to encapsulate several forms; requirements and behaviors for moving forward and backward through the forms; and methods to inc/dec the step state, fetching the active form injected with session data. Only a single controller would be needed with 2 next/back methods, rather than methods for each step.

In the Elgg plugin ecosystem, there’s very little guidance/emphasis on creating models, so writers rarely encapsulate business logic at all. Instead it becomes spread out amongst controllers and—worse—views. Since views can easily be overridden depending on the order of plugins in a list, business logic can easily be mangled by logic from another plugin. That said, the view system does allow mods to mix behaviors in ways that would be difficult were views to be tied more closely to individual plugin models; a few exemplary mods—that store state and validation in a model rather than the controller/views—might help positively influence the culture.

Bass for Stereolab’s “Miss Modular”

“Miss Modular” has an amazing bass line. It’s probably looped on record, but they play it live…and usually faster than the recording. I’m fairly sure it’s capoed at the 7th fret—that’s how I’ve typed it up here.

Stereolab "Miss Modular"
Capo bass @ 7th fret.
spaces/numbers/hyphens = 1/16th notes.
/ = 1/4 notes.

Intro)

  /       /       /       /       /
D                       2---
A         4---              4-
E                             4---
B 0-------    0---2-----          0-------------------------------

Verse)

  /       /       /       /       /       /       /       /
D                       2---
A         4---              4-            4---    4---  2-
E                             4---                          5-2---
B 0-------    0h1h2-----          0-------    0---

  /       /       /       /       /       /       /       /
D                                                 2---
A                 4---  4-- 2-            4---          4-- 2-
E         5---2---            4---                            4---
B 0------/                        2-------    2---

Notes:

  • Mute all the strings, but mostly the bottom 3.
  • At the beginning of the 3rd measure, by fretting the A on the 2nd string, you can slide the end of the low B up to meet it.
  • Chords are just Bm7 and C#m7 (the brass makes A and C#m9 chords)

You Are Not So Smart

The Misconception: You are a rational, logical being who sees the world as it really is.

The Truth: You are as deluded as the rest of us, but that’s OK, it keeps you sane.

You Are Not So Smart is a blog devoted to self delusion and irrational thinking.

And it’s great.

The latest post is about on Subjective Validation, “a fancy way of saying you are far more vulnerable to suggestion when the subject of the conversation is you.”

The tendency to believe vague statements designed to appeal to just about anyone is called the Forer Effect, and psychologists point to this phenomenon to explain why people fall for pseudoscience like biorhythms, iridology and phrenology or mysticism like astrology, numerology and tarot cards.

The last was on Confirmation Bias, which explains the success of political echo chambers and why racism and xenophobia will always be with us; humans are wired to ignore evidence outside their preconceived beliefs.

In the last few years I’ve been taking stabs at my own confirmation bias, seeking out the best arguments and evidence from those I might be inclined to disagree with. While there are a tremendous number of pundits making baseless assertions, especially on the radio and television—mastery of confirmation bias is a winning strategy—there are just as many great writers and thinkers across the political spectrum with worthwhile arguments.

Other great posts:

  • The Just-World Fallacy – People don’t “get what they deserve”
  • Fines – The effect of removing the social cost of undesired behavior

$374B of Bloody Cartel Money Laundered through U.S. Banks

I’ve been waiting for a story like this to come along.

“It’s the banks laundering money for the cartels that finances the tragedy,” says Martin Woods, director of Wachovia’s anti-money-laundering unit in London from 2006 to 2009. Woods says he quit the bank in disgust after executives ignored his documentation that drug dealers were funneling money through Wachovia’s branch network.

“If you don’t see the correlation between the money laundering by banks and the 22,000 people killed in Mexico, you’re missing the point,” Woods says.

With our drug policy, guns, and even our bankers, we’re killing Mexico.

Charter Cities seem better than foreign aid

The Atlantic has a great piece on Paul Romer and his push for “charter cities”. I agree completely with Romer that fair laws with economic liberties is the only way to support economic growth. While probably true in the old world, very few countries remain impoverished simply because of geography. Tyrants plague the people of North Korea; lawlessness, corrupt states, and trade-hostile laws impoverish many others. We should not end foreign aid where it’s needed, but charter cities sound like one of the only ways to make it uneeded.

California’s upcoming Cannabis ballot initiative

In November Californians will see on their ballot the Regulate, Control and Tax Cannabis Act of 2010. The act would basically “legalize” cannabis—all involved in such an industry would remain in violation of the federal Controlled Substances Act, and subject to the whims of the federal DEA and Dept. of Justice—for adults 21 and up, and set up some initial regulations on use, sale, cultivation, and transport. The act is fairly short and readable and seems like a reasonable initial regulatory structure to me.

The Good:

  • Could greatly reduce the prevalence of violent raids on private homes
  • Would keep otherwise-law-abiding adults out of the criminal justice system
  • Would reduce the wasteful use of treatment facilities on individuals just choosing treatment over jail
  • Would restore more respect for law enforcement
  • Home growing might greatly reduce the market value of cannabis, which might keep cannabis selling industries smaller, less able to lobby for looser regulations, and less able to afford expensive advertising campaigns. Ironically this act might make large-scale dispensaries—who funded the signature drive—less likely to exist.
  • The legitimization of cannabis could result in safer usage practices becoming the standard of use.
  • Local governments could add regulations to force sellers to provide safety information (e.g. how long impairment could last, how to recognize signs of trouble, recommending the use of vaporizers, harm research results)
  • Users who medically benefit from the drug (a small but non-zero percentage of CA’s current users) would have less trouble obtaining it.
  • Could significantly shrink black markets, including those that will continue to serve minors. E.g. A teen who can more easily steal pot from adult siblings or friends is less likely to seek out a dealer who may sell other drugs.
  • Could reduce alcohol use and associated violence and overdose deaths.
  • Could nudge Congress toward more reasonable cannabis laws and more federal research of cannabis (not just limited to harms).

The Bad:

  • Commercialization and legitimization will yield increases in the number of users (though in many parts of the state there are plenty of adult users).
  • Would make some law enforcement activities more difficult. E.g. users and sellers of harder drugs are often caught due to possession of marijuana, which is generally harder to conceal.
  • Home growing doesn’t nudge users toward safer delivery methods or place users in contact with someone who could theoretically provide helpful education/intervention. I say “theoretically” because California’s current policy creates too much incentive for doctors to be “pot docs”, who do little more than sell handwritten licenses.
  • Many users will simply combine pot use with alcohol use.
  • Even though it would remain illegal, driving under the influence of pot will probably rise. This is concerning, but the best available research is still pretty weak on the notion that casual usage creates significant danger. Pot users appear to be more aware of their impairment.
  • Will probably not yield of windfall of tax revenue for California
  • More people smoking things. Learning to smoke pot lessons the difficulty and foreignness of trying other smoked substances, which are generally more harmful than pot, including tobacco. If “spliffs”—cannabis with tobacco—became popular, this could lead to more tobacco smoking (which is proven to be carcinogenic) and more complicated addiction.

I still think the good outweighs the bad. Bring on the great democratic experiment!