At the moment I essentially have:
A.php:         class A { ... }
A1.php:        class A1 extends A { A1 stuff... }
A2.php:        class A2 extends A { A2 stuff... }
...
factory.php:   create($obj) {return new $obj;}
I'm thinking of changing it to:
A.php:         class A { ... }
A1.php:        class B extends A { A1 stuff... }
A2.php:        class B extends A { A2 stuff... }
...
factory.php:   create($obj) { require ($obj.".ph开发者_如何转开发p"); return new B; }
Any comments, or dangers that lie ahead? Only one class will ever get instantiated per PHP session.
My first impressions:
- You can never load both classes into memory at once. Even if you don't usually do this, it'll make, for example, unit testing hard.
- Debugging is made harder if your debugger tells you there's a problem with class B, but not which classB.
- A class describes a logical unit. There shouldn't be two logical units with the same name but different functionality.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论