這是一個標誌,這裏需要一些設計模式嗎?一堆私人物業一一執行
/**
* @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