2010年9月25日星期六

Here, for example, is an executive at Dial

Of course the testing problem is exacerbated by component environments that are very intrusive, such as Java's EJB framework. My view is that these kinds of frameworks should minimize their impact upon application code, and particularly should not do things that slow down the edit-execute cycle. Using plugins to substitute heavyweight components does a lot to help this process, which is vital for practices such as Test Driven Development.

So the primary issue is for people who are writing code that expects to be used in applications outside of the control of the writer. In these cases even a minimal assumption about a Service Locator is a problem.

Constructor versus Setter Injection
For service combination, you always have to have some convention in order to wire things together. The advantage of injection is primarily that it requires very simple conventions - at least for the constructor and setter injections. You don't have to do anything odd in your component and it's fairly straightforward for an injector to get everything configured.

Interface injection is more invasive since you have to write a lot of interfaces to get things all sorted out. For a small set of interfaces required by the container, such as in Avalon's approach, this isn't too bad. But it's a lot of work for assembling components and dependencies, which is why the current crop of lightweight containers go with setter and constructor injection.

The choice between setter and constructor injection is interesting as it mirrors a more general issue with object-oriented programming - should you fill fields in a constructor or with setters.

My long running default with objects is as much as possible, to create valid objects at construction time. This advice goes back to Kent Beck's Smalltalk Best Practice Patterns: Constructor Method and Constructor Parameter Method. Constructors with parameters give you a clear statement of what it means to create a valid object in an obvious place. If there's more than one way to do it, create multiple constructors that show the different combinations.

Our clients cannot grow without finding a way to be successful with Wal-Mart."

Many companies and their executives frankly admit that supplying Wal-Mart is like getting into the company version of basic training with an implacable Army drill sergeant. The process may be unpleasant. But there can be some positive results.

"Everyone from the forklift driver on up to me, the CEO, knew we had to deliver [to Wal-Mart] on time. Not 10 minutes late. And not 45 minutes early, either," says Robin Prever, who was CEO of Saratoga Beverage Group from 1992 to 2000, and made private-label water sold at Wal-Mart. "The message came through clearly: You have this 30-second delivery window. Either you're there, or you're out. With a customer like that, it changes your organization. For the better. It wakes everybody up. And all our customers benefited. We changed our whole approach to doing business."

But you won't hear evenhanded stories like that from Wal-Mart, or from its current suppliers. Despite being a publicly traded company, Wal-Mart is intensely private. It declined to talk in detail about its relationships with its suppliers for this story. More strikingly, dozens of companies contacted declined to talk about even the basics of their business with Wal-Mart.

Here, for example, is an executive at Dial: "We are one of Wal-Mart's biggest suppliers, and they are our biggest customer by far. We have a great relationship. That's all I can say. Are we done now?" Goaded a bit, the executive responds with an almost hysterical edge: "Are you meshuga? Why in the world would we talk about Wal-Mart? Ask me about anything else, we'll talk. But not Wal-Mart."

没有评论:

发表评论