I’m building a decent sized application in ASP.NET/VB.NET with various objects… I’ve never used interfaces before, and a fellow programmer balked when I mentioned this to him. Can anyone give me a quick overview on how they’re used, what they’re used for, and why I would use them? Maybe I don’t need to use them for this project, but if they would help, I surely would love to try.
Thanks so much!
Once you ‘get’ interfaces, OOP really falls into place. To put it simply, an interface defines a set of public method signatures, you create a class which implements those methods. This allows you generalize functions for any class which implements a particular interface (i.e. classes which have the same methods), even if those classes don’t necessarily descend from one another.
None of the classes above descend from one another, but my HandleLifeform method is generalized to operate on all of them — or really any class which implements the ILifeform interface.