|
|
|
|
|
by penprog
4202 days ago
|
|
java interfaces are one of the main reasons people like java (and as other people have said, it's reimplementation in other more modern languages shows how popular and useful they are). They promote code reuse and allow protected variation. Your professors bad explanations aren't a reason to dislike interfaces. Also how have you not, in a java class, written code that uses polymorphism? That would be the easiest way to understand how useful interfaces are. |
|
My preferred method of "inheritance" really is just extending an object. Which js is great at. And there's multiple ways to do this, with multiple kinds of prototypes. For something quick an easy I can make a prototype and just pass that through object.create() and now I have a new object that has all the properties of what I would loosely consider to be a "parent". It's more cloning than it is inheritance, and I can completely override properties however I want, while the original properties stay unchanged.
IMO polymorphism and interfaces in Java seem more like hurdles and added complexity compared to object extension and cloning in JavaScript. _.extend paired with browserify also makes for extremely modular code that I haven't seen any Java code compare too.