[tsmith] Abstract factories have one significant advantage over and above static Factories: [tsmith] #5 Dynamic extensibility: With abstract factories (by their very nature), one can usually plop in a new class file, change a parameter or even a text file, and the app can handle new objects that never crossed the original author’s mind. [tsmith] That’s lines 31-36 in the above file: [tsmith]
[tsmith] $cars = array(); [tsmith] 32
[tsmith] $type = ‘car’; [tsmith] 33
[tsmith] $directory = CARS_LIB_PATH . ‘/cars’; [tsmith] 34
[tsmith] 35
[tsmith] $files = scandir($directory); [tsmith] 36
[tsmith] filter_files_by_type($files, $type); [tsmith] It’s not hard to see the raw power of this.