Monday, December 19, 2011

Interface v Abstract Class (in my own words)

Interface based programming works very closely with DI (P2I or program to interface). The container will push the concrete implementation at runtime so the code is loosely coupled. It also promotes Test Driven Development. Why? You can by-pass the configuration files that might be looking to resolve the resources.

As for difference between abstract classes and interface, both are basically contracts that need to be followed by the implementing classes but interface allows the contract (of the methods) to be "upto" the developer. It also means the developer can now implement as many interfaces as necessary. I would like to think of Abstract Classes as "more strict". Programatically, you would be allowed to implement from only one abstract class, neither can be instantiated, and abstract classes can have concrete method definitions.

No comments:

Post a Comment