Link to home
Start Free TrialLog in
Avatar of MuhammadAdil
MuhammadAdilFlag for Pakistan

asked on

What is importance of Interface

Hello Experts

What is importance of interface in oops. Why we use it.
What is advantages of using interface?
What is importance of interface in enterprise level application
ASKER CERTIFIED SOLUTION
Avatar of PoeticAudio
PoeticAudio

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PoeticAudio
PoeticAudio

Some people that are new to these concepts question

"What is the point of an interface, it doesn't provide any implementation so I don't understand why I would ever use them, it just forces classes to have certain methods"

But as you saw above, the ability to create a contract that classes must abide by creates benefits because we can call the methods in those objects dynamically without caring which object it is. Sure this isn't a huge code saver (well it is, actually) but it doesn't seem so, really. Abstract classes help cut down code and logically group objects, but interfaces are more for designing flexible architectures, not so much for really saving code, it's more of a design paradigm rather then a "cut as much code as possible" paradigm. With the proper use of interfaces you can create a VERY flexible architecture. Just remember that interfaces are more for providing immensly flexible architectures and abstract classes are more for stripping out common functionality and throwing it into 1 base class so you can cut code down and make it much easier to build other objects that derrive from that base class (and building more logical designs). These are just a few benefits.