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.

Comment on this:

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s