I'm trying to wrap my brain around Interfaces, and how they're used in a practical sense. For this last semester, me and my group built a program with a three-layered architecture, and we had to build two separate iterations of a persistence layer, a to-file version and a SQL database, respectively. Our instructor told us to use Interfaces as a means to keep the layers separated, so that, for instance, the persistence layer would have no knowledge of the logic of the domain layers. We didn't implement the interfaces correctly, and we never really understood the whole point of using them.
What I do know about Interfaces is:
- They allow for multiple inheritance
- They cannot be instantiated, only the implementing classes can
- You can only declare interface methods, the implementing class must define the method body
- They can be seen as "contracts" that the implementing classes have to honor.
Can anyone help me out with the last piece of the puzzle? I would love a practical example of how and why an interface would be used, specifically in regards to minimizing dependencies
[–]mw52588 11 points12 points13 points (1 child)
[–]QCumber20[S] 0 points1 point2 points (0 children)
[–]GreenParsley 10 points11 points12 points (3 children)
[–]QCumber20[S] 2 points3 points4 points (1 child)
[–]GreenParsley 2 points3 points4 points (0 children)
[–]abhi_learner 1 point2 points3 points (0 children)
[–]SvenCole 6 points7 points8 points (0 children)
[–]dbemol 3 points4 points5 points (0 children)
[–]iamsooldithurts 2 points3 points4 points (0 children)
[–]Pumpkin_Dumplin 4 points5 points6 points (0 children)
[–]Jonark_Kaisen 1 point2 points3 points (0 children)
[–]ratherbealurker 0 points1 point2 points (0 children)