c# - I'm not sure I "get" Interfaces -


ok, understand basic concept of interface, don't know "get" it's use.

i'm in middle of writing app @ home right using abstract factory design pattern. practice, mostly, ultimate goal sell app (but that's not site).

anyway, book i'm using reference uses interface in example.

wikipedia explains "interfaces used encode similarities classes of various types share, not constitute class relationship."

so tells me interfaces used ensure similarities between classes.

so if have interface called guitar, can have abstract class called guitarabstract, , other classes called bassguitar, acousticguitar, electricguitar, of inheritance , implementation, etc.

i understand, intellectually, need , usage interfaces. seems additional, redundant code.

am missing there?

an interface allows write code work type of class, long implements required interface. allows code reused reducing work. interfaces not redundant.

an iterator example. don't care datastructure iterator represents, want retrieve data.

this purpose of interface.


Comments