2010年9月25日星期六

The choice between Service Locator

The CIA program's original scope was to hide and interrogate the two dozen or so al Qaeda leaders believed to be directly responsible for the Sept. 11 attacks, or who posed an imminent threat, or had knowledge of the larger al Qaeda network. But as the volume of leads pouring into the CTC from abroad increased, and the capacity of its paramilitary group to seize suspects grew, the CIA began apprehending more people whose intelligence value and links to terrorism were less certain, according to four current and former officials.

The original standard for consigning suspects to the invisible universe was lowered or ignored, they said. "They've got many, many more who don't reach any threshold," one intelligence official said.

Several former and current intelligence officials, as well as several other U.S. government officials with knowledge of the program, express frustration that the White House and the leaders of the intelligence community have not made it a priority to decide whether the secret internment program should continue in its current form, or be replaced by some other approach.

Meanwhile, the debate over the wisdom of the program continues among CIA officers, some of whom also argue that the secrecy surrounding the program is not sustainable.

One year, Huffy had committed to supply Wal-Mart with an entry-level, thin-margin bike--as many as Wal-Mart needed. Sales of the low-end bike took off. "I woke up May 1"--the heart of the bike production cycle for the summer--"and I needed 900,000 bikes," he says. "My factories could only run 450,000." As it happened, that same year, Huffy's fancier, more-profitable bikes were doing well, too, at Wal-Mart and other places. Huffy found itself in a bind.

With other retailers, perhaps, Mariotti might have sat down, renegotiated, tried to talk his way out of the corner. Not with Wal-Mart. "I made the deal up front with them," he says. "I knew how high was up. I was duty-bound to supply my customer." So he did something extraordinary. To free up production in order to make Wal-Mart's cheap bikes, he gave the designs for four of his higher-end, higher-margin products to rival manufacturers. "I conceded business to my competitors, because I just ran out of capacity," he says. Huffy didn't just relinquish profits to keep Wal-Mart happy--it handed those profits to its competition. "Wal-Mart didn't tell me what to do," Mariotti says. "They didn't have to." The retailer, he adds, "is tough as nails. But they give you a chance to compete. If you can't compete, that's your problem."

The current rush of lightweight containers all have a common underlying pattern to how they do service assembly - the dependency injector pattern. Dependency Injection is a useful alternative to Service Locator. When building application classes the two are roughly equivalent, but I think Service Locator has a slight edge due to its more straightforward behavior. However if you are building classes to be used in multiple applications then Dependency Injection is a better choice.

If you use Dependency Injection there are a number of styles to choose between. I would suggest you follow constructor injection unless you run into one of the specific problems with that approach, in which case switch to setter injection. If you are choosing to build or obtain a container, look for one that supports both constructor and setter injection.

The choice between Service Locator and Dependency Injection is less important than the principle of separating service configuration from the use of services within an application.

没有评论:

发表评论