这是一个标志,这里需要一些设计模式吗?一堆私人物业一一执行
/**
* @return string
*/
public function filter($string)
{
// underscored means private
$this->_prepareSomething($string);
$this->_prepareSomething2();
$this->_prepareSomething3();
$this->_prepareSomething4();
$this->_prepareSaveSomethingToFile();
return $this->getFiltered();
}
需要更多信息才能真正辨别。 – Chris 2010-09-28 13:15:39
同意我们需要更多信息,但看起来有点像某些抽象可能适用于此处。很难说它是否仅仅为了可测试性而分裂(而不是单一的例程,将它分解成一堆小的)。但它仍然紧密结合......或许[责任链条](http://sourcemaking.com/design_patterns/chain_of_responsibility)或[Command](http://sourcemaking.com/design_patterns/command)模式可能更适合。但是,如果不完全了解它的作用,我不确定这里有什么适用的...... – ircmaxell 2010-09-28 13:19:21
首先想到的是ircmaxell提到的一个责任链,但我认为需要更多的信息。 – tplaner 2010-09-28 13:22:39