Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'ve recently started looking at Android development. This has brought me back

ID: 644188 • Letter: I

Question

I've recently started looking at Android development. This has brought me back into the world of Java software development. The last time I worked with Java, I'll admit, I didn't understand OOP nearly as much as (I think) I do now.

Having mainly used C# in my career, I'm noticing a startling difference in how inheritance is used Java and C#.

In C# it seemed like inheritance could be avoided in most situations. The task at hand could usually be accomplished by using concrete classes of the .NET framework.

In Java, from what I'm gathering from code samples, it seems like the Java framework supplies many interfaces or abstract classes that are then meant to be implemented/extended by the developer.

This seems to be too big a difference to just boil down to style. What is the reasoning behind this? I feel like I won't be writing clean Java code until I understand this.

Also, is this limited to just the Android SDK or is this a Java-wide approach to OOP?

Or put in another way,

What is it about the design of these two languages that (seems to encourage) more or less inheritance use than the other?

If the languages treat inheritance identically, and assuming my observation is valid, then it means this is related to the design of the frameworks/libraries and not the languages. What would the motivation be for this kind of design?

Explanation / Answer

This seems to be too big a difference to just boil down to style. What is the reasoning behind this?

My understanding is that it largely is simply a stylistic decision. Well, perhaps not style, but the idioms of the language/environment. Java standard library developers followed one set of design guidelines and the .NET developers another (though they had the ability to see how Java's approach worked).

There is very little in the actual languages to encourage or dissuade inheritence. Only two things strike me as relevant:

.NET introduced generics earlier in their lifetime, before too much non-generic code was implemented. The alternative is a lot of inheritence to type specialize things.

A larger change was that .NET supported delegates. In Java you're stuck with (anonymous) inheritence to supply the most basic of variable functionality. This leads to a relatively large difference in how code is designed to either take advantage of delegates or to avoid the awkward inheritance structures needed to do it in Java.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote