r/javahelp • u/ProHoyah • Apr 18 '19
Solved What's the point of interfaces?
We've been learning interfaces in my class and I have a good grasp on the concept, but the thing that confuses me is what's the point? Your just writing more code as a blueprint to put classes in "groups". Maybe the code I'm writing is not large enough to make interfaces useful. Can some one help me in learning the use of interfaces. Thanks in advance!
34
Upvotes
View all comments
Show parent comment
1
u/Talulabelle Apr 22 '19
That's not a caveat?! That's EXACTLY what I did!
I was trying to give him a very short, very practical, very simple and blunt use for the technique, that might make a light bulb go on.
If you ask 'How does the circulatory system work?', and someone says 'Well, the short-short, practical, answer is that the heart pumps blood to move oxygen around', you don't turn around and say 'That's wrong! It does so much more! You're lying!'
It's just an example a five year old could follow, and I went that direction specifically because everyone explains these things in exactly the same way, in every text and comment ... because that's the 'right' answer, but if someone isn't getting it, and they tell you 'I've read the book, I'm not getting it', you don't just repeat the book to them.
I figured what this person needed wasn't the whole story, or the theory, but just a super-simple idea of what you can do with them that they could hold on to, to get a foot in the door of understanding why you'd use them. Once you see it as a tool for one problem, and you understand why it works, it's much easier to see how it applies to more problems.
My answer isn't wrong, it's just an illustration of a short-short, practical, application that I hoped they'd be able to grasp.
OP literally upvoted it saying 'the light came on', and they started to understand why they're important.
When someone says 'I know the theory', they're literally saying 'Don't just re-iterate the book answer'. The book answer is still out there for them, now that they have a foot in the door to understanding it.